This one does the same but also turns on the lights when the door opens or if there’s motion on the cameras.
[{"id":"9e336fa7.0b4cd","type":"stoptimer","z":"d6723c1.ee3f9c","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"5 Min","x":290,"y":900,"wires":[["e7f0fb40.dae368"],[]]},{"id":"19f07f73.5d92e1","type":"api-current-state","z":"d6723c1.ee3f9c","name":"Light Off?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.pool_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":840,"wires":[["bb8e3d39.52134"],[]]},{"id":"bb8e3d39.52134","type":"api-call-service","z":"d6723c1.ee3f9c","name":"Turn On","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"group.pool_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":840,"wires":[["1d8249d8.9edf46"]]},{"id":"3541132f.48bfcc","type":"api-call-service","z":"d6723c1.ee3f9c","name":"Turn Off","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"group.pool_lights","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":780,"y":900,"wires":[["8524ac9c.8c9b8"]]},{"id":"e9a744ce.e6b418","type":"server-state-changed","z":"d6723c1.ee3f9c","name":"Back Door","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.back_door","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":80,"y":840,"wires":[["9c59d681.e38478","5d97a52e.c1987c"],["9623cb92.90c768","9e336fa7.0b4cd"]]},{"id":"9c59d681.e38478","type":"time-range-switch","z":"d6723c1.ee3f9c","name":"Sunset","lat":"46.222715","lon":"-64.500891","startTime":"sunset","endTime":"sunrise","startOffset":"-20","endOffset":"+20","x":300,"y":840,"wires":[["19f07f73.5d92e1","9e336fa7.0b4cd"],[]]},{"id":"3a1c28fe.2acfd8","type":"server-state-changed","z":"d6723c1.ee3f9c","name":"Back Door Lock","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"lock.back_door_lock","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"unlocked","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":100,"y":760,"wires":[["9623cb92.90c768"],["5d97a52e.c1987c"]]},{"id":"5d97a52e.c1987c","type":"change","z":"d6723c1.ee3f9c","name":"STOP","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":780,"wires":[["9623cb92.90c768"]]},{"id":"9623cb92.90c768","type":"stoptimer","z":"d6723c1.ee3f9c","duration":"2","units":"Hour","payloadtype":"num","payloadval":"0","name":"2 Hrs","x":450,"y":760,"wires":[["a90eed2a.a1a7"],[]]},{"id":"a90eed2a.a1a7","type":"api-call-service","z":"d6723c1.ee3f9c","name":"Lock Door","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"lock","service":"lock","entityId":"lock.back_door_lock","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":630,"y":760,"wires":[[]]},{"id":"1d8249d8.9edf46","type":"api-call-service","z":"d6723c1.ee3f9c","name":"Turn On Fence Lights","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.outside_plug_shed","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":820,"y":840,"wires":[[]]},{"id":"8524ac9c.8c9b8","type":"api-call-service","z":"d6723c1.ee3f9c","name":"Turn Off Fence Lights","server":"94fdcfdf.a00b","version":1,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.outside_plug_shed","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":900,"wires":[[]]},{"id":"bdbf6b84.50c998","type":"server-state-changed","z":"d6723c1.ee3f9c","name":"Back/Pool motion","server":"94fdcfdf.a00b","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"group.pool_motion_group","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":"","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":100,"y":900,"wires":[["9c59d681.e38478"],["9e336fa7.0b4cd"]]},{"id":"e7f0fb40.dae368","type":"api-current-state","z":"d6723c1.ee3f9c","name":"Light On?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.pool_lights","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":460,"y":900,"wires":[["c2dc016e.f8a1c"],[]]},{"id":"c2dc016e.f8a1c","type":"api-current-state","z":"d6723c1.ee3f9c","name":"Motion?","server":"94fdcfdf.a00b","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.pool_motion_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":620,"y":900,"wires":[["3541132f.48bfcc"],["9e336fa7.0b4cd"]]},{"id":"94fdcfdf.a00b","type":"server","name":"Home Assistant","addon":true}]