I’ve included logInfo right now. The log shows when item A received command ON only, ’
LOG:
’
2018-05-14 15:41:33.464 [ome.event.ItemCommandEvent] - Item ‘22_switch_binary’ received command ON
2018-05-14 15:41:33.478 [vent.ItemStateChangedEvent] - 22_switch_binary changed from OFF to ON
’
Two things there, either the item is not defined and never receives the command but as we saw in the log, it does so that’s not it.
Second, your rule has errors and is not parse into the engine.
What happens in openhab.log when you save the rule file?
’
2018-05-14 18:05:07.325 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘testus.rules’
2018-05-14 18:05:07.345 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘testus.rules’ is either empty or cannot be parsed correctly!
2018-05-14 18:05:07.607 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘testus.rules’
’
Delete the file
Create another one and TYPE in the following
Don’t copy and paste (2 reasons - copying and pasting from a browser can introduce and or change character) - typing code helps learning it)
Do you actually have an item A and and item B
rule "t"
when
Item A received command ON
then
//Thread::sleep(3000)
logInfo("TEST RULE","TEST RULE")
B.sendCommand(ON)
end
I have these 2 wall plugs, named A and B into HabAdmin.
I’ve followed your instructions: create a new file, type the code… then again error into the log:
’
2018-05-14 18:16:34.747 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘testus2.rules’ is either empty or cannot be parsed correctly!
2018-05-14 18:16:35.003 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘testus2.rules’
’
’
2018-05-14 18:18:49.901 [ome.event.ItemCommandEvent] - Item ‘22_switch_binary’ received command ON
2018-05-14 18:18:49.911 [vent.ItemStateChangedEvent] - 22_switch_binary changed from OFF to ON
’
Update the script:
’
rule “t”
when
Item 22_switch_binary received command ON
then
logInfo(“TEST RULE”, “TEST RULE”)
wall_plug_node11_switch_binary.sendCommand(ON)
end
’
The log shows errors again:
’
2018-05-14 18:26:47.167 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘testus2.rules’
2018-05-14 18:26:47.186 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘testus2.rules’ is either empty or cannot be parsed correctly!
2018-05-14 18:26:47.288 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘testus2.rules’ has errors, therefore ignoring it: [3,5]: no viable alternative at input ‘22_’
’
I was afraid of that
OH doesn’t like item names starting with numbers
Rename your items
22_switch_binary to switch_binary_22
and the other one
Change them in the rule and it should work
Changed the names of the items (without numbers first) but the same errors are displayed in the log:
'rule “t”
when
Item switch_22_bathroom received command ON
then
logInfo(“TEST RULE”, “TEST RULE”)
switch_11_ac.sendCommand(ON)
end
’
LOG:
'2018-05-14 18:50:43.079 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model ‘testus2.rules’
2018-05-14 18:50:43.099 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘testus2.rules’ is either empty or cannot be parsed correctly!
2018-05-14 18:50:43.351 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘testus2.rules’
’
Restarted the RaspberryPi / OH2.
No ideea where to go from here.
Maybe you should think about your naming convention. If it gets more and more and more, ordering by number may not be the best option. Here is one (good) idea: