hey guys, please help me out - i thinks its an easy task but didnt find some quick-infos.
i want to turn ON my garden light at sunset or 9 pm and turn the lights OFF at 01:00 am.
this is my rule so far - do i need to make another rule to turn it off ?
i think it should work just in 1 rule, but dont get it…
Thanks!
rule "Gartenbeleuchtung einschalten"
when
Item NightState received update
then
if (NightState.state == "ON")
{
HK_IT02_Gartenlampen.sendCommand(ON)
}
else
if (NightState.state == "OFF")
>>>> how to get a specific time in here ? <<<<
{
HK_IT02_Gartenlampen.sendCommand(OFF)
}
end
OK, since NightState has nothing to do with 9pm and 1am then you should use two Rules, a cron triggered rule that triggers at 9pm and sets the lamp to ON and another that triggers at 1am that sets the lamp to OFF. NightState has nothing to do with it because NightState doesn’t change based on time but based on sun position. NightState will not turn on at 9pm so we can’t use it to turn on the lamp and it doesn’t turn off at 1am so we can’t use it to turn off the lamp.
thanks guys for the help! - thats my result for now - and i think this will do the trick
rule "Gartenbeleuchtung einschalten"
when
Item NightState received command ON or
Time cron "0 0 21 * * ?" // Jeden Tag um 21 Uhr Nachts
then
HK_IT02_Gartenlampen.sendCommand(ON)
end
rule "Gartenbeleuchtung ausschalten"
when
Time cron "0 0 1 * * ?" // Jeden Tag um 1 Uhr Nachts
then
HK_IT02_Gartenlampen.sendCommand(OFF)
end
changed to ON - or - received command ON !? whats the better choice ?
what a nice solution - i will give it a try - thanks for this!
It depends. Your Rule that updates NightState uses postUpdate so received command would never trigger the Rule. That is why I used changed to.
With postUpdate and your original “Update NightState” rule NightState gets updated every time SunElevation changes. But you don’t really care if NightState updated to control your light, you only care when it changes. And when you break the Rules up into two, you only care when it changes to ON.