I've been struggling to go forward on my project for a week now.
My intention is to automate a set of lights so that they turn on automatically before sunset and switch off later in the evening, come on during the night on PIR activity only and then come back on early in the morning, then switch off after sunrise.
The Sonoff board is flashed and working, PIR attached and working, however, I just can't find a way to do all of the above via rules.
The idea is that if the board loses power for some reason, I would like it to check the time and take the appropriate action. I don't understand what trigger I should use instead of Relay#Switch=0 to trigger the action as Time#Clock does not work with greater than - lower than.
Any help would be appreciated.
Code: Select all
on Time#Initialized do
gpio, 12, 0 //Board connected to wifi and time initialised
endon
on Relay#Switch=0 do
if %systm_hm% > %sunset-20m% and %systm_hm% < 20:30
gpio, 12, 1
endif
endon
on Clock#Time=All,20:31 do
gpio, 12, 0
endon
//Following code is working
on PIR#Switch=1 do
if %systm_hm% > 20:31:00 and %systm_hm% < 23:00:00
gpio, 12, 1
timerSet,2,30
endif
endon