Check motion in the past 10 minutes

Is there a way in node-red to check if there is motion state on in the past 10 minutes for a motion sensor?

You could use a history stats sensor that counts the number of β€˜on’ states in 10 minutes and use that (>0). If you like you can also add a template binary sensor with a device class β€˜motion’ that mimics a real sensor.

2 Likes

image

[{"id":"68d81fb0.78a26","type":"debug","z":"ffbd7f06.4a014","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":950,"y":704,"wires":[]},{"id":"6d13bcbf.56d2f4","type":"inject","z":"ffbd7f06.4a014","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":476,"y":704,"wires":[["c214238f.fcf0a"]]},{"id":"c214238f.fcf0a","type":"api-get-history","z":"ffbd7f06.4a014","name":"","startdate":"","enddate":"","entityid":"sensor.motion","entityidtype":"is","useRelativeTime":true,"relativeTime":"10 minutes","flatten":true,"output_type":"array","output_location_type":"msg","output_location":"payload","x":630,"y":704,"wires":[["8a45d50.3e87328"]]},{"id":"8a45d50.3e87328","type":"function","z":"ffbd7f06.4a014","name":"","func":"if(msg.payload.filter(item => item.state == \"on\").length) {\n    return msg;\n}","outputs":1,"noerr":0,"x":802,"y":704,"wires":[["68d81fb0.78a26"]]}]
4 Likes

Thanks both!