[SOLVED] Gettings mismatch input "item" expecting "end" errors in rule

rules
Tags: #<Tag:0x00007fe058071350>

(J Wee) #1

I am getting these errors to switch on and off my sonoff powerstrips

2018-11-16 14:01:50.080 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.rules’ has errors, therefore ignoring it: [39,2]: mismatched input ‘Item’ expecting ‘end’
[48,2]: mismatched input ‘Item’ expecting ‘end’
[57,2]: mismatched input ‘Item’ expecting ‘end’
[66,2]: mismatched input ‘Item’ expecting ‘end’
[74,2]: mismatched input ‘Item’ expecting ‘end’
[82,2]: mismatched input ‘Item’ expecting ‘end’

home.rules

rule “Frontdesk Powerstrip to OFF”
when
Time cron “0 0 19 1/1 * ? *”
then
Item sonoffps.sendCommand(“OFF”)

logInfo("info","Frontdesk Powerstrip OFF Rule fired")

end

rule “UPS1000 Powerstrip to OFF”
when
Time cron “0 0 19 1/1 * ? *”
then
Item sonoffps2.sendCommand(“OFF”)

logInfo("info","UPS1000 Powerstrip OFF Rule fired")

end

rule “Frontdesk Powerstrip to ON”
when
Time cron “0 0 7 ? * MON-SAT *”
then
Item sonoffps.sendCommand(“ON”)
logInfo(“Info”,“Frontdesk Powerstrip ON Rule fired”)
end

rule “UPS1000 Powerstrip to ON”
when
Time cron “0 0 7 ? * MON-SAT *”
then
Item sonoffps2.sendCommand(“ON”)
logInfo(“Info”,“UPS1000 Powerstrip ON Rule fired”)
end

What am I doing wrong?


(namraccr) #2

Please add code fences to your post.

Here’s the first offender:

then
Item sonoffps.sendCommand(“OFF”)

If you have a variable an item named sonoffps, this should be:

then
sonoffps.sendCommand("OFF")

(Vincent Regaud) #3

If you have an item named sonoffps, this should:


(namraccr) #4

Nice catch.


(J Wee) #5

Thank you @vzorglub and @namraccr!
Will my rules be “forgotten” everytime Openhab is rebooted/restarted? my OH2 resides on an ubuntu VM which I backup every night


(Vincent Regaud) #6

You can actually get rid of the quote IF the item is a switch item:

 sonoffps.sendCommand(OFF)

(J Wee) #7

Noted. Would it also fire if the quotes were present?


(Vincent Regaud) #8

Yes, all items accept strings