Loop to disable Zwave motion lights

Struggling with something that should probably be very easy. I have a few zwave enabled motion lights. They can be turned on/off via HA and also come on when motion is detected. I have a Node Red flow that will trigger all other outdoor lights if one turns on. I want a way to disable the motion lights as they turn on and prevent them from triggering the other lights. I have an input boolean called Motion Disabled. Ideally, when it is turned on, if any motion light turns on, it will be immediately turned back off and no other lights will be triggered. I put the boolean into the flow and it just goes into a constant loop of turning lights on and off. Any ideas would be appreciated. This should turn the lights back off if they are triggered, as long as the input boolean is on.


This should turn all other outdoor lights on for 5 minutes if it turns on, as long as the input boolean is off

I can help you with a better flow for this, but I have some questions:

  1. The lights should all trigger should 1 light be turned on manually and also by motion?
  2. Should manually turning on a single light (like your garage light) also turn on all other lights?

The first thing I would suggest is to create a group (or scene) for the lights that all turn on during motion. This way, you don’t have to worry about a single light controlling other lights. You can also use this same group for manual turning on/off lights.

Yes, if one light is turned on manually or by motion, all other outside lights should be triggered to turn on for 5 minutes then shut off, unless they were already on. If a light was already on when the motion light came on, it should NOT turn off after 5 minutes but should remain on indefinitely. I am still working on that as sometimes they turn back off and sometimes they don’t. If I individually turn the lights on, they will stay on until I turn them off which is correct. However, if I ask Alexa to turn on the ‘Outside’ group, my wifi switched lights will turn off after 5 minutes (not desired) while the zwave will stay on until I turn them off (desired). I can’t figure that out yet but I am not that concerned about it right now. I feel a group or scene will not work for the flow as each light also needs to be independent of others but correct me if I am wrong.

Here are the full flows. Tried to tweak for clarity.


They still would be. A group or scene in HA doesn’t take away control from the individual lights, it just gives you another entity that will trigger all the devices in that group or scene.

Give me a few. I’m working on a flow that I think will address all your use-cases.

Ok, this will handle your first use case of motion activation of all the lights:

You’ll need to set the ‘Motion Sensors’ events-state node to be exposed to HA:

This will allow you to replace the input_boolean with a switch that you can toggle within HA itself.

