[SOLVED] Dump first text rule

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’

There are errors!!
Can you post the whole file, please?

This is the all content of the file:


rule “t”
when
Item A received command ON
then
//Thread::sleep(3000)
logInfo(“TEST RULE”,“TEST RULE”)
B.sendCommand(ON)
end

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

Your item is named 22_switch_binary
Replace B by the name of the other item

rule "t"
when
    Item 22_switch_binary received command ON
then
    //Thread::sleep(3000)
    logInfo("TEST RULE","TEST RULE")
    B.sendCommand(ON)
end

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

Going to work now. Good luck

Thanks, V. I’ll try to change the names…

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. :frowning:

Your rule file load. You can ignore the first error message. It should work now.

Still not working.

Show me the logs when you switch 22 on

It’s working now, V! Thanks a lot, man.
So, the OH2 doesn’t like items with start with number - that’s the conclusion.

Please like and mark the thread as solved

Items starting with a number will work but you can’t use them in the rules…

1 Like

Another ideea succesfully tested right now if you want to keep item in order by number.
Use that approach of naming the items:


_22(add here whatever you want, but start the item with underscore instead of a number).

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: