Page 1 of 1

Rules - if power out, and power comes on at night, switch on lights

Posted: 13 Mar 2020, 23:52
by JR01
Hi, we have lots of power outs in South Africa now, sometimes after dark. I currently have a rule which switches on after sunrise, and off before sunrise. But this does not work if the power comes up inbetween these two events - and thus lights are off. How can I make the below additional rule work? (it does not work):

Code: Select all

on Time#Set do
  If %systime% < %sunrise-20m% and %systime% > %sunset+15m% 
    gpio,12,1
  else 
    gpio,12,1
  endif
endon

Re: Rules - if power out, and power comes on at night, switch on lights

Posted: 14 Mar 2020, 00:50
by TD-er
I don't think the if statement does ever match.
Sunset is after sunrise, so there is no time when it is < sunrise AND > sunset.

If you switch both > < and invert the GPIO value (actually you set both situations to '1' now) it may work.

Re: Rules - if power out, and power comes on at night, switch on lights

Posted: 14 Mar 2020, 05:46
by JR01
Ohhh, was late when I tried it.... thank you, should have seen it.