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…
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 ?
The solution Felix provides seemed logical.
Unfortunately results are the same:
/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
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
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.