This flow may look a bit complicated but mimics how the Philips Hue Hub deals with motion.
-
Based on the time and light level it will turn the lights on when motion is detected.
-
It then checks if there is motion for 30 seconds, every second before dimming lights
-
It then checks for motion for the next 30 seconds, every second before turning off the lights
-
If at any point motion is detected it turns the lights back to its preset brightness and starts motion detection from the beginning again.
With some exceptions:
-
After 23.00 the lights are set to dim so it doesn’t dim them after 30 seconds but checks for motion for every second for 60 seconds before turning them off.
-
If the alarm is not disarmed then this flow is not triggered - I have different settings for this when alarm is armed and triggered
I’m using Hue Motion sensors so they re-trigger quickly. Other motion sensors may not but this works well with the setup I have.
You may need to change your entities names in the nodes in this flow and also add your longitude/latitude to the time interval nodes.
[{"id":"424d9ac3.5584d4","type":"time-range-switch","z":"fe3260af.8794a","name":"","lat":"","lon":"","startTime":"23:00","endTime":"sunrise","startOffset":0,"endOffset":"-60","x":1080,"y":260,"wires":[["203ed480.2c666c"],["3af12b2.4c782d4"]]},{"id":"6e259947.91879","type":"server-state-changed","z":"fe3260af.8794a","name":"Hallway Motion Detected","server":"60e1db70.15c0ec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.hallway_motion_sensor","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,"x":250,"y":260,"wires":[["5651771c.45784"],[]]},{"id":"cddd65bf.d0199","type":"api-current-state","z":"fe3260af.8794a","name":"Halway Lux","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"24","halt_if_type":"num","halt_if_compare":"lt","override_topic":false,"entity_id":"sensor.hallway_motion_sensor_light_level","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":870,"y":260,"wires":[["424d9ac3.5584d4"],[]]},{"id":"3af12b2.4c782d4","type":"api-call-service","z":"fe3260af.8794a","name":"turn on hallway lights","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"scene","service":"turn_on","entityId":"scene.hallway_tropical_twilight","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1340,"y":260,"wires":[[]]},{"id":"5651771c.45784","type":"api-current-state","z":"fe3260af.8794a","name":"Check Disarmed Status","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"disarmed","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"alarm_control_panel.house","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":510,"y":260,"wires":[["6a0466ff.f2e66"],[]]},{"id":"6a0466ff.f2e66","type":"delay","z":"fe3260af.8794a","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":710,"y":260,"wires":[["cddd65bf.d0199"]]},{"id":"ad328435.e0ca8","type":"api-call-service","z":"fe3260af.8794a","name":"Dim hallway lights","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hallway_lights","data":"{\"brightness_pct\":\"10\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1550,"y":420,"wires":[["94e778ef.c10898"]]},{"id":"c0efba0d.362bf","type":"api-call-service","z":"fe3260af.8794a","name":"turn off hallway lights","server":"60e1db70.15c0ec","version":1,"service_domain":"light","service":"turn_off","entityId":"group.hallway_lights_group","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":2280,"y":420,"wires":[[]]},{"id":"f04ce98a.5442e","type":"api-current-state","z":"fe3260af.8794a","name":"Check Disarmed Status","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"disarmed","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"alarm_control_panel.house","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":510,"y":420,"wires":[["9192cf29.2589d"],[]]},{"id":"461f2314.0ff6dc","type":"time-range-switch","z":"fe3260af.8794a","name":"","lat":"","lon":"","startTime":"23:00","endTime":"sunrise","startOffset":0,"endOffset":"-60","x":800,"y":420,"wires":[["f291b906.96697"],["22f9ad9f.f0caa2"]]},{"id":"fbea3a58.cd7648","type":"server-state-changed","z":"fe3260af.8794a","name":"Hallway Motion Detected","server":"60e1db70.15c0ec","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.hallway_motion_sensor","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":270,"y":420,"wires":[["f04ce98a.5442e"],[]]},{"id":"22f9ad9f.f0caa2","type":"api-current-state","z":"fe3260af.8794a","name":"Check Motion","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.hallway_motion_sensor","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1040,"y":420,"wires":[[],["ce8a0f2a.6c3d1"]]},{"id":"94e778ef.c10898","type":"api-current-state","z":"fe3260af.8794a","name":"Check Motion","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.hallway_motion_sensor","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1780,"y":420,"wires":[["424d9ac3.5584d4"],["d5f89f14.c0efa8"]]},{"id":"a18ee953.7ebe4","type":"delay","z":"fe3260af.8794a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2019,"y":500,"wires":[["94e778ef.c10898"]]},{"id":"d5f89f14.c0efa8","type":"counter-loop","z":"fe3260af.8794a","name":"","counter":"ile86d4036d62498","counterType":"msg","reset":true,"resetValue":"value-null","initial":0,"initialType":"num","operator":"lt","termination":"31","terminationType":"num","increment":1,"incrementType":"num","x":2020,"y":420,"wires":[["c0efba0d.362bf"],["a18ee953.7ebe4"]]},{"id":"ce8a0f2a.6c3d1","type":"counter-loop","z":"fe3260af.8794a","name":"","counter":"ile86d4036d62498","counterType":"msg","reset":true,"resetValue":"value-null","initial":0,"initialType":"num","operator":"lt","termination":"31","terminationType":"num","increment":1,"incrementType":"num","x":1280,"y":420,"wires":[["ad328435.e0ca8"],["8656a797.318f1"]]},{"id":"8656a797.318f1","type":"delay","z":"fe3260af.8794a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1180,"y":500,"wires":[["22f9ad9f.f0caa2"]]},{"id":"203ed480.2c666c","type":"api-call-service","z":"fe3260af.8794a","name":"turn on hallway lights dim","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hallway_lights","data":"{\"brightness_pct\":\"30\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1350,"y":220,"wires":[[]]},{"id":"505295af.695e04","type":"api-call-service","z":"fe3260af.8794a","name":"turn off hallway lights","server":"60e1db70.15c0ec","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.hallway_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1260,"y":700,"wires":[[]]},{"id":"f291b906.96697","type":"api-current-state","z":"fe3260af.8794a","name":"Check Motion","server":"60e1db70.15c0ec","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.hallway_motion_sensor","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":900,"y":640,"wires":[[],["42bf161a.09baa"]]},{"id":"a7f6a3db.667ef","type":"delay","z":"fe3260af.8794a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1080,"y":680,"wires":[["f291b906.96697"]]},{"id":"42bf161a.09baa","type":"counter-loop","z":"fe3260af.8794a","name":"","counter":"ile86d4036d62498","counterType":"msg","reset":true,"resetValue":"value-null","initial":0,"initialType":"num","operator":"lt","termination":"61","terminationType":"num","increment":1,"incrementType":"num","x":880,"y":700,"wires":[["505295af.695e04"],["a7f6a3db.667ef"]]},{"id":"ab7ee7cf.53231","type":"comment","z":"fe3260af.8794a","name":"................... Hallway Lights Motion Presence .................. ................... 2 Preset Light Levels - Hue Motion Presence..................","info":"","x":680,"y":160,"wires":[]},{"id":"56ee0f9b.e5f5d8","type":"api-current-state","z":"fe3260af.8794a","name":"Hallway Lights","server":"57ce5691.fd6e48","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.hallway_lights_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":640,"y":540,"wires":[["461f2314.0ff6dc"],[]]},{"id":"9192cf29.2589d","type":"delay","z":"fe3260af.8794a","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":620,"y":480,"wires":[["56ee0f9b.e5f5d8"]]},{"id":"87ddd38f.c0fd7","type":"comment","z":"fe3260af.8794a","name":"Lights already dim so check if motion is in next 60 seconds else turn lights off ","info":"","x":1090,"y":600,"wires":[]},{"id":"92d9c7cb.343b78","type":"comment","z":"fe3260af.8794a","name":"Turn on Lights Flow ---->","info":"","x":270,"y":220,"wires":[]},{"id":"98d5d4c2.e068c8","type":"comment","z":"fe3260af.8794a","name":"Check for motion before turning off lights ---->","info":"","x":350,"y":360,"wires":[]},{"id":"60e1db70.15c0ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true},{"id":"57ce5691.fd6e48","type":"server","name":"Home Assistant","addon":true}]