Node-RED time alarms

Hi there,

I’m using a ‘poll state’ for getting the power consumption of a device. If the power consumption is over 200 watts it turns on an adressable LED green, if its lower than 200 watts the LED turn off. This is still working.
The next stepp I like to do is as following:
If the power consumption is higher than 200 watts for more than 5 minutes turn the LED red and stay in this state until I manual reset it.
Behavior is, that if a pump is running longer than 5 minutes I have to clean it. After I have cleaned it the status should only display if it is running. But the fault display should be showen as long as I had solved the problem with the pump.

Is there anyone who can show me how I can do this?

event state node to turn on the red. Then what ever the manual reset is, an input boolean, to turn off.

You need two triggers when the starts.
You need one with a delay of 5 minutes and the checkmark set that cancel the trigger if the state changes back again. This need then sets the red light.

Then you need a check node after the current start and stop nodes you already have. This is to check if the Les is already red and if not then do as usual, but of it is then dead end flow.

Lastly you need your manual reset and if it is Node-Red you use to trigger it then it’s just a test trigger directly at the node that sets off. If not then you can make an entity in HA to trigger it.

Many tahnks for your ideas.
I’m really new in node red, so what do you mean with

or how can I realize this?

I was not and still am not near my HA installation, so I am not certain of the right name, but I think it is “Current state” it is called.
It will pull the state of an entity in HA and embed it in the msg from the node.

If you are polling the entity with the green led flow, it updates that entity system wide not just in that node.

If you use an event state node for the entity you poll in the other flow it will update as it’s polled. The event state can be set to wait for 5 minutes as posted above.

It was the polling of the led node in the two current flow he has, in order to prevent those from changing a red led.

I’m the one who assumed.

I guess you assume a multi color led? I see it as two separate led’s.

One flow that polls a sensor and anytime it returns >200 it turns the green led on, <200 it turns off the green led.

Another flow to turn on the red led if that sensor returns >200 for 5 min with a manual shut off/reset.

Without the op’s flow, there is no way to tell the actual set up.

Edit, yup rereading it says addressable

I believe he is referring to a current state node to block the green commands.

[{"id":"0b8f5d054fc3be02","type":"poll-state","z":"f80b6c338afd5483","name":"","server":"","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"","state_type":"str","halt_if":"2000","halt_if_type":"num","halt_if_compare":"is","outputs":2,"x":240,"y":340,"wires":[["7129ccbe48edd3a2"],["2df9574c4c2d89c4"]]},{"id":"cbd6dcc1690cd583","type":"api-call-service","z":"f80b6c338afd5483","name":"turn on green","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":730,"y":340,"wires":[[]]},{"id":"0baa8cd72b5404bd","type":"api-call-service","z":"f80b6c338afd5483","name":"turn off green","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":730,"y":400,"wires":[[]]},{"id":"7129ccbe48edd3a2","type":"api-current-state","z":"f80b6c338afd5483","name":"red led boolean","server":"","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":540,"y":340,"wires":[["cbd6dcc1690cd583"],[]]},{"id":"2df9574c4c2d89c4","type":"api-current-state","z":"f80b6c338afd5483","name":"red led boolean","server":"","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":540,"y":400,"wires":[["0baa8cd72b5404bd"],[]]},{"id":"d902bbb3e265b662","type":"server-state-changed","z":"f80b6c338afd5483","name":"polled sensor","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"200","halt_if_type":"num","halt_if_compare":"gte","outputs":2,"output_only_on_state_change":true,"for":"5","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":250,"y":480,"wires":[["5c60f6618eb0846c"],[]]},{"id":"0e33a6d269f72dce","type":"server-state-changed","z":"f80b6c338afd5483","name":"red led boolean","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":260,"y":580,"wires":[["a9603147977839e1","9cddc3e2e7ec3230"]]},{"id":"a9603147977839e1","type":"api-call-service","z":"f80b6c338afd5483","name":"turn on red led","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":700,"y":580,"wires":[[]]},{"id":"9cddc3e2e7ec3230","type":"api-call-service","z":"f80b6c338afd5483","name":"turn off red led","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":700,"y":640,"wires":[[]]},{"id":"5c60f6618eb0846c","type":"api-call-service","z":"f80b6c338afd5483","name":"red led boolean turn on","server":"","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":550,"y":480,"wires":[[]]}]

Thanks. Have no time to test it until now. But you have seen my problem. Wil test it and give reply.

I prefer this solution, because there is no boolean. I use the led value in three stages.
This solution also react almost instantly on the use of the device, where the poll state node used above reacts by regular polling the state of use with intervals. Low intervals will be alot of activity on HA and high intervals will mean you might miss the 5 minutes mark with interval value -1 second.

It can be compacted a bit by reusing nodes in some of the flows, like turn off led, but I left it like this to make the 4 flows easier to comprehend.

