I have a couple questions about the way Vera is handling some events and timers, as exhibited in the DayOrNight plugin’s implementation file.
Let’s assume that sunset is 7pm and sunrise is 6am and that I have a sunset offset of 30minutes, so that my sunset is at 6:30pm.
Here’s the scenario:
06:00 - sunrise arrives, and DayOrNight (DN) sets itself a timer for 18:30 based on offset.
13:00 - Vera reboots for some reason
13:00:20 - DN inits and sets itself a timer for 18:30
→ this 20 second delay, I assume, is to allow Vera to settle down after a reboot, and have a valid value for is_night()
18:30 - timer fires as scheduled, DN switches to Night time, scenes/PLEG that use DN as trigger get fired
18:40 - Vera reboots for some reason
18:40 - DN indicates Night time because that is what what is in the config file prior to reboot
→ is that a correct assumption?
18:40:20 - DN inits and sets itself to Day, because is_night says day (it’s not 7pm yet)
→ ZWave-enabled rooster now crows because daytime has arrived
18:40:20 - DN sets itself a timer for 18:30 (which will be tomorrow!)
19:00 - (real sunset occurs)
19:05 - scripts that use is_night know that it is night, but those that ask DN get Day instead
→ true?
all night long - DN indicates Day, since it never had a chance to adjust
06:30 - how would DN know that it is daytime? It never got the chance to set itself a timer for daytime? The next timer event would be 18:30. Therefore, it’s now correctly (still) indicating Day, but the rooster doesn’t get told to crow.
→ when you ask Vera to call your function with luup.call_timer(), does that persist through a reboot? In other words, Vera must be using some kind of internal database to schedule this call? Because I know that if a scene has delayed actions and Vera reboots prior to that timer, those delayed actions never fire. So can we rely on Vera’s call_timer, or should we keep track of our own scheduling and check ourselves every N seconds/minutes?
My questions here are programming related, using DN as an example only, this isn’t really a discussion/concern about the DN plugin.
Thanks for your help, all!