Rules if then flag [solved]

outdoor lights go on every morning at 6:30 am and out on sunrise.

two rules - works no problem.

rule "buitenlicht aan ochtend door de week"
when   
Time cron "0 30 6 ? * MON-FRI"
then
 sendCommand(nb_s2_12_bl_hek, ON)
 end

and

rule "buitenlicht uit ochtend"
when
    Channel 'astro:sun:e89f7bb8:rise#event' triggered START 
then
 sendCommand(nb_s2_12_bl_hek, OFF)  
end

working like this from oktober orso. But now while sunrise is getting earlyer and earlyer i looked up that around june sunrise will be earlyer than 6:30 am.

How can i make the on rule so that he checks when sunrise is and if it’s before 6:30 it doesn’t go on ?

You can use a proxy item as a flag

Switch sunIsUp
rule "buitenlicht aan ochtend door de week"
when   
    Time cron "0 30 6 ? * MON-FRI"
then
    if (sunIsUp.state == OFF) {
        nb_s2_12_bl_hek.sendCommand(ON)
    }
end

rule "buitenlicht uit ochtend"
when
    Channel 'astro:sun:e89f7bb8:rise#event' triggered START 
then
    nb_s2_12_bl_hek.sendCommand(OFF)
    sunIsUp.postUpdate(ON)
end

rule "sunset"
when
    Channel 'astro:sun:e89f7bb8:set#event' triggered START 
then
    sunIsUp.postUpdate(OFF)
end

Thks,

I was looking for something like that but could not figure out how.

You’re welcome,
You can also look at:

for a more in depth option

Like if you want and mark the thread as solved, please.

Thank you

Easiest way is to use Astro binding config:

astro:sun:e89f7bb8 [ geolocation="xxx,yyy", altitude=300, interval=600 ]
{
    Channels:
        Type rangeEvent : rise#event
        [
            earliest="06:30"
        ]
}

How do i put this in a code/rule ?

edit. in config files in my things.

I will try this

@Peter_van_hanegem

I put this in the thing config file or via paperUI thing config. It is the same.