Value greater than X for Y seconds?

I'm trying to do an automation based on power consumption. It's the common If consumption is greater than 4500W for 15 seconds, send me an alert. I've been searching how to do it but couldn't find anything. And I've been trying to do it myself, but could be that I'm currently out of imagination. All I do is terribly ugly.
Any suggestions?

This should be a good starting point:

You need to feed the Decision node every x seconds with the power consumption data to get it working.
Oeps, the example is with 1500W instead 4500.

[{"id":"f6d0913d58895c5d","type":"switch","z":"b3f31bbd.8966b8","name":"Decision","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"1500","vt":"num"},{"t":"lte","v":"1500","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":460,"wires":[["f1d80ab4e00d6509"],["527da59aeca63b68"]]},{"id":"f1d80ab4e00d6509","type":"trigger","z":"b3f31bbd.8966b8","name":"","op1":"","op2":"Alarm","op1type":"nul","op2type":"str","duration":"15","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":890,"y":460,"wires":[["1c65ee92c3d04f93"]]},{"id":"527da59aeca63b68","type":"change","z":"b3f31bbd.8966b8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":500,"wires":[["f1d80ab4e00d6509"]]},{"id":"df48ae4534808675","type":"inject","z":"b3f31bbd.8966b8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1700","payloadType":"num","x":230,"y":460,"wires":[["f6d0913d58895c5d"]]},{"id":"388638e71583501c","type":"inject","z":"b3f31bbd.8966b8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1200","payloadType":"num","x":230,"y":520,"wires":[["f6d0913d58895c5d"]]},{"id":"1c65ee92c3d04f93","type":"debug","z":"b3f31bbd.8966b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1070,"y":460,"wires":[]}]
1 Like

Wow... I didn't think on reset messages.
I'll try it asap. Thanks!

Do you think that something could be added for reset the trigger after a while?
Say after the consumption is greater than 1500 for 15s we activate a relay (and let it activated).
And after a while, say 30s, the consumption being lower than 1500, deactivate the relay?

I'm thinking to resolve this by adding a secondary flow, but I think it could be done in the same, isn't it?
I'm trying this one, but it keeps sending "OFF" messages every 30s: