Right way/better way: action if other entity inactive "recently"

Noob here. I have two sensors, a PIR sensor outdoors, and a door switch. I want to trigger a response if there is motion sensed but the door sensor hasn't been triggered just before. The use-case is somebody's left a package at the door, but not when opening the door to fetch it.

I thought of having a state node change the message payload to an empty string, but that seems like a hack. What's the right way?

Hi @sblessley,

Here is one way, not sure it's the best way, using node-red-contrib-simple-gate to block or pass messages. You can install the node via the hamburger menu Manage Palette option.

[{"id":"ef953fdf48b0e4ef","type":"group","z":"6067dcc19d4df957","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["0882ed954c72e44f","ef17d4824ad7e50a","c9e1dc67254f1578","0b51da2be9330f6a","5ad883d03ca32e20","42bb894e40fd83c9"],"x":34,"y":39,"w":972,"h":122},{"id":"0882ed954c72e44f","type":"inject","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"Door sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":80,"wires":[["c9e1dc67254f1578"]]},{"id":"ef17d4824ad7e50a","type":"inject","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"PIR sensor","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":120,"wires":[["0b51da2be9330f6a"]]},{"id":"c9e1dc67254f1578","type":"trigger","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"","op1":"close","op2":"open","op1type":"str","op2type":"str","duration":"2","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":330,"y":80,"wires":[["42bb894e40fd83c9"]]},{"id":"0b51da2be9330f6a","type":"gate","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","persist":false,"storeName":"memory","x":690,"y":120,"wires":[["5ad883d03ca32e20"]]},{"id":"5ad883d03ca32e20","type":"debug","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":120,"wires":[]},{"id":"42bb894e40fd83c9","type":"change","z":"6067dcc19d4df957","g":"ef953fdf48b0e4ef","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":80,"wires":[["0b51da2be9330f6a"]]}]
1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.