I've been getting requests to show off my smart lighting setup using Home Assistant & Node-RED so here it is. I have quite a lot of inputs and sensors that control various lights throughout the inside and outside of my house. Here is a breakdown of this entire setup.

The Flow

Click here for link to image
[{"id":"9736af23.353b8","type":"api-call-service","z":"ff717302.0c688","name":"Living Room Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.living_room\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":2340,"y":300,"wires":[[]]},{"id":"46ae688.c860798","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":320,"wires":[["d12e5042.48a1b","ec64d873.d75708","b5c23ccf.2a411"],["d12e5042.48a1b"]]},{"id":"86ec2855.d52778","type":"api-call-service","z":"ff717302.0c688","name":"Living Room Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.living_room\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":3030,"y":367,"wires":[[]]},{"id":"93f798c4.f950d8","type":"server-state-changed","z":"ff717302.0c688","name":"Motion Living Room","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.motion_living_room","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":230,"y":340,"wires":[["46ae688.c860798"]]},{"id":"d12e5042.48a1b","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"8","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":367,"wires":[["95f1b7b0.8a2ac8"]]},{"id":"15134d48.3611e3","type":"api-current-state","z":"ff717302.0c688","name":"Is Living Room Light Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.living_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1250,"y":320,"wires":[["8bd8d83d.d88588"],[]]},{"id":"8bd8d83d.d88588","type":"api-current-state","z":"ff717302.0c688","name":"GET Living Room Lux Below 6","server":"233a9c63.e2baf4","outputs":2,"halt_if":"6","halt_if_type":"num","halt_if_compare":"gt","override_topic":true,"entity_id":"sensor.living_room_brightness","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1510,"y":320,"wires":[["f79821b.856bbe"],[]]},{"id":"ec64d873.d75708","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Living Room Light","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.auto_living_room_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":990,"y":320,"wires":[["15134d48.3611e3"],[]]},{"id":"95f1b7b0.8a2ac8","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Living Room Light","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.auto_living_room_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1150,"y":367,"wires":[["250836d7.217ada"],[]]},{"id":"711cc4a6.80f57c","type":"server-state-changed","z":"ff717302.0c688","name":"Motion Laundry Room","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.motion_laundry_room","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":220,"y":220,"wires":[["39f96b52.dc8f14"]]},{"id":"39f96b52.dc8f14","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":200,"wires":[["1952f32a.d31e8d","9c913799.783be8"],["9c913799.783be8"]]},{"id":"1952f32a.d31e8d","type":"api-call-service","z":"ff717302.0c688","name":"Laundry Room Light On","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.laundry_room_light\" }","mergecontext":"","x":970,"y":200,"wires":[[]]},{"id":"682bceb5.b291f","type":"api-call-service","z":"ff717302.0c688","name":"Laundry Room Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.laundry_room_light\" }","mergecontext":"","x":2590,"y":220,"wires":[[]]},{"id":"9c913799.783be8","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"60","extend":false,"units":"s","reset":"on","bytopic":"all","name":"","x":930,"y":248,"wires":[["fde83b7f.0ec118"]]},{"id":"492ad523.f6b51c","type":"server-state-changed","z":"ff717302.0c688","name":"Motion Hallway","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.motion_hallway","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":240,"y":520,"wires":[["411ca996.cc03a8"]]},{"id":"3e47cac7.60a966","type":"api-call-service","z":"ff717302.0c688","name":"Hallway Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.hallway\" }","mergecontext":"newMsg","x":2198,"y":575,"wires":[[]]},{"id":"411ca996.cc03a8","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":560,"wires":[["b40ad878.45a188","10f6bd4f.d51e93"],["10f6bd4f.d51e93"]]},{"id":"fe6b49f1.f306e8","type":"api-call-service","z":"ff717302.0c688","name":"Hallway Light Off","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.hallway\" }","mergecontext":"","x":2050,"y":609,"wires":[[]]},{"id":"10f6bd4f.d51e93","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"2","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":609,"wires":[["6674bb72.33e744"]]},{"id":"7d4428e0.074b88","type":"api-current-state","z":"ff717302.0c688","name":"Is Hallway Light Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.hallway","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1210,"y":560,"wires":[["feca2c1.ae234d"],[]]},{"id":"feca2c1.ae234d","type":"api-current-state","z":"ff717302.0c688","name":"GET Hallway Lux Below 8","server":"233a9c63.e2baf4","outputs":2,"halt_if":"8","halt_if_type":"num","halt_if_compare":"gt","override_topic":true,"entity_id":"sensor.hallway_brightness","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1430,"y":560,"wires":[["a1a1d391.47e07"],[]]},{"id":"b40ad878.45a188","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Hallway Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_hallway_light","x":980,"y":560,"wires":[["7d4428e0.074b88"]]},{"id":"6674bb72.33e744","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Hallway Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_hallway_light","x":1140,"y":609,"wires":[["4d771ff6.90071"]]},{"id":"38d42665.06fffa","type":"server-state-changed","z":"ff717302.0c688","name":"Front Door","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.front_door","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":260,"y":460,"wires":[["411ca996.cc03a8","46ae688.c860798","2b90d9d2.555a56","7d963dc9.f51ab4"]]},{"id":"12d4202c.26baf","type":"server-state-changed","z":"ff717302.0c688","name":"Front Doorstep Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.front_doorstep_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":220,"y":569,"wires":[[]]},{"id":"513193e3.80783c","type":"server-state-changed","z":"ff717302.0c688","name":"Front Walkway Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.front_walkway","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":220,"y":620,"wires":[[]]},{"id":"653b567.56df3a8","type":"api-call-service","z":"ff717302.0c688","name":"Front Door Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.front_door\" }","mergecontext":"","x":2374,"y":700,"wires":[[]]},{"id":"2b90d9d2.555a56","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":700,"wires":[["6247b65f.25fd48","3d38cde5.1d5b92"],["3d38cde5.1d5b92"]]},{"id":"3d38cde5.1d5b92","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"5","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":749,"wires":[["117d12ba.13e4dd"]]},{"id":"9de602bc.227d5","type":"api-current-state","z":"ff717302.0c688","name":"Is Front Door Light Off","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","entity_id":"light.front_door","x":1930,"y":700,"wires":[["6d921a76.8e9784"]]},{"id":"6247b65f.25fd48","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Front Door Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_front_door_light","x":980,"y":700,"wires":[["d91f813a.a4ecf"]]},{"id":"117d12ba.13e4dd","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Front Door Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"input_boolean.auto_front_door_light","override_payload":true,"x":1140,"y":749,"wires":[["5b6fa1d2.822b8"]]},{"id":"f8a0c71c.7c2368","type":"api-call-service","z":"ff717302.0c688","name":"Front Door Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.front_door\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":2712,"y":749,"wires":[[]]},{"id":"a4a3101a.599","type":"api-call-service","z":"ff717302.0c688","name":"Garage Door Lights ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.garage_door_lights\", \"brightness\": \"255\" }","mergecontext":"","x":2490,"y":840,"wires":[[]]},{"id":"e899f8db.2444a8","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":840,"wires":[["ec43a742.0a4838","5a9f81d1.15ba5"],["5a9f81d1.15ba5"]]},{"id":"5a9f81d1.15ba5","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"5","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":887,"wires":[["92a6292b.09ac88"]]},{"id":"d870f928.006658","type":"api-current-state","z":"ff717302.0c688","name":"Is Garage Door Lights Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.garage_door_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2020,"y":840,"wires":[["87f3fb54.345308"],[]]},{"id":"ec43a742.0a4838","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Garage Door Lights","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_garage_door_light","x":1000,"y":840,"wires":[["d2b4a158.b9afd"]]},{"id":"88884ea8.e8f32","type":"api-call-service","z":"ff717302.0c688","name":"Garage Door Lights OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.garage_door_lights\" }","mergecontext":"","x":2164,"y":887,"wires":[[]]},{"id":"92a6292b.09ac88","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Garage Door Lights","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"input_boolean.auto_garage_door_light","override_payload":true,"x":1160,"y":887,"wires":[["e59f838f.58328"]]},{"id":"289a8cf5.c30bc4","type":"server-state-changed","z":"ff717302.0c688","name":"Driveway and Walkway camera motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.driveway_and_walkway_camera_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":170,"y":700,"wires":[[]]},{"id":"2d67cdaf.961782","type":"server-state-changed","z":"ff717302.0c688","name":"Back Door","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.back_door","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":260,"y":280,"wires":[["46ae688.c860798","7efd37b5.dfe3f8","7d963dc9.f51ab4"]]},{"id":"60b2ea20.b0b2e4","type":"server-state-changed","z":"ff717302.0c688","name":"Kitchen Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.kitchen_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":240,"y":820,"wires":[["36f9d286.35962e"]]},{"id":"d3ef7db4.6bcc","type":"api-call-service","z":"ff717302.0c688","name":"Kitchen Lights ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.kitchen\", \"brightness\": \"255\" }","mergecontext":"","x":1430,"y":960,"wires":[[]]},{"id":"36f9d286.35962e","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":960,"wires":[["8d89ec62.2b0ba","d16b08e9.f173b8"],["d16b08e9.f173b8"]]},{"id":"d16b08e9.f173b8","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"5","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":1007,"wires":[["72be9cd7.dc7f44"]]},{"id":"8d89ec62.2b0ba","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","entity_id":"light.kitchen","x":970,"y":960,"wires":[["6371c86f.ad6458"]]},{"id":"7db9be43.fcf85","type":"api-call-service","z":"ff717302.0c688","name":"Kitchen Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.kitchen\" }","mergecontext":"","x":2050,"y":1007,"wires":[[]]},{"id":"6371c86f.ad6458","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Kitchen Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_kitchen_light","x":1210,"y":960,"wires":[["d3ef7db4.6bcc"]]},{"id":"72be9cd7.dc7f44","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Kitchen Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_kitchen_light","x":1130,"y":1007,"wires":[["7625b798.82f578"]]},{"id":"fa01b5a4.c68998","type":"api-current-state","z":"ff717302.0c688","name":"Kitchen Motion Off","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","entity_id":"binary_sensor.kitchen_motion","x":1590,"y":1007,"wires":[["c1be253a.6fef78"]]},{"id":"a1a1d391.47e07","type":"api-current-state","z":"ff717302.0c688","name":"Sun Below Horizon","server":"233a9c63.e2baf4","outputs":2,"halt_if":"below_horizon","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sun.sun","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1650,"y":560,"wires":[["53b39479.1d748c"],["126ee3ef.77851c"]]},{"id":"126ee3ef.77851c","type":"function","z":"ff717302.0c688","name":"Brightness Payload Formatter (60%)","func":"var newMsg =  {\n    payload: {\"data\":{\"brightness\":\"60\"}}\n};\nreturn newMsg;","outputs":1,"noerr":0,"x":1918,"y":575,"wires":[["3e47cac7.60a966"]]},{"id":"6dd4387f.024cc8","type":"server-state-changed","z":"ff717302.0c688","name":"Laundry Room Garage Door","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.laundry_room_garage_door","entityidfiltertype":"substring","haltifstate":"","outputs":1,"x":200,"y":400,"wires":[["39f96b52.dc8f14","36f9d286.35962e","da1c090f.1d33c8","7d963dc9.f51ab4"]]},{"id":"c7c6d5a4.b45c28","type":"api-call-service","z":"ff717302.0c688","name":"Garage Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.garage\",\"brightness\":\"255\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1390,"y":440,"wires":[[]]},{"id":"da1c090f.1d33c8","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":440,"wires":[["7a9fa9c9.f72648","b12bdbcd.885e88"],["b12bdbcd.885e88"]]},{"id":"51198a81.6adce4","type":"api-call-service","z":"ff717302.0c688","name":"Garage Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.garage\" }","mergecontext":"","x":2110,"y":490,"wires":[[]]},{"id":"b12bdbcd.885e88","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"2","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":490,"wires":[["69e95c6b.f39254"]]},{"id":"8664f35d.30a4f","type":"api-current-state","z":"ff717302.0c688","name":"motion_living_room On","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.motion_living_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1650,"y":367,"wires":[["563cc17.27aca4"],[]]},{"id":"45853cb1.0eb4e4","type":"api-current-state","z":"ff717302.0c688","name":"front_door OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.front_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2120,"y":367,"wires":[["dc59bd7b.a1268"],[]]},{"id":"e0e9d3ca.a4be5","type":"api-current-state","z":"ff717302.0c688","name":"back_door OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.back_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2560,"y":367,"wires":[["1312249c.37c2fb"],[]]},{"id":"69e95c6b.f39254","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Garage Light","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.auto_garage_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1130,"y":490,"wires":[["87587acc.9bae68"],[]]},{"id":"7a9fa9c9.f72648","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Garage Light","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.auto_garage_light","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":970,"y":440,"wires":[["236e626.5db9a9e"],[]]},{"id":"da1091a0.e4af5","type":"api-current-state","z":"ff717302.0c688","name":"laundry_room_garage_door OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.laundry_room_garage_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1600,"y":490,"wires":[["5ac2e38d.04cb2c"],[]]},{"id":"53b39479.1d748c","type":"api-call-service","z":"ff717302.0c688","name":"Hallway Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.hallway\",\"brightness\":\"255\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":1858,"y":540,"wires":[[]]},{"id":"159e0aa2.5635e5","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.front_door","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":650,"y":740,"wires":[["3d38cde5.1d5b92"]]},{"id":"ad8c5dae.acd64","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.garage_door_lights","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":670,"y":880,"wires":[["5a9f81d1.15ba5"]]},{"id":"4e3cab05.7dfc14","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.hallway","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":640,"y":600,"wires":[["10f6bd4f.d51e93"]]},{"id":"c3973f31.3b34a","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.garage","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":640,"y":480,"wires":[["b12bdbcd.885e88"]]},{"id":"bb4f7528.921a68","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.living_room","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":650,"y":360,"wires":[["d12e5042.48a1b"]]},{"id":"7b0d341b.596f1c","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.laundry_room_light","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":670,"y":240,"wires":[["9c913799.783be8"]]},{"id":"86318dc1.f1e74","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.kitchen","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":640,"y":1000,"wires":[["d16b08e9.f173b8"]]},{"id":"18dcca8b.c0f365","type":"api-call-service","z":"ff717302.0c688","name":"Back Yard Light ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{ \"entity_id\": \"light.back_yard\", \"brightness\": \"255\" }","mergecontext":"","x":2710,"y":1100,"wires":[[]]},{"id":"7efd37b5.dfe3f8","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":1100,"wires":[["362af465.9edeec","38e9d516.c6994a"],["362af465.9edeec"]]},{"id":"362af465.9edeec","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"3","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":1148,"wires":[["1548acc4.0f9d83"]]},{"id":"35c090.99ad1f7","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","entity_id":"light.back_yard","x":1246,"y":1100,"wires":[["52dfd8d4.c44d18"]]},{"id":"bed9200c.072d6","type":"api-call-service","z":"ff717302.0c688","name":"Back Yard Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.back_yard\" }","mergecontext":"","x":2800,"y":1148,"wires":[[]]},{"id":"38e9d516.c6994a","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Back Yard Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_back_door_light","x":980,"y":1100,"wires":[["35c090.99ad1f7"]]},{"id":"1548acc4.0f9d83","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Back Yard Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_back_door_light","x":1140,"y":1148,"wires":[["90c680be.5c4c2"]]},{"id":"c073558e.676db8","type":"api-current-state","z":"ff717302.0c688","name":"Back Door Closed","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"binary_sensor.back_door","override_payload":true,"x":1630,"y":1148,"wires":[["a6939b86.c61fb8"]]},{"id":"5ad8895f.5931c8","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.back_yard","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":650,"y":1140,"wires":[["362af465.9edeec"]]},{"id":"fddf9bfe.47afb8","type":"function","z":"ff717302.0c688","name":"Check Flow Timestamp","func":"var timestamp = Math.round(Date.now()/1000);\nvar off_timestamp = flow.get('back_yard_light_off_timestamp')||0;\nvar time_diff = timestamp - off_timestamp;\nvar min_diff = 3; // wait at least 3 seconds since it turned off\n\nif(!off_timestamp) {\n    return msg;\n}\n\nif(time_diff <= min_diff) {\n    node.status({fill:\"red\",shape:\"dot\",text:\"Blocked \"+new Date().toLocaleString()+\" (\"+time_diff+\")\"});\n    return;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":2490,"y":1100,"wires":[["18dcca8b.c0f365"]]},{"id":"d80d92f5.f0beb","type":"function","z":"ff717302.0c688","name":"Set Flow Timestamp","func":"flow.set('back_yard_light_off_timestamp', Math.round(Date.now()/1000));\nreturn msg;","outputs":1,"noerr":0,"x":2580,"y":1148,"wires":[["bed9200c.072d6"]]},{"id":"16f032f4.3e403d","type":"server-state-changed","z":"ff717302.0c688","name":"Back Yard Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.back_yard_door_camera_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":240,"y":860,"wires":[["7efd37b5.dfe3f8"]]},{"id":"45f51c06.02d2e4","type":"server-state-changed","z":"ff717302.0c688","name":"Office Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.office_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":250,"y":900,"wires":[["f36e3550.fd1f08"]]},{"id":"9aa20ab1.f65d88","type":"api-call-service","z":"ff717302.0c688","name":"Office Lights ON","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.office\"}","mergecontext":"","output_location":"payload","output_location_type":"msg","x":2100,"y":1220,"wires":[[]]},{"id":"595901bc.17e4e","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"10","extend":false,"units":"min","reset":"on","bytopic":"all","name":"","x":930,"y":1272,"wires":[["4b00b6ff.dd10c8"]]},{"id":"e8d29648.ad8f28","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"input_boolean.auto_office_light","override_payload":true,"x":1030,"y":1220,"wires":[["32e1d84f.b27fb8"]]},{"id":"39337f54.c1f54","type":"api-call-service","z":"ff717302.0c688","name":"Office Light OFF","server":"233a9c63.e2baf4","service_domain":"light","service":"turn_off","data":"{ \"entity_id\": \"light.office\" }","mergecontext":"","x":2040,"y":1272,"wires":[[]]},{"id":"4b00b6ff.dd10c8","type":"api-current-state","z":"ff717302.0c688","name":"Switch: Auto Office Light","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","entity_id":"input_boolean.auto_office_light","x":1130,"y":1272,"wires":[["be0d4057.df761"]]},{"id":"f8b36f57.15648","type":"api-current-state","z":"ff717302.0c688","name":"Office Motion Off","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"binary_sensor.office_motion","override_payload":true,"x":1590,"y":1272,"wires":[["677f4528.c0f9ac"]]},{"id":"f36e3550.fd1f08","type":"switch","z":"ff717302.0c688","name":"switch on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":590,"y":1220,"wires":[["595901bc.17e4e","e8d29648.ad8f28"],["595901bc.17e4e"]]},{"id":"54ec552f.6d7e2c","type":"server-state-changed","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","entityidfilter":"light.office","entityidfiltertype":"substring","haltifstate":"off","outputs":1,"x":630,"y":1260,"wires":[["595901bc.17e4e"]]},{"id":"677f4528.c0f9ac","type":"function","z":"ff717302.0c688","name":"Last motion over 10 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 10*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1820,"y":1272,"wires":[["39337f54.c1f54"]]},{"id":"4244459.8bb99bc","type":"cron","z":"ff717302.0c688","name":"Every 2 Minutes","crontab":"0 */2 * * * *","x":600,"y":1460,"wires":[["32acdad5.531b56"]]},{"id":"a6939b86.c61fb8","type":"function","z":"ff717302.0c688","name":"Last motion over 3 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 3*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1860,"y":1148,"wires":[["2065f61b.4c2dda"]]},{"id":"c1be253a.6fef78","type":"function","z":"ff717302.0c688","name":"Last motion over 5 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 5*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1820,"y":1007,"wires":[["7db9be43.fcf85"]]},{"id":"90c680be.5c4c2","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"light.back_yard","override_payload":true,"x":1400,"y":1148,"wires":[["c073558e.676db8"]]},{"id":"2065f61b.4c2dda","type":"api-current-state","z":"ff717302.0c688","name":"No Back Yard Motion","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"binary_sensor.back_yard_door_camera_motion","override_payload":true,"x":2100,"y":1148,"wires":[["2ac26b20.445674"]]},{"id":"2ac26b20.445674","type":"function","z":"ff717302.0c688","name":"Last motion over 2 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 2*60;\n    \n    // node.warn(\"timeago: \" + timeAgo);\n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":2340,"y":1148,"wires":[["d80d92f5.f0beb"]]},{"id":"be0d4057.df761","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"light.office","override_payload":true,"x":1370,"y":1272,"wires":[["f8b36f57.15648"]]},{"id":"7625b798.82f578","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"light.kitchen","override_payload":true,"x":1370,"y":1007,"wires":[["fa01b5a4.c68998"]]},{"id":"4d771ff6.90071","type":"api-current-state","z":"ff717302.0c688","name":"Is Hallway Light On","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.hallway","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1370,"y":609,"wires":[["2a712ce1.fa1144"],[]]},{"id":"e59f838f.58328","type":"api-current-state","z":"ff717302.0c688","name":"Is Garage Door Lights On","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.garage_door_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1430,"y":887,"wires":[["9e3d8992.3ff8c8"],[]]},{"id":"5b6fa1d2.822b8","type":"api-current-state","z":"ff717302.0c688","name":"Front Door Light On","server":"233a9c63.e2baf4","outputs":1,"halt_if":"off","override_topic":true,"entity_id":"light.front_door","override_payload":true,"x":1372,"y":749,"wires":[["7935521e.2f875c"]]},{"id":"236e626.5db9a9e","type":"api-current-state","z":"ff717302.0c688","name":"Is Garage Light Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.garage","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1190,"y":440,"wires":[["c7c6d5a4.b45c28"],[]]},{"id":"87587acc.9bae68","type":"api-current-state","z":"ff717302.0c688","name":"Is Garage Light On","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.garage","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1350,"y":490,"wires":[["da1091a0.e4af5"],[]]},{"id":"9cd3d0cf.e7c5","type":"api-current-state","z":"ff717302.0c688","name":"binary_sensor.laundry_room_garage_door Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.laundry_room_garage_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2020,"y":220,"wires":[["6ccdcbea.b740a4"],[]]},{"id":"6ccdcbea.b740a4","type":"function","z":"ff717302.0c688","name":"Last motion over 1 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 1*60;\n    \n    if(timeAgo >= timeLimit) {\n        node.status({fill:\"green\",shape:\"dot\",text: timeAgo});\n        return msg;\n    }\n    \n    node.status({fill:\"red\",shape:\"ring\",text: timeAgo});\n}","outputs":1,"noerr":0,"x":2340,"y":220,"wires":[["682bceb5.b291f"]]},{"id":"5f232e54.400b5","type":"api-current-state","z":"ff717302.0c688","name":"binary_sensor.motion_laundry_room Off","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.motion_laundry_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1400,"y":248,"wires":[["4c0f001a.f1bce"],[]]},{"id":"4c0f001a.f1bce","type":"function","z":"ff717302.0c688","name":"Last motion over 1 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 1*60;\n    \n    node.warn(\"timeago: \" + timeAgo);\n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1700,"y":220,"wires":[["9cd3d0cf.e7c5"]]},{"id":"fde83b7f.0ec118","type":"api-current-state","z":"ff717302.0c688","name":"light.laundry_room ON","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.laundry_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1120,"y":248,"wires":[["5f232e54.400b5"],[]]},{"id":"32acdad5.531b56","type":"function","z":"ff717302.0c688","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":1460,"wires":[["4b00b6ff.dd10c8","1548acc4.0f9d83","72be9cd7.dc7f44","92a6292b.09ac88","fde83b7f.0ec118","117d12ba.13e4dd","95f1b7b0.8a2ac8","69e95c6b.f39254","6674bb72.33e744"]]},{"id":"5b66cd85.e53214","type":"function","z":"ff717302.0c688","name":"Last motion over 5 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 5*60;\n    \n    if(timeAgo >= timeLimit) {\n        node.status({fill:\"green\",shape:\"dot\",text: timeAgo});\n        return msg;\n    }\n    \n    node.status({fill:\"red\",shape:\"ring\",text: timeAgo});\n}","outputs":1,"noerr":0,"x":1919,"y":749,"wires":[["2a7e7266.1abb0e"]]},{"id":"7935521e.2f875c","type":"api-current-state","z":"ff717302.0c688","name":"binary_sensor.front_door_motion OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.front_door_motion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1635,"y":749,"wires":[["5b66cd85.e53214"],[]]},{"id":"44a5565.290eda8","type":"function","z":"ff717302.0c688","name":"Last motion over 5 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 5*60;\n    \n    if(timeAgo >= timeLimit) {\n        node.status({fill:\"green\",shape:\"dot\",text: timeAgo});\n        return msg;\n    }\n    \n    node.status({fill:\"red\",shape:\"ring\",text: timeAgo});\n}","outputs":1,"noerr":0,"x":2468,"y":749,"wires":[["f8a0c71c.7c2368"]]},{"id":"2a7e7266.1abb0e","type":"api-current-state","z":"ff717302.0c688","name":"binary_sensor.front_door OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.front_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2198,"y":749,"wires":[["44a5565.290eda8"],[]]},{"id":"563cc17.27aca4","type":"function","z":"ff717302.0c688","name":"Last motion over 8 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 8*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1900,"y":367,"wires":[["45853cb1.0eb4e4"]]},{"id":"dc59bd7b.a1268","type":"function","z":"ff717302.0c688","name":"Last motion over 8 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 8*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":2340,"y":367,"wires":[["e0e9d3ca.a4be5"]]},{"id":"1312249c.37c2fb","type":"function","z":"ff717302.0c688","name":"Last motion over 8 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 8*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":2780,"y":367,"wires":[["86ec2855.d52778"]]},{"id":"250836d7.217ada","type":"api-current-state","z":"ff717302.0c688","name":"light.living_room On","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"light.living_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1400,"y":367,"wires":[["8664f35d.30a4f"],[]]},{"id":"5ac2e38d.04cb2c","type":"function","z":"ff717302.0c688","name":"Last motion over 2 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 2*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1880,"y":490,"wires":[["51198a81.6adce4"]]},{"id":"2a712ce1.fa1144","type":"api-current-state","z":"ff717302.0c688","name":"motion_hallway OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.motion_hallway","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1580,"y":609,"wires":[["18cdf90e.14bd37"],[]]},{"id":"18cdf90e.14bd37","type":"function","z":"ff717302.0c688","name":"Last motion over 2 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 2*60;\n    \n    if(timeAgo >= timeLimit) {\n        return msg;\n    }\n}","outputs":1,"noerr":0,"x":1820,"y":609,"wires":[["fe6b49f1.f306e8"]]},{"id":"187c5282.42479d","type":"comment","z":"ff717302.0c688","name":"Light Automation Inputs","info":"","x":220,"y":180,"wires":[]},{"id":"2352709e.5d31b","type":"comment","z":"ff717302.0c688","name":"Light Automation Filtering and Action","info":"","x":660,"y":160,"wires":[]},{"id":"c48346fe.1eee28","type":"comment","z":"ff717302.0c688","name":"Continuous check if lights needs to be on","info":"","x":680,"y":1420,"wires":[]},{"id":"fca65365.4009f","type":"server-state-changed","z":"ff717302.0c688","name":"Driveway Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.driveway_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":240,"y":740,"wires":[["e899f8db.2444a8"]]},{"id":"32e1d84f.b27fb8","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"light.office","override_payload":true,"x":1350,"y":1220,"wires":[["21173df.7abd4c2"]]},{"id":"d2b4a158.b9afd","type":"api-current-state","z":"ff717302.0c688","name":"weather disables auto outdoor lights switch","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":true,"entity_id":"input_boolean.weather_disables_auto_outdoor_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1330,"y":840,"wires":[["1be87ec2.916f11"],["d870f928.006658"]]},{"id":"1be87ec2.916f11","type":"api-current-state","z":"ff717302.0c688","name":"sensor.dark_sky_summary","server":"233a9c63.e2baf4","outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"sensor.dark_sky_summary","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1640,"y":814,"wires":[["9db6a0c8.12b05"]]},{"id":"9db6a0c8.12b05","type":"switch","z":"ff717302.0c688","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Snow","vt":"str"},{"t":"cont","v":"Flurries","vt":"str"},{"t":"nempty"}],"checkall":"false","repair":false,"outputs":3,"x":1830,"y":814,"wires":[[],[],["d870f928.006658"]]},{"id":"596b9b39.b88af4","type":"api-current-state","z":"ff717302.0c688","name":"sensor.dark_sky_summary","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"sensor.dark_sky_summary","override_payload":true,"x":1562,"y":673,"wires":[["18ff948b.fecd9b"]]},{"id":"18ff948b.fecd9b","type":"switch","z":"ff717302.0c688","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Snow","vt":"str"},{"t":"cont","v":"Flurries","vt":"str"},{"t":"nempty"}],"checkall":"false","repair":false,"outputs":3,"x":1752,"y":673,"wires":[[],[],["9de602bc.227d5"]]},{"id":"d91f813a.a4ecf","type":"api-current-state","z":"ff717302.0c688","name":"weather disables auto outdoor lights","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.weather_disables_auto_outdoor_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1270,"y":700,"wires":[["596b9b39.b88af4"],["9de602bc.227d5"]]},{"id":"761255e1.1514ec","type":"api-current-state","z":"ff717302.0c688","name":"sensor.dark_sky","server":"233a9c63.e2baf4","outputs":1,"halt_if":"on","override_topic":true,"entity_id":"sensor.dark_sky_summary","override_payload":true,"x":1920,"y":1080,"wires":[["ad944acb.792018"]]},{"id":"ad944acb.792018","type":"switch","z":"ff717302.0c688","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Snow","vt":"str"},{"t":"cont","v":"Flurries","vt":"str"},{"t":"nempty"}],"checkall":"false","repair":false,"outputs":3,"x":2070,"y":1080,"wires":[[],[],["2231857a.45bb0a"]]},{"id":"52869ba9.649d74","type":"server-state-changed","z":"ff717302.0c688","name":"living room brightness","server":"233a9c63.e2baf4","entityidfilter":"sensor.living_room_brightness","entityidfiltertype":"substring","haltifstate":"","outputs":1,"x":220,"y":100,"wires":[["1973b9fb.684196"]]},{"id":"1973b9fb.684196","type":"switch","z":"ff717302.0c688","name":"Below 6","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"6","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":400,"y":100,"wires":[["42b4ef7c.8205b"]]},{"id":"3ce8d7a8.d7daa8","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.motion_living_room","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":800,"y":100,"wires":[["46ae688.c860798"],[]]},{"id":"38e550c4.61481","type":"comment","z":"ff717302.0c688","name":"turn on light if it gets dark and motion is active","info":"","x":490,"y":20,"wires":[]},{"id":"56f72c0.cf4b9d4","type":"server-state-changed","z":"ff717302.0c688","name":"hallway brightness","server":"233a9c63.e2baf4","entityidfilter":"sensor.hallway_brightness","entityidfiltertype":"substring","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":210,"y":60,"wires":[["2ae1e966.985306"]]},{"id":"2ae1e966.985306","type":"switch","z":"ff717302.0c688","name":"Below 6","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"8","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":400,"y":60,"wires":[["219343c1.fa4efc"]]},{"id":"b51fb335.6d5e9","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.motion_hallway","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":790,"y":60,"wires":[["411ca996.cc03a8"],[]]},{"id":"49c2e08d.19515","type":"function","z":"ff717302.0c688","name":"Brightness Payload Formatter (60%)","func":"var newMsg =  {\n    payload: {\"data\":{\"brightness\":\"60\"}}\n};\nreturn newMsg;","outputs":1,"noerr":0,"x":1690,"y":152,"wires":[[]]},{"id":"8f9831fb.0c6e8","type":"function","z":"ff717302.0c688","name":"format kelvin","func":"if(msg.payload == 'on') {\n    var newMsg =  {\n        payload: {\n            \"data\": {\n                \"kelvin\": flow.get('circadian_kelvin')\n            }\n        }\n    }\n    \n    return newMsg;\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":2150,"y":300,"wires":[["9736af23.353b8"]]},{"id":"f79821b.856bbe","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.circadian_lighting","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":1880,"y":300,"wires":[["8f9831fb.0c6e8"]]},{"id":"a3fcd005.0ecdc","type":"function","z":"ff717302.0c688","name":"format kelvin","func":"if(msg.payload == 'on') {\n    var newMsg =  {\n        payload: {\n            \"data\": {\n                \"kelvin\": flow.get('circadian_kelvin')\n            }\n        }\n    }\n    \n    return newMsg;\n}\n\nreturn msg;\n","outputs":1,"noerr":0,"x":1930,"y":1220,"wires":[["9aa20ab1.f65d88"]]},{"id":"21173df.7abd4c2","type":"api-current-state","z":"ff717302.0c688","name":"","server":"233a9c63.e2baf4","outputs":1,"halt_if":"","override_topic":true,"entity_id":"input_boolean.circadian_lighting","override_payload":true,"x":1660,"y":1220,"wires":[["a3fcd005.0ecdc"]]},{"id":"52dfd8d4.c44d18","type":"api-current-state","z":"ff717302.0c688","name":"weather disables auto outdoor lights switch","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is_not","override_topic":true,"entity_id":"input_boolean.weather_disables_auto_outdoor_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1561,"y":1100,"wires":[["761255e1.1514ec"],["2231857a.45bb0a"]]},{"id":"219343c1.fa4efc","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"2","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":540,"y":60,"wires":[["b51fb335.6d5e9"]]},{"id":"42b4ef7c.8205b","type":"trigger","z":"ff717302.0c688","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"2","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":540,"y":100,"wires":[["3ce8d7a8.d7daa8"]]},{"id":"996792bf.5ac82","type":"server-state-changed","z":"ff717302.0c688","name":"Driveway Camera Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.driveway_camera_motion","entityidfiltertype":"exact","haltifstate":"","outputs":1,"x":210,"y":780,"wires":[[]]},{"id":"9e3d8992.3ff8c8","type":"api-current-state","z":"ff717302.0c688","name":"Driveway Motion OFF","server":"233a9c63.e2baf4","outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"binary_sensor.driveway_motion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1669,"y":887,"wires":[["f321f2d6.a322c"],[]]},{"id":"f321f2d6.a322c","type":"function","z":"ff717302.0c688","name":"Last motion over 5 minutes","func":"if(typeof msg.data.last_changed !== 'undefined') {\n    var d = new Date(msg.data.last_changed);\n    var timeAgo = (new Date().getTime() - d.getTime())/1000;\n    var timeLimit = 5*60;\n    \n    if(timeAgo >= timeLimit) {\n        node.status({fill:\"green\",shape:\"dot\",text: timeAgo});\n        return msg;\n    }\n    \n    node.status({fill:\"red\",shape:\"ring\",text: timeAgo});\n}","outputs":1,"noerr":0,"x":1909,"y":887,"wires":[["88884ea8.e8f32"]]},{"id":"8d751cad.b4255","type":"server-state-changed","z":"ff717302.0c688","name":"Front Door Motion","server":"233a9c63.e2baf4","entityidfilter":"binary_sensor.front_door_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"x":230,"y":660,"wires":[["2b90d9d2.555a56"]]},{"id":"87f3fb54.345308","type":"api-current-state","z":"ff717302.0c688","name":"Driveway Lux <= 50","server":"233a9c63.e2baf4","outputs":2,"halt_if":"50","halt_if_type":"num","halt_if_compare":"lte","override_topic":true,"entity_id":"sensor.driveway_light_level","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2256,"y":840,"wires":[[],["a4a3101a.599"]]},{"id":"2231857a.45bb0a","type":"api-current-state","z":"ff717302.0c688","name":"Is Sun Below Horizon","server":"233a9c63.e2baf4","outputs":1,"halt_if":"above_horizon","entity_id":"sun.sun","x":2260,"y":1100,"wires":[["fddf9bfe.47afb8"]]},{"id":"6d921a76.8e9784","type":"api-current-state","z":"ff717302.0c688","name":"Driveway Lux <= 50","server":"233a9c63.e2baf4","outputs":2,"halt_if":"50","halt_if_type":"num","halt_if_compare":"lte","override_topic":true,"entity_id":"sensor.driveway_light_level","state_type":"num","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":2150,"y":700,"wires":[[],["653b567.56df3a8"]]},{"id":"7d963dc9.f51ab4","type":"link out","z":"ff717302.0c688","name":"","links":["db0a53d3.53409"],"x":535,"y":1380,"wires":[]},{"id":"ac34e37.e1cd82","type":"comment","z":"ff717302.0c688","name":"Send message if no one is home","info":"","x":650,"y":1340,"wires":[]},{"id":"c0aad1a6.ef711","type":"http request","z":"ff717302.0c688","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"http://192.168.1.58:2971/api/command","tls":"","proxy":"","authType":"","x":1490,"y":1420,"wires":[[]]},{"id":"d450642b.bc8ce8","type":"change","z":"ff717302.0c688","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"wake\":true,\"wakeTime\":600}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":1420,"wires":[["c0aad1a6.ef711"]]},{"id":"12b2be91.781e91","type":"comment","z":"ff717302.0c688","name":"Turn on mypanel tablet","info":"","x":1380,"y":1380,"wires":[]},{"id":"338d360e.d52a5a","type":"link in","z":"ff717302.0c688","name":"","links":["b5c23ccf.2a411"],"x":1195,"y":1420,"wires":[[]]},{"id":"b5c23ccf.2a411","type":"link out","z":"ff717302.0c688","name":"","links":["338d360e.d52a5a"],"x":875,"y":280,"wires":[]},{"id":"233a9c63.e2baf4","type":"server","z":"","name":"Home Assistant","legacy":true,"hassio":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true}]

I think the best way to explain how this flow works is to go over the basics and then dive into each room individually. This way you understand how the whole thing functions as well as what my unique cases are for some of my rooms.

Inputs

So every room that is automated is connected to some sort of input. This input is what triggers the evaluation if a light should be turned on (and later turned off). In my home I have inputs from DIY/Hue motion sensors, security camera motion, and door sensors. I love Node-RED because it makes wiring multiple things together very easy. Just look at the above flow and you can easily see what triggers what. You can also have one sensor trigger off multiple flows just like how all of my door sensors trigger multiple lights (this way if you update a sensor ID you only change it in one spot instead of every flow).

I also made some inputs that only fire if brightness changes and is below a specified amount. I do this because I had issues with motion being continually detected in my living room for long periods while the sun was going down so the motion event never fires to get the lights to turn on. Now if the light drops below a specified level and motion is detected the lights will turn on. This is only necessary for automatic lights that utilize some sort of lux sensor.

ON/OFF Switch

Once the input is fired it then gets filtered through the on/off switch. This switch basically just makes sure that only on and not off payloads trigger my lights to turn on. It uses both values to reset the trigger node's timer for turning the light off though.

Evaluate if light should be on

From here we go on to evaluating whether the light should be turned on or off. Each light has different things we check depending on how you want it setup. In the above image at the top you can see where my laundry room automation is. I always want the light to turn on so I don't do any sort of evaluating but this is where you would put logic for some sort of lux sensor or maybe detecting if a switch on the Home Assistant front-end is turned on (so if it is turned off it will disable the automatic light).

Evaluate if light should be off

We always do evaluating before turning the light off because we have a timer node that fires every couple minutes to the OFF side of the flow to see if lights need to be turned off. This way if a light gets turned on manually or the power goes out and all the lights turn on they will turn back off again automatically.

Room Breakdown

Here is a breakdown of how I have each room setup. Each room has their

Laundry Room

Just a motion sensor that always turns on the light when motion is detected. Turns light off after 60 seconds of no motion. This is a high traffic area due to it being the access point to the garage.

Living Room

My living room lighting automation is the most complicated of the bunch.. These are all the things I have setup so far:

  • Auto living room light switch in Home Assistant UI that can turn off the automatic lights (can also turn this switch off using one of my hacked Hue remotes and holding the on/off buttons).
  • Lights only turn on if brightness below 6 lux in the room.
  • If circadian lighting switch is on we set the kelvin of the bulb when turning it on to match the sky color (covered in my post Circadian lighting with Home Assistant and Node-RED).
  • If Chromecast is playing on my TV the lights will dim to a specified amount (this actually isn't displayed above but can be found in my post Dim lights when TVis playing).

These lights are triggered by my living room motion sensor or the back/front door sensors.

At one point I had the motion events turning on the screen to my living room tablet running Home Assistant (using MyPanel app). I actually like the display of the time on the screensaver of the tablet so I disabled this feature for now (it's unconnected in the picture above at the very bottom middle).

Garage

When I open the door between my garage and my laundry room I have the light inside my garage turn on. When this door opens it triggers both the light in the garage and laundry room.

I have plans to build a garage door sensor in the future that I can use to turn on the garage light as well as the outside garage door lights when the garage door opens or closes (hate walking out into the dark at night to turn on the lights using motion sensors).

Hallway

The light in my hallway only turns on when the lux sensor drops below a set amount. If the sun is down I want the bulb to use a lower brightness so it doesn't disturb my sleeping bearded dragon. I use the sun component to dim the light to 60% if the sun is down for this reason. This light turns on if my front door opens or from motion detected in the hallway.

Office

My office is another room I do circadian lighting in to have my lights match the perceived color of the sky. I have a lamp and a bulb in the ceiling fixture that are synced to turn on together when motion is detected.

I have plans to build some sort of Python tool that will notify Home Assistant if I am on my office computer so it can keep the light on. Currently if I hold still in my office for too long the lights will turn off. This is the only room I have had this problem in. I tend to hold still for long periods of time while programming or reading articles.

Kitchen

My kitchen has a pretty simple setup. I always turn on the lights in the kitchen on motion as long as the switch for Kitchen Automatic Lights is on in Home Assistant. Since my kitchen is an open design with the living room I have considered making these lights dim as well when the TV is playing (my dog sometimes walks in the kitchen while I am watching TV and it gets really bright).

I do not use any sort of color bulbs in the kitchen. I want the lighting in this area to stay consistent. This can be important for food quality consistency.

Garage Door Lights

I have two lights that are on each side of my garage door. These are using a Hue outdoor motion sensor to trigger on motion. These also use the lux level from the outdoor motion sensor to determine if it's dark enough for us to turn on the lights. I used to use the sun component but I prefer using the actual light level outside so it handles overcast conditions and it getting dark in my front yard before my back yard.

I have plans in the future to add some sort of sensor to my garage door. This way I can turn on these lights if it's dark outside and the garage door is opening or closing. I also live in a very hot area so the PIR motion sensor on these devices gets false alerts over a specific temperature. I am considering using the reported temperature from the device to determine if motion events can be reliable or not (ignore if over a specific temperature).

I also want to get cheap color bulbs to put outside so I can do holiday color lighting for specific dates.

Backyard Light

I have a light in my backyard that uses the backdoor sensor and camera motion events. It works pretty good but I will most likely be moving to Hue motion sensors for this area as well (false alerts from bugs flying around my camera gets old quick).

Conclusion

I hope you enjoyed this little dive into my home lighting automation. I know it can be nice to go over other setups for inspiration so I hope you got inspired. I also hope this gives you a general idea of what can be easily accomplished using my various posts on Node-RED & Home Assistant.

If you ended up getting inspired, have any feedback, or have a question feel free to leave a comment below. I love to hear back from my readers.