Scheduled timers & timeouts, extended sunset/sunrise functionality
As discussed on IRC.
Today the only way to schedule things (against wallclock) is to add a script which reacts to the timechanged event, and compares the time fields. This means running one or often many LUA scripts every minute, even if it only needs to do something once every 24 hours.
In addition, we talked about adding functionality to the sunset/sunrise code.
The following have been discussed:
- Let user create "alarms"/scheduled timers which sends an event at absolute time X
- Example: turn on lights 7 am every weekday
- Pre-configured timers: in X minutes, run Y. Can be started/reset/cancelled.
- Example: at every event Y (movement detection), start/reset timer X, which waits 15 minutes and then sends command Z (turn light off)
- Timers relative to known events (sunset/sunrise)
- Example: create a timer which triggers 15 minutes before sunrise.
In addition, we've talked about adding functionality to the sunset/sunrise code:
- For every timechanged event, add field sunset_in_minutes and sunrise_in_minutes (this could be solved with above timers instead)
- Whenever sunrise/sunset calculation is re-executed (2 times per day normally), update system variables "sun(rise|set)_hour" and "sun(rise|set)_minute".
Lets gather some ideas here and see what we come up with.