Hi,
Update: Still had the simple mode enabled and therefore wrong items. Fixed this now and it is working as expected. Stupid me. Damn.
sorry again to bother you with so many (possibly stupid issues) but I a m still struggling with the concepts and where to put an item, a channel a swithc or whatever.
You guys recommended to disable in PaperUI the “Simple Linking Mode”. So I did and removed all items (ehhhmmm… THINGS) in the PaperUI, remove all files from ./items and ./rules and really started from scratch.
So first I will show you what I have and how I have it configured.
Configuration
1. Created Things
Here, I went to add new things and discoverd through the Enocean binding my Nodon In Wall Module with both switching channels. Under PaperUI - Configuration - Things I can see it now with both switching channels:
2. Created Items
I added a file called KNEBB.items
under ./items
where I used the channel IDs from step 1 (see there)
Switch Switch_EG_Kueche_Licht "Nodon In Wall Module 1 - Channel 1" <light> { channel = "enocean:measurementSwitch:FTB3SXG:05194E91:generalSwitchA"}
Switch Switch_EG_Vorratsraum_Licht "Nodon In Wall Module 1 - Channel 2" <light> { channel = "enocean:measurementSwitch:FTB3SXG:05194E91:generalSwitchB"}
Items file got loaded succfessfully as openhab.log shows:
2020-04-26 10:04:07.926 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'KNEBB.items'
2020-04-26 10:04:09.013 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'KNEBB.items'
3. Created Sitemap
I added a sitemap with the following:
sitemap Demo label="Demo"
{
Switch item=Switch_EG_Kueche_Licht label="Küche (Licht)"
Switch item=Switch_EG_Vorratsraum_Licht label="Vorratsraum (Licht)"
}
Which loaded fine, too:
2020-04-26 10:06:02.655 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'Demo.sitemap'
2020-04-26 10:06:03.738 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'Demo.sitemap'
4. Basic functionality given
Now I can use the BaasicUI to switch my lights on and off just as needed. When switches on manually I see the state in the BasicUI getting updated. Seems to be working perfect for me.
5. Creating rules
Now to use rules I create a rule file:
rule "Auto-OFF Vorratsraum"
when
Item Switch_EG_Vorratsraum_Licht changed to ON
then
logInfo("KNEBB","Speiseraum AN")
end
Which loaded fine and logs when the configured Item triggers:
2020-04-26 10:09:05.506 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'vorratsraum.rules'
2020-04-26 10:09:06.732 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'vorratsraum.rules'
2020-04-26 10:09:15.764 [INFO ] [eclipse.smarthome.model.script.KNEBB] - Speiseraum AN
So, looks perfect, doesn’t it?
Issue
The issue arises when I try to send a command to the switch rule based (again, through BasicUI I can switch my lights on an off just as desired).
I added another action to the rules file which looks like this now:
rule "Auto-OFF Vorratsraum"
when
Item Switch_EG_Vorratsraum_Licht changed to ON
then
logInfo("KNEBB","Speiseraum AN")
Switch_EG_Kueche_Licht.sendCommand(ON)
end
Which will end up in thousands of NullPointerExceptions by just loading the changed file. And obviously the rule is not enabled and does not work.
So I am still doing something really wrong here. But what did I get wrong? Why is my sendCommand wrong (the exceptions points me the command refers to an non-existing item). But item is configured (and used by BasicUI).