Multiple motion sensors. Checking each other before moving forward

Is there an easier way to do what I have depicted below. Pretty much I have 3 motion sensors in master bathroom.

If anyone one of them detect motion, a helper is turned on.
If anyone one of them detect no motion, it checks the other two.
Only if all 3 are off at the same time will the helper turn off.

This works but wondering if theres an easier way to “code” it?

[{"id":"c9e174023076821a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"acb0521ccf6bc110","type":"server-state-changed","z":"c9e174023076821a","name":"Motion sensed floor","server":"ab3e2c53.e3491","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_master_bathroom2","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"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":210,"y":350,"wires":[["b23f42f70e640136"],["84a1f5df837747fe"]]},{"id":"425813e91943f629","type":"server-state-changed","z":"c9e174023076821a","name":"Motion sensed above door","server":"ab3e2c53.e3491","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_master_bathroom_4in1","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"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":229,"y":296,"wires":[["b23f42f70e640136"],["768034564c15bc4b"]]},{"id":"5e77170dafcf9082","type":"server-state-changed","z":"c9e174023076821a","name":"Motion sensed closet","server":"ab3e2c53.e3491","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.motion_master_bathroom_closet","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"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":210,"y":410,"wires":[["b23f42f70e640136"],["9d5d0c3c41b465ec"]]},{"id":"b23f42f70e640136","type":"api-call-service","z":"c9e174023076821a","name":"ON: motion sensed helper","server":"ab3e2c53.e3491","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.master_bathroom_motion_sensed","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":560,"y":230,"wires":[[]]},{"id":"0c5aae614849e225","type":"api-call-service","z":"c9e174023076821a","name":"OFF: motion sensed helper","server":"ab3e2c53.e3491","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_on","entityId":"input_boolean.master_bathroom_motion_sensed","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":350,"wires":[[]]},{"id":"768034564c15bc4b","type":"api-current-state","z":"c9e174023076821a","name":"No motion on floor?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom2","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":530,"y":290,"wires":[["a2475c607f2b5740"],[]]},{"id":"a2475c607f2b5740","type":"api-current-state","z":"c9e174023076821a","name":"No motion in closet?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom_closet","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":840,"y":290,"wires":[["0c5aae614849e225"],[]]},{"id":"84a1f5df837747fe","type":"api-current-state","z":"c9e174023076821a","name":"No motion above door?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom_4in1","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":350,"wires":[["2f5ff4d2db4d8622"],[]]},{"id":"9d5d0c3c41b465ec","type":"api-current-state","z":"c9e174023076821a","name":"No motion on floor?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom2","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":530,"y":410,"wires":[["dba1e26a477c3a91"],[]]},{"id":"2f5ff4d2db4d8622","type":"api-current-state","z":"c9e174023076821a","name":"No motion in closet?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom_closet","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":840,"y":350,"wires":[["0c5aae614849e225"],[]]},{"id":"dba1e26a477c3a91","type":"api-current-state","z":"c9e174023076821a","name":"No motion above door?","server":"ab3e2c53.e3491","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.motion_master_bathroom_4in1","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":840,"y":410,"wires":[["0c5aae614849e225"],[]]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHome","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

I think you should look at group in HA and put your sensor in there, then you can use the group to test on.

Groups in HA can be set to be on if one or more entities in the group is on or else they are off, or the opposite.

1 Like

If you choose to do it in Node-Red, then make a chain instead.

I can’t show it ATM, but I can describe it.

Reuse you check nodes, but check first if there is movement above door, then set false to send to check if there is movement on floor and again set false to sent to check if there is movement on closet and lastly send false alarm of turn off.
Pipe all you first nodes into the same first node.

One of the nodes will be checked twice then but it is easier to maintain

Think I got what your saying. Heres what I did.

Exactly what I meant :blush:

image

[{"id":"80672a30cad44e59","type":"api-call-service","z":"91a80f99.6180e","name":"","server":"","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.helper","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":648,"y":3856,"wires":[[]]},{"id":"cae3fc45b316c48f","type":"server-state-changed","z":"91a80f99.6180e","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.a, sensor.b, sensor.c","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"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":"{\"service\": \"turn_on\"}","valueType":"jsonata"}],"x":314,"y":3856,"wires":[["80672a30cad44e59"],[]]},{"id":"540af2a177e9b259","type":"trigger-state","z":"91a80f99.6180e","name":"","server":"","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.a, sensor.b, sensor.c","entityidfiltertype":"substring","debugenabled":false,"constraints":[{"targetType":"entity_id","targetValue":"sensor.a","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"},{"targetType":"entity_id","targetValue":"sensor.b","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"},{"targetType":"entity_id","targetValue":"sensor.c","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"off","propertyValue":"new_state.state"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":304,"y":3904,"wires":[["80672a30cad44e59"],[]]}]

Leave it to Kermit to condense into 3 nodes. I like that. May be my first trigger state node!