I’d personally go this way, it might be more difficult to understand though
[{"id":"d9631ff.d5dd0e","type":"comment","z":"878e74c2.7f39c8","name":"Patio Lights auto/manual mode sensor","info":"","x":250,"y":4240,"wires":[]},{"id":"429dc2b.660353c","type":"ha-entity","z":"878e74c2.7f39c8","name":"sensor.patio_lights_socket_1_manual_auto","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"patio_lights_socket_1_manual_auto"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":1150,"y":4520,"wires":[[]]},{"id":"fb95b448.0cc0c8","type":"comment","z":"878e74c2.7f39c8","name":"To manual","info":"","x":200,"y":4340,"wires":[]},{"id":"2bb4ea0.fa65916","type":"server-state-changed","z":"878e74c2.7f39c8","name":"Light to off?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.patio_lights_socket_1","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,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":210,"y":4420,"wires":[["32addbd6.f68e24"],[]]},{"id":"32addbd6.f68e24","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":4420,"wires":[[],["28a8e34a.caa25c"]]},{"id":"d5d46bcb.aff898","type":"change","z":"878e74c2.7f39c8","name":"manual","rules":[{"t":"set","p":"payload","pt":"msg","to":"manual","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":4480,"wires":[["429dc2b.660353c"]]},{"id":"95fa9843.8de008","type":"change","z":"878e74c2.7f39c8","name":"auto","rules":[{"t":"set","p":"payload","pt":"msg","to":"auto","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":4560,"wires":[["429dc2b.660353c"]]},{"id":"8be88cb9.8d8e8","type":"link in","z":"878e74c2.7f39c8","name":"","links":["28a8e34a.caa25c"],"x":735,"y":4480,"wires":[["d5d46bcb.aff898"]]},{"id":"7b98c79.34f1e38","type":"link in","z":"878e74c2.7f39c8","name":"","links":["8d0e44be.c548c8"],"x":735,"y":4560,"wires":[["95fa9843.8de008"]]},{"id":"28a8e34a.caa25c","type":"link out","z":"878e74c2.7f39c8","name":"","links":["8be88cb9.8d8e8"],"x":535,"y":4420,"wires":[]},{"id":"c0b42d91.e43eb","type":"comment","z":"878e74c2.7f39c8","name":"To auto","info":"","x":190,"y":4540,"wires":[]},{"id":"caf62019.b6cee","type":"inject","z":"878e74c2.7f39c8","name":"Every day at 22:31","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"31 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":4620,"wires":[["8d0e44be.c548c8"]]},{"id":"8d0e44be.c548c8","type":"link out","z":"878e74c2.7f39c8","name":"","links":["7b98c79.34f1e38"],"x":375,"y":4620,"wires":[]},{"id":"225098cc.2f6ec8","type":"comment","z":"878e74c2.7f39c8","name":"Main flow","info":"","x":160,"y":3980,"wires":[]},{"id":"29923e7d.8dbbe2","type":"server-state-changed","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.zone_sliding_door_open","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,"for":"5","forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":220,"y":4080,"wires":[["d11ad810.c0f348"],["d11ad810.c0f348"]]},{"id":"1459e9ff.8bdda6","type":"server-state-changed","z":"878e74c2.7f39c8","name":"sensor auto/manual","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.patio_lights_socket_1_manual_auto","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[],"x":210,"y":4120,"wires":[["d11ad810.c0f348"]]},{"id":"d11ad810.c0f348","type":"api-current-state","z":"878e74c2.7f39c8","name":"auto?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"auto","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.patio_lights_socket_1_manual_auto","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":450,"y":4100,"wires":[["e67a7a26.16eac8"],["2c629738.7e2518"]]},{"id":"2c629738.7e2518","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light off","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":4140,"wires":[[]]},{"id":"e67a7a26.16eac8","type":"api-current-state","z":"878e74c2.7f39c8","name":"PIR off for 5 min?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.zone_sliding_door_open","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"5","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":630,"y":4080,"wires":[["64700779.8df778"],["47956d8b.f70e24"]]},{"id":"64700779.8df778","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light off","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":4040,"wires":[[]]},{"id":"47956d8b.f70e24","type":"time-range-switch","z":"878e74c2.7f39c8","name":"Time Range","lat":"","lon":"","startTime":"18:00","endTime":"22:30","startOffset":0,"endOffset":0,"x":830,"y":4100,"wires":[["6762f089.a7b44"],[]]},{"id":"6762f089.a7b44","type":"api-call-service","z":"878e74c2.7f39c8","name":"Light on","server":"2879a640.7a9e7a","version":5,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":["switch.patio_lights_socket_1"],"data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1000,"y":4100,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"2879a640.7a9e7a","type":"server","name":"Home Assistant","version":4,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
Creating a sensor.patio_lights_socket_1_manual_auto allows you to have better control over the main flow. You’ll always know whether the main flow is in automatic mode or in manual mode. Aside from that, you can more easily add different triggers to change the state of your sensor, different ways to set the flow to auto or to manual.
Main flow contains this sensor as a trigger, so you only really need to care about configuring your sensor right. Main flow will do the rest and you’ll very rarely need to change it. This way, if for example, you set the sensor to manual, light will go off. On the other hand, if you set the sensor back to auto and someone is in the room (motion’s been detected during the last 5 minutes whithin your time range), light will turn on too.
Is more complete and better finished.