[SOLVED] Sunset event with offset on wrong time

I am trying to set light switch to ON 30 minutes prior to sunset event.
To accomplish this I searched the forum, and saw some programming examples, that should do the job, but seem very large for this simple question…

What I have done:

Things:

astro:sun:SchinMin30  [ geolocation="51.1222,5.875652" ] {
    Channels:
        Type start : set#start [
            offset=-30
        ]
}

astro:sun:home  [ geolocation="51.1222,5.875651" ] {
    Channels:
        Type start : set#start [
            offset=0
        ]
}

My items:

DateTime   Thuis_ZonOnder     "Zon gaat onder om [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" <sunset> { channel="astro:sun:home:set#start" }
DateTime   Thuis_Schin30_ZonOnder  "Zon onder -30 [%1$td.%1$tm.%1$tY %1$tH:%1$tM]" <sunset> { channel="astro:sun:SchinMin30:set#start" }

When i display the values on my sitemap I see the 30 minutes difference.Looks like it works.


But then…

rules:
rule “Zonsondergang: Licht achter aanzetten 30 MINUTEN VOOR ZONSONDERGANG”
when
Channel “astro:sun:SchinMin30:set#event” triggered START
then
RFX_Kaku2.sendCommand(ON)
logInfo(“RFXCOM”, “(Licht achterkamer) KAKU2 Gaat AAN 30 minuten voor zonsondergang” )
end

rule "Zonsondergang: Licht achter aanzetten ZONSONDERGANG"
when
    Channel "astro:sun:home:set#event" triggered START
then
    RFX_Kaku2.sendCommand(ON)
    logInfo("RFXCOM", "(Licht achterkamer) KAKU2 Gaat AAN op zonsondergang" )
end

Logging:

openhab.log:2020-01-21 17:04:00.619 [INFO ] [clipse.smarthome.model.script.RFXCOM] - (Licht achterkamer) KAKU2 Gaat AAN 30 minuten voor zonsondergang
openhab.log:2020-01-21 17:04:00.620 [INFO ] [clipse.smarthome.model.script.RFXCOM] - (Licht achterkamer) KAKU2 Gaat AAN op zonsondergang

The START event is exactly the SAME time. That was not my intention.
Why ?

Any help is appreciated… :smiley:

You set
astro:sun:SchinMin30:set#start

but your trigger is set to
Channel ““astro:sun:SchinMin30:set#event” triggered START

I guess you could extend your things file as follow:

astro:sun:SchinMin30  [ geolocation="51.1222,5.875652" ] {
    Channels:
        Type start : set#start [
            offset=-30
        ]

        Type rangeEvent : set#event [
            offset=-30
        ]
}

astro:sun:home  [ geolocation="51.1222,5.875651" ] {
    Channels:
        Type start : set#start [
            offset=0
        ]

        Type rangeEvent : set#event [
            offset=0
        ]
}
2 Likes

Thanks Felix.

Very obvious but not seen by me :open_mouth: :grinning:

The solution Felix provides seemed logical.
Unfortunately results are the same: :cry:

/var/log/openhab2/openhab.log:2020-01-22 17:06:00.029 [INFO ] [clipse.smarthome.model.script.RFXCOM] - (Licht achterkamer) KAKU2 Gaat AAN 30 minuten voor zonsondergang
/var/log/openhab2/openhab.log:2020-01-22 17:06:00.050 [INFO ] [clipse.smarthome.model.script.RFXCOM] - (Licht achterkamer) KAKU2 Gaat AAN op zonsondergang

Things:

astro:sun:SchinMin30  [ geolocation="51.1222,5.875652" ] {
    Channels:
        Type start : set#start [
            offset=-30
        ]
        Type rangeEvent : set#event [
            offset=-30
        ]
}


astro:sun:home  [ geolocation="51.1222,5.875651" ] {
    Channels:
        Type start : set#start [
            offset=0
        ]
        Type rangeEvent : set#event [
            offset=0
        ]
}

rules( KAKU2 is set to ON twice for debugging purpose. Log will show exact time )

rule "Zonsondergang: Licht achter aanzetten 30 MINUTEN VOOR ZONSONDERGANG"
when
    Channel "astro:sun:SchinMin30:set#event" triggered START
then
    RFX_Kaku2.sendCommand(ON)
    logInfo("RFXCOM", "(Licht achterkamer) KAKU2 Gaat AAN 30 minuten voor zonsondergang" )
end

rule "Zonsondergang: Licht achter aanzetten ZONSONDERGANG"
when
    Channel "astro:sun:home:set#event" triggered START
then
    RFX_Kaku2.sendCommand(ON)
    logInfo("RFXCOM", "(Licht achterkamer) KAKU2 Gaat AAN op zonsondergang" )
end

Sitemap shows:

So why is KAKU2 not set to ON at 16:36

Wait until tomorrow ; in general, Astro calculates events for the day ahead at midnight.

You realized you’ll see the events in your events.log ?

Well, when displaying the calculated value in the sitemap, you will see the correct time. Unfortunately the event was started without taking the offset into consideration.

The calculated value is displayed in my reply.

I hope you are right.

Thanks for your thoughts

:slight_smile:

The switch did trigger at 30 minutes prior to sunset today.
@Felix_Raetz & @rossko57 you both helped me out.

Thx !!!

1 Like