[{“id”:“0b8f5d054fc3be02”,“type”:“poll-state”,“z”:“f80b6c338afd5483”,“name”:"",“server”:"",“version”:2,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“updateinterval”:“60”,“updateIntervalType”:“num”,“updateIntervalUnits”:“seconds”,“outputinitially”:false,“outputonchanged”:false,“entity_id”:"",“state_type”:“str”,“halt_if”:“2000”,“halt_if_type”:“num”,“halt_if_compare”:“is”,“outputs”:2,“x”:240,“y”:340,“wires”:[[“7129ccbe48edd3a2”],[“2df9574c4c2d89c4”]]},{“id”:“cbd6dcc1690cd583”,“type”:“api-call-service”,“z”:“f80b6c338afd5483”,“name”:“turn on green”,“server”:"",“version”:3,“debugenabled”:false,“service_domain”:"",“service”:"",“entityId”:"",“data”:"",“dataType”:“jsonata”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:730,“y”:340,“wires”:[[]]},{“id”:“0baa8cd72b5404bd”,“type”:“api-call-service”,“z”:“f80b6c338afd5483”,“name”:“turn off green”,“server”:"",“version”:3,“debugenabled”:false,“service_domain”:"",“service”:"",“entityId”:"",“data”:"",“dataType”:“jsonata”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:730,“y”:400,“wires”:[[]]},{“id”:“7129ccbe48edd3a2”,“type”:“api-current-state”,“z”:“f80b6c338afd5483”,“name”:“red led boolean”,“server”:"",“version”:2,“outputs”:2,“halt_if”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“entity_id”:"",“state_type”:“str”,“blockInputOverrides”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“entity”}],“override_topic”:false,“state_location”:“payload”,“override_payload”:“msg”,“entity_location”:“data”,“override_data”:“msg”,“x”:540,“y”:340,“wires”:[[“cbd6dcc1690cd583”],[]]},{“id”:“2df9574c4c2d89c4”,“type”:“api-current-state”,“z”:“f80b6c338afd5483”,“name”:“red led boolean”,“server”:"",“version”:2,“outputs”:2,“halt_if”:“off”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“entity_id”:"",“state_type”:“str”,“blockInputOverrides”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“entity”}],“override_topic”:false,“state_location”:“payload”,“override_payload”:“msg”,“entity_location”:“data”,“override_data”:“msg”,“x”:540,“y”:400,“wires”:[[“0baa8cd72b5404bd”],[]]},{“id”:“d902bbb3e265b662”,“type”:“server-state-changed”,“z”:“f80b6c338afd5483”,“name”:“polled sensor”,“server”:"",“version”:3,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:"",“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:“200”,“halt_if_type”:“num”,“halt_if_compare”:“gte”,“outputs”:2,“output_only_on_state_change”:true,“for”:“5”,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“eventData”},{“property”:“topic”,“propertyType”:“msg”,“value”:"",“valueType”:“triggerId”}],“x”:250,“y”:480,“wires”:[[“5c60f6618eb0846c”],[]]},{“id”:“0e33a6d269f72dce”,“type”:“server-state-changed”,“z”:“f80b6c338afd5483”,“name”:“red led boolean”,“server”:"",“version”:3,“exposeToHomeAssistant”:false,“haConfig”:[{“property”:“name”,“value”:""},{“property”:“icon”,“value”:""}],“entityidfilter”:"",“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“str”,“haltifstate”:"",“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“output_only_on_state_change”:true,“for”:0,“forType”:“num”,“forUnits”:“minutes”,“ignorePrevStateNull”:false,“ignorePrevStateUnknown”:false,“ignorePrevStateUnavailable”:false,“ignoreCurrentStateUnknown”:false,“ignoreCurrentStateUnavailable”:false,“outputProperties”:[{“property”:“payload”,“propertyType”:“msg”,“value”:"",“valueType”:“entityState”},{“property”:“data”,“propertyType”:“msg”,“value”:"",“valueType”:“eventData”},{“property”:“topic”,“propertyType”:“msg”,“value”:"",“valueType”:“triggerId”}],“x”:260,“y”:580,“wires”:[[“a9603147977839e1”,“9cddc3e2e7ec3230”]]},{“id”:“a9603147977839e1”,“type”:“api-call-service”,“z”:“f80b6c338afd5483”,“name”:“turn on red led”,“server”:"",“version”:3,“debugenabled”:false,“service_domain”:"",“service”:"",“entityId”:"",“data”:"",“dataType”:“jsonata”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:700,“y”:580,“wires”:[[]]},{“id”:“9cddc3e2e7ec3230”,“type”:“api-call-service”,“z”:“f80b6c338afd5483”,“name”:“turn off red led”,“server”:"",“version”:3,“debugenabled”:false,“service_domain”:"",“service”:"",“entityId”:"",“data”:"",“dataType”:“jsonata”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:700,“y”:640,“wires”:[[]]},{“id”:“5c60f6618eb0846c”,“type”:“api-call-service”,“z”:“f80b6c338afd5483”,“name”:“red led boolean turn on”,“server”:"",“version”:3,“debugenabled”:false,“service_domain”:"",“service”:"",“entityId”:"",“data”:"",“dataType”:“jsonata”,“mergecontext”:"",“mustacheAltTags”:false,“outputProperties”:[],“queue”:“none”,“x”:550,“y”:480,“wires”:[[]]}]

Thank you all for your help.
I think I’ve made it running with this:

The first inject (on) is only for test purpose.
The the first “events: state” node get the values and is wating if the runtime of the pump is to long.
If the runtime is to long ist stets the LED red and triggers a entity (Node-RED Companion) to “Alarm”.
So I can see the alarm also in LoveLace.
The OK “inject” is for reseting the alarm after checking the pump. At this state it is OK for me to do this only direct from Node_Red. May be I include a reset button to LoveLace later.
The second “events:state” node makes the same like the first but without delay. Then the current state of the entity will be checked. If it if OK and not alarm the normal running status of the pump will be showen with a green LED for running and an off LED if it is not running.

You got the idea and made your own solution. Perfect!