I have a ZWave light bulb and a ZWave 4-button wall switch, both connected to Domoticz installed on a Raspberry Pi.
I'd like the following scenarios :
- Button 1 : lamp on for 30 minutes
- Button 2 : lamp off
- Button 3 : lamp always on
- Button 4 : summon Cthulhu
Each buttons overrides the previous action (Button 3 -> Button 1 = on for 30 minutes)
Wiring and programming the buttons is easy, but now, how about the timer ? I'd like to avoid creating a homemade service because I'm afraid of messing with init.d
.
I have 3 possibilities :
Domoticz dummy switch
Domoticz allows to create a dummy switch which can change states after some time given in an interface :
Pros
- off-the-shelf timer!
- I can interact quite quickly between my wall switch and the lamp
Cons
- although Domoticz handles MQTT, there will be a lot of LUA script and "blocky" to interconnect devices
- time might not be easily configurable...
at
and atq
at
is a linux command to plan an action in time, as simple as
at [when] < [what]
Pros
- multi-timer service
- easy to use and call
Cons
- at only gives an unique ID, unless parsing the planned command I can't give a name to the job (unless with a magic linux command...)
- therefore I need to code/implement a job matcher using a database
Crontab
Crontab is a linux service to plan repetitive tasks. In my case it will be a simple
# check every minute
* * * * * /path/checktimer.sh
Pros
- Reliable time trigger
Cons
- Cannot manage seconds...
- Still forced to maintain somewhere a job matcher
To my question :
- Did you have to manage timers like this kind?
- Did I miss other more reliable/configurable solutions?
- Do you have a preference with on the solutions above?