Call service after 10 seconds with a range

thanks in advance
i have struggled with this basic task for a while and i can do it so easily in the home assistant automations but i want it in node red as part of a larger flow.
i have a temperature sensor continually fluctuating, and i want to switch on a fan only if the temperature is within a range for more that a minute
(Not when it is under or over a number)

i have simplified my example
"when temperature is between 30 and 40"- "for more that 1 minute"- "switch on fan"

i have tried timers and loops restricted messages and i keep getting lost

i couldn't use a delay because i need it different automation when the temperature goes out side the range, the delay node was just triggering the node late even if the temperature had moved outside the range
i wasnt able to use the trigger node because the temperature was always changing and resetting the trigger timer

You can cancel the second, delayed message from a trigger node by sending msg.reset.
Sending another temperature within the range doesn't retart the countdown.

[{"id":"f4eca1737fc074f0","type":"inject","z":"f7d3b9792b4e31ae","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19","payloadType":"num","x":110,"y":100,"wires":[["91965a69aa2ab915"]]},{"id":"71022b6689a6bc0b","type":"trigger","z":"f7d3b9792b4e31ae","name":"","op1":"","op2":"ON","op1type":"nul","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":630,"y":140,"wires":[["34a67c24a55a01cc"]]},{"id":"91965a69aa2ab915","type":"switch","z":"f7d3b9792b4e31ae","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"20","vt":"num","v2":"30","v2t":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":140,"wires":[["71022b6689a6bc0b"],["b2a61973ed87d686"]]},{"id":"b2a61973ed87d686","type":"change","z":"f7d3b9792b4e31ae","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":160,"wires":[["71022b6689a6bc0b"]]},{"id":"d31414fad885e286","type":"inject","z":"f7d3b9792b4e31ae","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":110,"y":140,"wires":[["91965a69aa2ab915"]]},{"id":"60a57b056134928c","type":"inject","z":"f7d3b9792b4e31ae","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"29","payloadType":"num","x":110,"y":180,"wires":[["91965a69aa2ab915"]]},{"id":"5809522291822f4f","type":"inject","z":"f7d3b9792b4e31ae","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"31","payloadType":"num","x":110,"y":220,"wires":[["91965a69aa2ab915"]]},{"id":"34a67c24a55a01cc","type":"debug","z":"f7d3b9792b4e31ae","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":140,"wires":[]}]
1 Like

Perhaps the hysteresis node will help here, it allows you to set lower/upper thresholds and compares it to the previous value.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.