Hi, I would like to automate my lights, so that they switch on when the sun goes down and switch off when the night is over.
I created this lichter.rules files and put this code in it.
rule "Nacht start Licht Buero EIN"
when
Channel 'astro:sun:local:set#start' triggered START
then
E_Office_Light.sendCommand(ON)
end
rule "Nacht ende Licht Buero AUS"
when
Channel 'astro:sun:local:rise#start' triggered START
then
E_Office_Light.sendCommand(OFF)
end
I did not create any things objects for astro. I understood that it is not necessary. Ofcourse the light E_Office_Light is in a thing file and has the status ON or OFF
I use openhab 2.5, astro 2.5.10., my lights are homematic HmIP-FSM16 and runing on raspberymatic
Thanks for the help
ps: I noticed that my system has a delay of 1 hour I assume the time is not set properly. I created a corn job to stop the light at a specific time. Just as information…
You need to create a thing for the sun. Based on that you will have local time (set up geolocation) and available channels (visible directly if you define it in Paper UI)
Ow thanks a lot for your quick answer, that is awesome.
So I create a thing for the sun, should it be called sun or it doesn’t matter? But the name of the thing is not needed, right?
I can leave the code as I wrote it in the lichter rules? The channel wil triger it, right?
shall be OK assuming the channel name is correct. Not sure about local from the above. If you use Paper UI you need to copy the name of the channel generated by Openhab. If you define on your own you need to refer to Thing definition name accordinlgy,
Maybe I did understand you wrong. In PaperUI ther is a thing for sun already existing with the name astro:sun:local. So I do not need to create a file called lichter.things right? I can delet it? Because the thing needed is already in paperUI. I’m I right?
this is the right one to work without item definition which is triggered START/END. But this is for sun rise. You may need a similar channel for sunset event! (to switch your light on)…See for a channel like
astro:sun:local:set#event in Paper UI
It shall work in your rule, if not check as follows:
do you have proper geolocation and update interval set up at the thing level, if yes:
see openhab event log for astro event evidence (you may need to wait ~24 hours for next sunrise event )
Same problem for me. I have several astro rules and they are have problems with OH 3.0. Interesting that some of them triggered yesterday, but today no rules fired at all.
// Christmas lights auto
rule "Sunset Rule"
when
Channel "astro:sun:home:civilDusk#event" triggered START
then
logWarn("light", "Sunset Rule")
g_light_christmas.sendCommand(ON)
end
Was NOT fired. (No message “Sunset Rule” or any error messages related around it).
Then, i coped rule to 2nd one, saved file (OH reloaded .rules file):
// Christmas lights auto
rule "Sunset Rule 2"
when
Channel "astro:sun:home:civilDusk#event" triggered START
then
logWarn("light", "civilDusk trigger")
end
// Christmas lights auto
rule "Sunset Rule"
when
Channel "astro:sun:home:civilDusk#event" triggered START
then
logWarn("light", "Sunset Rule")
g_light_christmas.sendCommand(ON)
end
And triggered via CLI again using same command -> BOTH (old and new rules) were triggered.
My answers/comments were related to astro setup in OH2.
I am not yet on OH3. This might be more OH3 rule related issue? and might be good to start a separate conversation with [OH3] beginning for a proper attention
Oops, sorry, i missed that point. This topic was found using “OH 3.0” search. I will try to isolate this issue and open proper bug report for OH 3.0 version.
Just figured out, that my timezone seams to be incorrect. In the settings of openhab it is set correctly. I supect that my docker container might be wrong. So I will try to fix the timezone issue and mybe it will help.
You do confirme that my rule should work so I will leave it like it is now and testing for the next 48 houres.
Thanks for the help. I might come back in a couple of days
I do not see anything strange with it. In my location sunset starts is 15:30 in Winter time, then few minutes later sunset ends. If it is too bright to turn on the lights you can use another channel in the rule (ex Dusk) or set offset parameter at the Sunset Range channel to move the event…