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

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#1 Post by JR01 » 13 Mar 2020, 23:52

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
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

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

#2 Post by TD-er » 14 Mar 2020, 00:50

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.

JR01
Normal user
Posts: 260
Joined: 14 Feb 2016, 21:04
Location: South Africa

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

#3 Post by JR01 » 14 Mar 2020, 05:46

Ohhh, was late when I tried it.... thank you, should have seen it.
-----------
IOTPLAY. Tinkerer, my projects are @ http://GitHub.com/IoTPlay, and blog https://iotplay.org. Using RPi, Node-Red, ESP8266 to prove Industry 4.0 concepts.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 34 guests