Rule depending on switch-state and time from astro binding

Hello,

i am trying to set up a rule depending the state of a switch and the time now (compared to a time from the astro binding).

What the rule should do:

  • If the switch is on, everything should be turned of at the trigger
  • If the switch is on an time is before sunset, just the tuner should be turned on
  • If the switch is on an time is after sunset, the tuner and some lights should be turned on

this is my actual rule, but it doenst work, i get this warning in the console:

18:45:13.158 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'dashbuttons.rules' has errors, therefore ignoring it: [15,59]: no viable alternative at input '&&'
rule "Dash button pressed"
    when
        Channel "amazondashbutton:dashbutton:xx-xx-xx-xx-xx-xx:press" triggered
then
    var SunSetTime = (AstroSunData_Set_StartTime.state as DateTimeType).calendar.timeInMillis
    if(ZW_Steckdose_Wohnzimmer_Media_Switch.state == ON) {
    sendCommand(Group_Lichter, OFF)
    sendCommand(YamahaReceiverRXV775_Power, OFF)
    createTimer(now.plusSeconds(1)) [| sendCommand(LgTv_Poweroff, ON) ]
    createTimer(now.plusSeconds(10)) [| sendCommand(ZW_Steckdose_Wohnzimmer_Media_Switch, OFF) ]
    createTimer(now.plusSeconds(1)) [| sendCommand(LgTv_Poweroff, OFF) ]
    }
    if(ZW_Steckdose_Wohnzimmer_Media_Switch.state == OFF) && (now.isAfter(SunSet_Time)) {
    sendCommand(ZW_Steckdose_Wohnzimmer_Media_Switch, ON)
    createTimer(now.plusSeconds(20)) [| sendCommand(YamahaReceiverRXV775_Power, ON) ]
    createTimer(now.plusSeconds(4)) [| sendCommand(YamahaReceiverRXV775_InputSource, 'TUNER')]
    }
    if(ZW_Steckdose_Wohnzimmer_Media_Switch.state == OFF) !!  (now.isAfter(SunSet_Time)) {
    sendCommand(Group_Wohnzimmer_Licht, ON)
    sendCommand(ZW_Steckdose_Wohnzimmer_Media_Switch, ON)
    createTimer(now.plusSeconds(20)) [| sendCommand(YamahaReceiverRXV775_Power, ON) ]
    createTimer(now.plusSeconds(4)) [| sendCommand(YamahaReceiverRXV775_InputSource, 'TUNER')]
    }
end

thanks for your help!

Alex

This statement is wrong. It should be:

if(ZW_Steckdose_Wohnzimmer_Media_Switch.state == OFF && now.isAfter(SunSet_Time))

Further, there is no such operator as !!.

if(A && B) -> if A is true AND B is true.
if(A || B) -> if A is true OR B is true.
if(A && !B) -> if A is true AND B is false.

thank you @Udo_Hartmann ! It works fine now!