Simple rule but "no viable alternative" error

Hi,

I’m sure someone could help me with this …

When the rollershutter is closed the rule should switch off the (presence simulating) light.

rule "Urlaub WZ Licht aus"                                               
    when
        EG_wzsued_r_Rollershutter changed to 100
    then    
        if (urlaub == ON && EG_wz_l_x_decke_Switch1.state == ON) {
            EG_wz_l_x_decke_Switch1.sendCommand(OFF)
                        Thread::sleep(100)
                        logInfo("URLAUB", "--> URLAUB: WZ Licht aus wg. Rollladen zu")
            }
end
// items

Rollershutter   EG_wzsued_r_Rollershutter   "WZ-süd: Rollladen" <rollershutter>         (gM,gR,gMQTTv2,Gtest,Gshelly,GrolloOpenS2,Gwz) [ "Switchable" ]      {channel="mqtt:topic:mosquitto:shelly25_4:Shelly25_XXXXX_roller"}

But VScode throws this error message:
no viable alternative at input 'EG_wzsued_r_Rollershutter'

Hi,
Your’re Missing the Item in front of yout trigger. It should be

Item XYZ changed to 100

Also, if “urlaub” is an item, then you forgot the .state!

Also, side note, don’t use Thead::sleep

2 Likes

Thank you for pointing me in the right direction.

Yes, urlaub is a virtual item (switch) on my sitemap.

Concerning Thread::sleep: I thought values around 100 ms are ok?

Well, yes they are ok, but since you’re writing the rule now, maybe use a timer - that’s always better i’d say.
I don’t really see, why you would need the delay here anyways? Maybe you could explain the reason why you put it there…

You’re right - actually there is no need for delay.

1 Like