Hi, I’m relatively new to Node-Red so bear with me if there is an easy answer to my problem.
Here is the scenario I am trying to achieve:
- if the TV has been turned off after 10pm AND
- the hall sensor has been triggered within 10 minutes of that event
- turn off the living room lights
I can see how I could achieve this with an ‘input_boolean’ to store the ‘TV is off’ variable but there must be a better way?
Thanks for any help!
It utilizes a time range node (after 10pm), a stoptimer node (within 10 minutes), and a traffic light node (wait until one event before the other).
To elaborate, the Event State Node for TV Off fires when the state is OFF (Halt if ON). The Time Range node passes the message if the time is after 22:00. It triggers both the Stoptimer node (for 10 minutes) and the Traffic Light (to ALLOW for the OFF regex and STOP for the STOP regex). The Stop Timer passes a 2nd payload of STOP to the traffic light after 10 minutes. Hallway motion fires when ON (Halt if OFF). When the traffic light is green, it passes that payload on to the Change Node that converts the payload to OFF (I’m not 100% sure this is necessary but I’ve had flows do the opposite of what I expected before implementing this) and on to the call service node to turn off the lights.
Excellent, thank you very much, let me give that a whizz
I see one of my issues: the time-range-switch produces “invalid date - invalid date” after deployment, will try and bypass
It may be that the time range node doesn’t allow you to cross midnight. In which case, two time range nodes (one 22:00-23:59 and one 00:00-whenever you want to stop) should work.
It looks like it was resolved by uninstalling / reinstalling…