About This File
Sankotronic's scene for scheduling time based events (Topic 23510) is a shining example of LUA coding and impeccably documented. It's very powerful and caters for just about every scheduling requirement that you could think of, as well as adding a lot of useful variables that can be used to check whether a scene is running at different periods in the day, week, month, year etc. However, with that power comes a little added complexity, and it's possible that your requirements are much simpler. If you're one of those people and haven't already implemented your own scheduling scene, then that's where this scene may help.
SIMPLE TIMER SCENE
This scene will simply update global variables, either on a periodic basis, or at selected times of the day. These global variables can then be used to trigger other scenes by adding them to the %% globals section in the header, eg:
--[[
%% globals
fiveMinuteTimer
--]]
It will automatically create the global variables, so you don't need to worry about doing this manually.
At the beginning of the scene is a table that contains the timers that you want to create, and you should modify this table according to your requirements. For each timer, as well as the timer name, you also specify either:
- The frequency in seconds that the timer will be triggered, or
- The set time(s) that the timer will be triggered, in HH:MM format.
Two special values for 'sunrise' and 'sunset' can be used to trigger scenes to run at these times.
This is the table that you should update:
local timers = {
timer1 = {name="oneMinuteTimer", frequency=60},
timer2 = {name="fiveMinuteTimer", frequency=300},
timer3 = {name="fifteenMinuteTimer", frequency=900},
timer4 = {name="twelveHourTimer", frequency=43200},
timer5 = {name="garageDoorCheckTimer", setTimes={"20:00", "21:00", "22:00"}},
timer6 = {name="sunriseTimer", setTimes={"sunrise"}},
timer7 = {name="sunsetTimer", setTimes={"sunset"}}
}
It is recommended that you set on the 'Do not allow alarm to stop scene while alarm is running'. If not, then whenever Fibaro's alarm is triggered, then all your scenes that depend on these timers will stop.