[{"id":"fbe437a4.494cd","type":"server-state-changed","z":"6ecc9570.0a4fbc","name":"Motion Sensors","server":"df8e6220.fa7b2","version":1,"exposeToHomeAssistant":true,"haConfig":[{"property":"name","value":"Outdoor Motion Sensors Switch"},{"property":"icon","value":"mdi:switch"}],"entityidfilter":"","entityidfiltertype":"exact","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,"x":140,"y":240,"wires":[["33f63822.948bc","9c61bb71.c8019"],["9c61bb71.c8019"]]},{"id":"33f63822.948bc","type":"api-call-service","z":"6ecc9570.0a4fbc","name":"Turn on outdoor lights","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":360,"y":200,"wires":[["d3d19073.94995"]]},{"id":"9c61bb71.c8019","type":"trigger","z":"6ecc9570.0a4fbc","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"units":"min","reset":"on","bytopic":"all","topic":"topic","outputs":1,"x":330,"y":280,"wires":[["d23f571f.3b4a3"]]},{"id":"d23f571f.3b4a3","type":"api-call-service","z":"6ecc9570.0a4fbc","name":"Turn off outdoor lights","server":"df8e6220.fa7b2","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":600,"y":280,"wires":[["b244c66d.2ef298"]]},{"id":"154de8fe.2ca82f","type":"comment","z":"6ecc9570.0a4fbc","name":"This handles all the motion sensors and lights as groups.\\n It also toggles a flow var to denote they came on by motion. \\n You can repeat this same pattern for your individual motion sensors.","info":"","x":300,"y":60,"wires":[]},{"id":"d3d19073.94995","type":"change","z":"6ecc9570.0a4fbc","name":"Set on by motion","rules":[{"t":"set","p":"outside_lights_on_by_motion","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":200,"wires":[[]]},{"id":"b244c66d.2ef298","type":"change","z":"6ecc9570.0a4fbc","name":"Set off by motion","rules":[{"t":"set","p":"outside_lights_on_by_motion","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":280,"wires":[[]]},{"id":"7c01d571.e37da4","type":"comment","z":"6ecc9570.0a4fbc","name":"To make this work, you'll need to add a group for your outdoor lights \\n and a group of your outdoor motion sensors (in groups.yaml).","info":"","x":300,"y":140,"wires":[]},{"id":"df8e6220.fa7b2","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":false,"rejectUnauthorizedCerts":false,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I’m still working on the rest of the use-cases.

Groups created in groups.yaml. This is my first time, does this look good:

group:
    outdoor:
        name: Outdoor
        entities:
            -switch.street_light
            -switch.hall_light
            -switch.garage_soffit_lights
            -switch.bleecker_shed_switch
            -switch.east_garage_motion
            -switch.shed_motion_switch
  
    motion_lights:
        name: Motion Lights
        entities:
            -switch.bleecker_shed_switch
            -switch.east_garage_motion
            -switch.shed_motion_switch
1 Like

I got it working. No groups needed. Json:

[{"id":"4acabf7c.baa05","type":"tab","label":"All outside lights on with any motion detected","disabled":false,"info":""},{"id":"5b1093e0.6b1c4c","type":"api-call-service","z":"4acabf7c.baa05","name":"Shed Motion On","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.shed_motion_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":60,"wires":[["46a481e3.c9f74"]]},{"id":"46a481e3.c9f74","type":"delay","z":"4acabf7c.baa05","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1060,"y":60,"wires":[["e6cd8f4a.4a4af"]]},{"id":"e6cd8f4a.4a4af","type":"api-call-service","z":"4acabf7c.baa05","name":"Shed Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.shed_motion_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":60,"wires":[[]]},{"id":"7067fa27.cf53c4","type":"api-call-service","z":"4acabf7c.baa05","name":"Blk Shed Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.bleecker_shed_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":160,"wires":[[]]},{"id":"74b66d0f.7dad94","type":"api-current-state","z":"4acabf7c.baa05","name":"BLK Shed Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.bleecker_shed_switch","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":660,"y":160,"wires":[["f048870b.6911a8"],[]]},{"id":"df8b1e2b.7ff7d","type":"delay","z":"4acabf7c.baa05","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1080,"y":160,"wires":[["7067fa27.cf53c4"]]},{"id":"3a00c4f9.87262c","type":"api-current-state","z":"4acabf7c.baa05","name":"East Garage Motion Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.east_garage_motion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":690,"y":320,"wires":[["7ab1f72f.3484b8"],[]]},{"id":"1af2edcd.5f78e2","type":"api-current-state","z":"4acabf7c.baa05","name":"Shed Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.shed_motion_switch","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":740,"y":60,"wires":[["5b1093e0.6b1c4c"],[]]},{"id":"7ab1f72f.3484b8","type":"api-call-service","z":"4acabf7c.baa05","name":"East Garage Motion On?","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.east_garage_motion","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":930,"y":320,"wires":[["25e32695.1cdbea"]]},{"id":"25e32695.1cdbea","type":"delay","z":"4acabf7c.baa05","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1120,"y":320,"wires":[["f4b98a1.2381d78"]]},{"id":"f4b98a1.2381d78","type":"api-call-service","z":"4acabf7c.baa05","name":"East Garage Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.east_garage_motion","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1330,"y":320,"wires":[[]]},{"id":"f048870b.6911a8","type":"api-call-service","z":"4acabf7c.baa05","name":"Blk Shed Motion On","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.bleecker_shed_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":900,"y":160,"wires":[["df8b1e2b.7ff7d"]]},{"id":"32a1fa9e.069c16","type":"delay","z":"4acabf7c.baa05","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1160,"y":240,"wires":[["ccda78bb.bdd008"]]},{"id":"ccda78bb.bdd008","type":"api-call-service","z":"4acabf7c.baa05","name":"Street Light Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.street_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1340,"y":240,"wires":[[]]},{"id":"9f90837.6956c8","type":"api-call-service","z":"4acabf7c.baa05","name":"Street Light On","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.street_light","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":240,"wires":[["32a1fa9e.069c16"]]},{"id":"ddb2c631.45f588","type":"api-current-state","z":"4acabf7c.baa05","name":"Street Light Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.street_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":720,"y":240,"wires":[["9f90837.6956c8"],[]]},{"id":"a64496a8.1d7258","type":"trigger-state","z":"4acabf7c.baa05","name":"East garage motion turns on","server":"b69b345.2faeec8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.east_garage_motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":120,"y":280,"wires":[["f25c8dfc.fcdc8","96ba4433.5b9708","874dc9ca.8c48c8","2bce2647.8399da","aa9ab3f0.1d542"],[]]},{"id":"762a0527.7bc8ac","type":"trigger-state","z":"4acabf7c.baa05","name":"Shed motion turns on","server":"b69b345.2faeec8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.shed_motion_switch","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":100,"y":80,"wires":[["96ba4433.5b9708","f25c8dfc.fcdc8","56d47e65.0e374","31581497.3844cc","aa9ab3f0.1d542"],[]]},{"id":"3feb73df.cb256c","type":"trigger-state","z":"4acabf7c.baa05","name":"Bleeker Shed motion turns on","server":"b69b345.2faeec8","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"switch.bleecker_shed_switch","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on","propertyValue":"new_state.state"}],"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":130,"y":180,"wires":[["874dc9ca.8c48c8","f25c8dfc.fcdc8","56d47e65.0e374","217e74cb.2a2acc","aa9ab3f0.1d542"],[]]},{"id":"874dc9ca.8c48c8","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":490,"y":60,"wires":[["1af2edcd.5f78e2"],[]]},{"id":"96ba4433.5b9708","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":450,"y":160,"wires":[["74b66d0f.7dad94"],[]]},{"id":"f25c8dfc.fcdc8","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":510,"y":240,"wires":[["ddb2c631.45f588"],[]]},{"id":"56d47e65.0e374","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":450,"y":320,"wires":[["3a00c4f9.87262c"],[]]},{"id":"31581497.3844cc","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable On?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":450,"y":420,"wires":[["19f9e777.fc9fb9"],[]]},{"id":"217e74cb.2a2acc","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable On?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":450,"y":460,"wires":[["f2ebce90.0d45d"],[]]},{"id":"2bce2647.8399da","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable On?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":450,"y":500,"wires":[["adb74f22.9daed"],[]]},{"id":"adb74f22.9daed","type":"api-call-service","z":"4acabf7c.baa05","name":"East Garage Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.east_garage_motion","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":690,"y":500,"wires":[[]]},{"id":"f2ebce90.0d45d","type":"api-call-service","z":"4acabf7c.baa05","name":"Blk Shed Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.bleecker_shed_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":680,"y":460,"wires":[[]]},{"id":"19f9e777.fc9fb9","type":"api-call-service","z":"4acabf7c.baa05","name":"Shed Motion Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.shed_motion_switch","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":660,"y":420,"wires":[[]]},{"id":"dcc018db.de7ec8","type":"api-current-state","z":"4acabf7c.baa05","name":"Garage Soffit Lights Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"switch.garage_soffit_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":710,"y":380,"wires":[["b797a1bc.10583"],[]]},{"id":"b797a1bc.10583","type":"api-call-service","z":"4acabf7c.baa05","name":"Garage Soffit Lights On","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.garage_soffit_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":950,"y":380,"wires":[["857269dc.c65808"]]},{"id":"857269dc.c65808","type":"delay","z":"4acabf7c.baa05","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1140,"y":380,"wires":[["d80b03d6.059ac"]]},{"id":"d80b03d6.059ac","type":"api-call-service","z":"4acabf7c.baa05","name":"Garage Soffit Lights Off","server":"b69b345.2faeec8","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.garage_soffit_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1350,"y":380,"wires":[[]]},{"id":"aa9ab3f0.1d542","type":"api-current-state","z":"4acabf7c.baa05","name":"Motion Disable Off?","server":"b69b345.2faeec8","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_boolean.motion_light_disable","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":470,"y":380,"wires":[["dcc018db.de7ec8"],[]]},{"id":"b69b345.2faeec8","type":"server","name":"Home Assistant","addon":true}]