Check time before taking action

I’ve got following 2 rules.
One put the lights on with sunset, the other puts them out at 20:00.

rule "TIJD917"
        when
          Item Daylight changed from ON to OFF
        then
          sendCommand( VERL_ParkingParkeerstroken, ON)
        end

rule "TIJD904"
        when
          Time cron "0 0 20 * * ?"
        then
          sendCommand( VERL_ParkingParkeerstroken, OFF)
        end

But today, sunset is later then 20:00, so no need to put hte light on. :blush:

What’s the best way to check this?
Something like “if currentTime < 20:00” ?

Hi

Have you considered using a variable (or an Item) and an if statement as an inihibit?

Along with a third cron rule to cancel the inihibit?

How do you set the state of the item Daylight? By using the Astro-Binding?
If yes, you can set the “earliest” time on a channel exactly for that purpose.

I’ve used now an extra item as reference. Looked the easiest way to me. :blush:

rule "TIJD917"
        when
          Item Daylight changed from ON to OFF
        then
          sendCommand( VERL_ParkingParkeerstroken, ON)
        end

rule "TIJD904"
        when
          Time cron "0 0 20 * * ?"
        then
            if(DaylightPass.state == OFF) { 
               sendCommand( VERL_ParkingParkeerstroken, OFF)
               sendCommand( DaylightPass, ON)  
            } 
        end

rule "TIJD907"
        when
                Time cron "0 15 0 * * ?"
        then
                sendCommand( DisplayPass, OFF)
        end

I’ll try later on the ‘earliest time’ channel.
It’s not clear to me who this just (should) work.

1 Like