I see that delay has a “reset” option, and I tried sending a payload of “reset” from a change node off of a service node setting “Home”. But maybe I wasn’t using it right.
You weren’t using it right. I only know this because I spent more time and rum trying to figure this out that I really probably should have. But I eventually figured it out.
You don’t send "reset as a msg.payload field. What you actually need is to ADD a msg.reset field to the message being sent.
I’m sure I’m doing it an overly complicated way and there is probably a better way; but this is how I accomplished it for my particular use:
I have a “manual control” switch that I use to disable some of my lighting automations, because you try and explain to a 2 year old why the Christmas lights won’t turn on during the day. The problem was that whenever a Mother-In-Law would use it, it would stay on manual control until I realized that the schedule wasn’t working.
At this point I decided I would put the “manual control” on a 2-hour timer. After 2 hours, revert to auto. Simple enough.
Except after 2 hours, it would turn off “manual control” like I told it to. Problem being, it didn’t matter if I had toggled the “manual control” multiple times in that 2-hr block. I needed a way to reset the timer if I turned off “manual control”, well, manually.
To explain how I accomplished it in words, it goes like this:
Poll state: manual control every 7 seconds (random, arbitrary number. Use what works for you)
Pass through ‘rbe’ node to only report when the state changes.
Next up is a ‘switch’ node:
If “manual control” state is ‘on’ I pass on to a 120m ‘delay’ node which then turns off manual control after the timer expires.
If “manual"control” state is ‘off’ I then pass on to a ‘change’ node.
In the change node I have 2 rules:
Set msg.payload to ’ ’ (Null, nothing, nada, zilch, blank)
Set msg.reset to 1
From there it passes the new changed message to the same delay mode, at which point the timer is expired.
If my wording is hard to follow, I also pasted that flow below, so if you wanted to you could import it into your Node-Red to actually look at it and change it to fit your system. It may generate some errors because your HASS instance is not the same as mine, but you may be able to figure out what you need from there.
[{"id":"2d988fb5.c27fa","type":"poll-state","z":"e1493802.d833a8","name":"","server":"eb6b4bea.ddd5a8","updateinterval":"7","outputinitially":true,"outputonchanged":true,"entity_id":"input_boolean.manual_control_ib","x":180,"y":600,"wires":[["a140386.7a6cbc8"]]},{"id":"63851fc4.aef7c","type":"switch","z":"e1493802.d833a8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":true,"outputs":2,"x":550,"y":600,"wires":[["6ff8ca80.c4edc4","75ecd1e8.f0b76"],["6a287a48.228a74","6c460922.18bd78"]]},{"id":"a140386.7a6cbc8","type":"rbe","z":"e1493802.d833a8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":410,"y":600,"wires":[["63851fc4.aef7c"]]},{"id":"75ecd1e8.f0b76","type":"delay","z":"e1493802.d833a8","name":"","pauseType":"delay","timeout":"120","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":390,"y":480,"wires":[["86c0fcbf.0dfcc"]]},{"id":"6c460922.18bd78","type":"change","z":"e1493802.d833a8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"payload","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":140,"y":480,"wires":[["75ecd1e8.f0b76"]]},{"id":"eb6b4bea.ddd5a8","type":"server","z":"","name":"Home Assistant","legacy":false}]