I’m wondering about how to modify a flow to suppress messages if the state of an entity has changed recently… say, in the last five minutes.
Specifically, I have a flow that works really well to notify me of motion in the front yard, incorporating a couple of motion sensors. However, I don’t want it to notify me if the motion is very likely me moving around in the front yard. I’m wondering if I can insert a node that evaluates the states of my front door and garage doors to see if they’ve changed in the last five minutes, then passes the message only if those states haven’t changed. Furthermore, something like a trigger node that would reset the trigger would prevent repeated messages if there’s constant motion in the front yard.
If you’ve handled this scenario, how did you do it?
there is a “global” context in node red which can be used to store some data. So my solution for this would be to create a state_changed node for the front door. Whenever it is triggered set a global context variable like “front_door_changed” (name it how ever you like) to true, you can use the change node for this. After that start a timer with stoptimer node and duration of 5 minutes. When timer ist finished set “front_door_changed” to false. In your current flow for the motion part you can check “front_door_changed” - can be done with switch node - and only notify if it is not set to true.
A similar solution can be found to avoid repeated messages.
Ahhhh, that’s really cool. I like learning new nodes.
It appears this flow achieves something else I wanted, which is to extend the timer if the initial motion event followed an exit from the house… i.e., if I leave the house and I’m milling around the front yard, I don’t want to get motion notifications after the timer times out.
And I realized you don’t actually need a change node to set the value of the global context variable. You can set it directly (set to true in this example): global.set("LeavingHouseFront",true);. So, if I have this correct, the variable will be true when I walk out the house, and will remain true as long as there’s motion detected each 15 minutes–preventing notifications–and then only go false when the timer exceeds 15 minutes.
Yes, the stoptimer node resets the timer, everytime it gets an input, this is very useful
Just a tip: I would suggest to add a connection from “Set Global Variable to True” node to “15-Minute Timer” node. This will cover the case that you open the door and close it right away without any motion in the front yard. Without that connection the LeavingHouseFront variable would not become false after 15 minutes.