Home Assistant Community

How to do something if a specific condition persist for a specific time

#1

Hello,
I’m monitoring a Innr plug where is plugged my fridge.
At the moment my flow just insert the current consumption in an influxdb table and then I use ti with Grafana to monitor the fridge consumption.
Now I would like to add a piece of code to check if there is a consuption below a specific threshold for a specific time to raise an alert Because the fridge could be broken.
Is there any smart way to do this (new palette to add…) ?

Thank You

#2

You could use a Stop timer. When the state of your sensor falls below X, the Stop timer begins counting for the specific amount of time. When the time expires, you get a notification. If during that time the state of the sensor returns to an acceptable position, deliver a STOP message to the timer and the timer will stop, and then you can add any notification or action to that path.

1 Like
#3

A trigger node will do it, no need to add any extra node types. Configure it to wait the desired time before passing the message along, and reset it if the consumption gets above threshold again.

Like this

[{“id”:“53d8c8fe.ce8b98”,“type”:“server-state-changed”,“z”:“eeb7694d.de6c18”,“name”:"",“server”:“b3647e80.a78bd”,“entityidfilter”:“sensor.fridge_consumption”,“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“num”,“haltifstate”:“10”,“halt_if_type”:“num”,“halt_if_compare”:“gt”,“outputs”:2,“output_only_on_state_change”:true,“x”:257,“y”:2490,“wires”:[[“d8605723.9805e”],[“61379f1.9fb786”]]},{“id”:“d8605723.9805e”,“type”:“trigger”,“z”:“eeb7694d.de6c18”,“op1”:"",“op2”:"",“op1type”:“nul”,“op2type”:“payl”,“duration”:“10”,“extend”:false,“units”:“min”,“reset”:"",“bytopic”:“all”,“name”:"",“x”:650,“y”:2483,“wires”:[[“b9308a80.5505f8”]]},{“id”:“b9308a80.5505f8”,“type”:“debug”,“z”:“eeb7694d.de6c18”,“name”:"",“active”:true,“tosidebar”:true,“console”:false,“tostatus”:false,“complete”:“false”,“x”:808.5,“y”:2483,“wires”:[]},{“id”:“61379f1.9fb786”,“type”:“change”,“z”:“eeb7694d.de6c18”,“name”:“reset”,“rules”:[{“t”:“set”,“p”:“reset”,“pt”:“msg”,“to”:“true”,“tot”:“bool”},{“t”:“set”,“p”:“payload”,“pt”:“msg”,“to”:“false”,“tot”:“bool”}],“action”:"",“property”:"",“from”:"",“to”:"",“reg”:false,“x”:496,“y”:2514,“wires”:[[“d8605723.9805e”]]},{“id”:“b3647e80.a78bd”,“type”:“server”,“z”:"",“name”:“HASS”,“legacy”:false,“hassio”:false,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”}]

1 Like
#4

Thank You guys,
both solution work fine.
The @arretx one is easier to be understood immediately and the @AndreasM one is completely already integrated and let me learn more about Node-Red messages.

Thank You again

#5

the wait until node is a really simple way to do this as well.

wait for a set amount of time until the state meets your condition,

  • if it does one output is chosen
  • if it doesn’t and the time runs out another output is chosen

I use them all the time for things like, waiting for a set amount of no movement before turning of the lights etc.