I have the following situation:
If I have an open window or open door of my car, I receive an input message by MQTT and the result is that I receive a notification by email. So far, so good. Every 5 minutes the status of the doors and windows are checked. This is important, as I do not want to have a door or window open in case of a rain shower. But, if I have to unload goods from my car, the door(s) or tailgate maybe open for a longer period and in this case it is not needed to receive a notification.
I have been looking for a (contrib) node that receives the input message, stores it and send it to the output, if a second, identical input is received within a time frame. If this not happens the storage should be cleared. I did not find a node, that I could use.
My first idea was to use a "Function" node and to store the first message in a Context store, if a second identical message is received within a certain time frame, it is compared with the Context store. In case it is identical the message is returned and the store cleared.
However, the disadvantage is that you have to create such a "Function" node for each door and window. The name of the doors and windows are included in the topic.
Such a way of confirmation of a message is quite common in the Security and Fire Alarm business.
Is here anybody, who ever made such a solution or knows a suitable node for this.
Thanks for any hint in advance.
The filter node (previously RBE / Report By Exception) built in to node-red can be configured to only pass the msg upon change.
Also the filter node can be told to filter based on the topic, so each topic is treated like a separate channel.
Hello @Steve-Mcl and @Colin
Thanks for your responses.
I know that the Filter node (previously called RBE) can be configured that way. However I receive messages that do not change (except of the time).
Imagine, my left front window is "Open". The first time, I receive a message "Open", after 5 minutes I receive (with RBE configured) nothing, as it has been blocked by RBE. It will be "reset", as soon as I receive the message "Closed". Actually I do not want a notification, when I receive the first message, but only if I receive the (same) second message (or even third, etc)
The Filter (RBE) node will not help me.
Currently I think that node-red-contrib-delay-gate (node) - Node-RED comes closest to what I want to achieve, However this node is controlled by time and not by the number of received messages.
Think of the problem a different way round. If I understand correctly you want a notification if the window is opened and not closed within 5 minutes. You can do that with a Trigger node. Configure it to
Wait 5 minutes
Then send the notification
But to Reset if the Closed message is received.
Steve and Colin, thank you both for the suggestions.
I did some testing in my application and both the "contrib-delay-gate" and the "trigger" node can do what I wanted them to do. Finally I selected the "delay-gate" node, as that gave me a few extra possibilities.