My OH grows up and I have new problem)))
I would like to turn on the light after sunset (with astro binding) but if anyone present in house (presence item I already have). Here is the code. It works well.
rule "Light ON on Sunset"
when
Channel 'astro:sun:home:set#event' triggered START
then
if (PresenceAnyone.state == ON) {
gLight.sendCommand(OFF)
}
End
But if at sunset was nobody at home and he/she will come later the light must be also ON, how can i describe it? Yes i can make trigger that is sunset has already came and check it. But if OH restart and loose state of this item.
So I need to check something like this
CurrentTime >= 'astro:sun:home:set#event'
But how it will be right from the syntax side?
Or in other words how can I check at this moment if
'astro:sun:home:set#event'
altready trigged or not (even if OH was offline in the time when trigger fired)?
rule "Light ON on Sunset"
when
Channel 'astro:sun:home:set#event' triggered START
then
SunIsUp.postUpdate(OFF)
if (PresenceAnyone.state == ON) {
gLight.sendCommand(ON)
}
end
Another rule to reset the SunIsUp item
rule "Light ON on Sunset"
when
Channel 'astro:sun:home:rise#event' triggered START
then
SunInUp.postUpdate(ON)
end
And finally a presence rule:
rule "Someone came home"
when
Item PresenceAnyone changed to ON
then
if (SunIsUp.state == OFF) { //After sunset
gLight.sendCommand(ON)
}
end
If you look at the Time of Day DP, you will see what it does is it triggers at all of the important times AND at System started. So if OH was down during one of the time events, the correct state still gets calculated when OH comes back up.
So question is open.
This is really important problem, it can be used not only in this case, but in many others if OH goes offline.
How it can be solved or at least how it can be checked?