I need 2x binary sensors to activate before switching a switch

I need to be able to Open the binary sensor door then the binary sensor Pir will activate, this will be done in this order.
binary_sensor.0x00158d0003cf3b33_contact (door contact)
then
binary_sensor.azealea_suite_pir_sensor
switch.azealea_thin_lights_on

Then if the following sequence happens
Pir activates then the door opens

binary_sensor.azealea_suite_pir_sensor
then
binary_sensor.0x00158d0003cf3b33_contact (door contact)
switch.azealea_thin_lights_off

This normally hapens within 10 - 30 seconds

[{"id":"41a640e87bd70a9c","type":"server-state-changed","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.0x00158d0003cf3b33_contact","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,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":300,"y":1320,"wires":[["04a15e94e25113f3"],[]]},{"id":"04a15e94e25113f3","type":"ha-wait-until","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":0,"outputs":2,"entityId":"binary_sensor.azealea_suite_pir_sensor","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":640,"y":1320,"wires":[["ce254beae062f10b"],[]]},{"id":"ce254beae062f10b","type":"api-call-service","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.azealea_thin_lights_on","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":1320,"wires":[[]]},{"id":"3deead1a7ef44a9d","type":"server-state-changed","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.azealea_suite_pir_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,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":280,"y":1400,"wires":[["8ac8f46bc33d8698"],[]]},{"id":"8ac8f46bc33d8698","type":"ha-wait-until","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":0,"outputs":2,"entityId":"binary_sensor.0x00158d0003cf3b33_contact","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":640,"y":1400,"wires":[["142823ada55dc7b9"],[]]},{"id":"142823ada55dc7b9","type":"api-call-service","z":"94f33d66.e9ffa","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.azealea_thin_lights_on","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":1400,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Amazing i will give this a try this afternoon cheers

Sadly it doesnt quite work, you have to open then close the door then activate the pir otherwise it turns on then off, I was so excited too. thankyou

Try this instead.
This will disable the other automation for 1 minute so that they won’t conflict each other.

[{"id":"41a640e87bd70a9c","type":"server-state-changed","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.0x00158d0003cf3b33_contact","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,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":320,"y":740,"wires":[["d6378c25a59c5bfd"],[]]},{"id":"04a15e94e25113f3","type":"ha-wait-until","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":0,"outputs":2,"entityId":"binary_sensor.azealea_suite_pir_sensor","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":960,"y":740,"wires":[["ce254beae062f10b"],[]]},{"id":"ce254beae062f10b","type":"api-call-service","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.azealea_thin_lights_on","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1150,"y":740,"wires":[["0d33a60223bcb337"]]},{"id":"3deead1a7ef44a9d","type":"server-state-changed","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.azealea_suite_pir_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,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":300,"y":820,"wires":[["b0c83689e8e2caea"],[]]},{"id":"8ac8f46bc33d8698","type":"ha-wait-until","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":0,"outputs":2,"entityId":"binary_sensor.0x00158d0003cf3b33_contact","entityIdFilterType":"exact","property":"state","comparator":"is","value":"on","valueType":"str","timeout":"30","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"data","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":960,"y":820,"wires":[["142823ada55dc7b9"],[]]},{"id":"142823ada55dc7b9","type":"api-call-service","z":"ebaa69a9.649708","name":"","server":"4bbca37b.1700ec","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.azealea_thin_lights_on","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1150,"y":820,"wires":[["0023394e400853c7"]]},{"id":"d935b5aea67b25aa","type":"change","z":"ebaa69a9.649708","name":"","rules":[{"t":"set","p":"door","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":740,"wires":[["04a15e94e25113f3"]]},{"id":"10ce75a8cb572753","type":"change","z":"ebaa69a9.649708","name":"","rules":[{"t":"set","p":"door","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1470,"y":740,"wires":[[]]},{"id":"0d33a60223bcb337","type":"delay","z":"ebaa69a9.649708","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1320,"y":740,"wires":[["10ce75a8cb572753"]]},{"id":"2aa54875d1197ec8","type":"change","z":"ebaa69a9.649708","name":"","rules":[{"t":"set","p":"pir","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":810,"y":820,"wires":[["8ac8f46bc33d8698"]]},{"id":"cf415fa3170c585a","type":"change","z":"ebaa69a9.649708","name":"","rules":[{"t":"set","p":"pir","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1470,"y":820,"wires":[[]]},{"id":"0023394e400853c7","type":"delay","z":"ebaa69a9.649708","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1320,"y":820,"wires":[["cf415fa3170c585a"]]},{"id":"d6378c25a59c5bfd","type":"switch","z":"ebaa69a9.649708","name":"","property":"pir","propertyType":"flow","rules":[{"t":"false"},{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":740,"wires":[["d935b5aea67b25aa"],[],["d935b5aea67b25aa"]]},{"id":"b0c83689e8e2caea","type":"switch","z":"ebaa69a9.649708","name":"","property":"door","propertyType":"flow","rules":[{"t":"false"},{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":630,"y":820,"wires":[["2aa54875d1197ec8"],[],["2aa54875d1197ec8"]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

It might work strangely the first time so give it a few attempts before giving up.

Cheers many many thanks for your assistance

Cheers works exactly as i expeted many many thanks

Hi Hellis81, I woder if I might trouble you for a bit more help, seeing as the last thing works amazing. I have a
Bathroom Door Contact (binary_sensor.bathroom_door_contact_2)
BathroomPir (binary_sensor.bathroom_motion_sensor_home_security_motion_detection)
Bathroom Light Front / Rear (light.bathroom_light_front / light.bathroom_light_rear)
My current Flow does the following:
Door is always open Walk in pir picks up lights come on for a period of time 5mins and stay on as we move about(dependnt on lux and time of day etc)
If I shut the door the lights should come on dimmed and stay on until the door is opened then go off, this kinda works however after the Pir picks you up the lights come on you shut the door and the light goes off for a brief while after 5 mins then comes on and stays on then acts normally once the door is opened, If you are happy to help again that would be great

[{"id":"f795a59d.45a6c8","type":"tab","label":"Bathroom Lights\\Rear Hall","disabled":false,"info":""},{"id":"9082e3ab.5b377","type":"server-state-changed","z":"f795a59d.45a6c8","name":"Bathroom Pir","server":"f2fd78b9.353888","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.bathroom_motion_sensor_home_security_motion_detection","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,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":180,"wires":[["57cc3f94.4ebd8"],[]]},{"id":"4a0a1bbc.df2fe4","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 2%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_front"],"data":"{   \"entity_id\": \"light.bathroom_light_2, light.bathroom_light_rear\",   \"brightness_pct\": 2 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":490,"y":220,"wires":[["dd1eb5493ae05c34"]]},{"id":"bed8e476.72b498","type":"stoptimer","z":"f795a59d.45a6c8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":1060,"y":120,"wires":[["1dac75d0.20564a"],[]]},{"id":"1dac75d0.20564a","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn off Lights","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_front","light.bathroom_light_rear"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1280,"y":180,"wires":[[]]},{"id":"57cc3f94.4ebd8","type":"within-time-switch","z":"f795a59d.45a6c8","name":"","nameInt":"","positionConfig":"fc57fdf8.60e95","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"22:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":270,"y":180,"wires":[["6a2eb01ce43923c2","bea86fc225e4aa02","24b365973cf91e7f"],["4a0a1bbc.df2fe4"]]},{"id":"c9112bea.8dbea8","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 100%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_front"],"data":"{   \"entity_id\": \"light.bathroom_light_front\",   \"brightness_pct\": 90 }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":100,"wires":[["dd1eb5493ae05c34"]]},{"id":"6a2eb01ce43923c2","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Extractor","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_extract_fan"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":490,"y":280,"wires":[["7e9be894bc0e61d8"]]},{"id":"2e590b336d432320","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 100%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_rear"],"data":"{   \"entity_id\": \"light.bathroom_light_rear\",   \"brightness_pct\": 90\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":680,"y":160,"wires":[["dd1eb5493ae05c34"]]},{"id":"7e9be894bc0e61d8","type":"stoptimer","z":"f795a59d.45a6c8","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":740,"y":280,"wires":[["11e26a9c045306d0"],[]]},{"id":"11e26a9c045306d0","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn off Extractor","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.bathroom_extract_fan"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1050,"y":280,"wires":[[]]},{"id":"bea86fc225e4aa02","type":"api-current-state","z":"f795a59d.45a6c8","name":"Office Lux","server":"f2fd78b9.353888","version":3,"outputs":2,"halt_if":"1600","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.office_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":460,"y":100,"wires":[["c9112bea.8dbea8"],[]]},{"id":"24b365973cf91e7f","type":"api-current-state","z":"f795a59d.45a6c8","name":"Office Lux","server":"f2fd78b9.353888","version":3,"outputs":2,"halt_if":"1600","halt_if_type":"num","halt_if_compare":"lte","entity_id":"sensor.office_lux","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":460,"y":160,"wires":[["2e590b336d432320"],[]]},{"id":"d14dc76cf9cc522b","type":"server-state-changed","z":"f795a59d.45a6c8","name":"Bathroom Door","server":"f2fd78b9.353888","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.bathroom_door_contact_2","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,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":120,"y":460,"wires":[["6a6327ae01179b80","624ad3faa2049b37","b15f01c1bf4f004b"],["16f10633e787f0ea"]]},{"id":"b84930d650c25848","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 4%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_front"],"data":"{   \"entity_id\": \"light.bathroom_light_rear\",   \"brightness_pct\": 04\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":500,"wires":[[]]},{"id":"16f10633e787f0ea","type":"within-time-switch","z":"f795a59d.45a6c8","name":"","nameInt":"","positionConfig":"fc57fdf8.60e95","startTime":"07:00","startTimeType":"entered","startOffset":0,"startOffsetType":"none","startOffsetMultiplier":60000,"endTime":"19:00","endTimeType":"entered","endOffset":0,"endOffsetType":"none","endOffsetMultiplier":60000,"timeDays":"*","timeOnlyOddDays":false,"timeOnlyEvenDays":false,"timeMonths":"*","timedatestart":"","timedateend":"","propertyStart":"","propertyStartType":"none","propertyStartCompare":"true","propertyStartThreshold":"","propertyStartThresholdType":"num","startTimeAlt":"","startTimeAltType":"entered","startOffsetAlt":0,"startOffsetAltType":"none","startOffsetAltMultiplier":60000,"propertyEnd":"","propertyEndType":"none","propertyEndCompare":"true","propertyEndThreshold":"","propertyEndThresholdType":"num","endTimeAlt":"","endTimeAltType":"entered","endOffsetAlt":0,"endOffsetAltType":"none","endOffsetAltMultiplier":60000,"tsCompare":"0","x":330,"y":420,"wires":[["168a7da6709f1729","ded1cbeb9fdbbebd"],["b84930d650c25848"]]},{"id":"168a7da6709f1729","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 100%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_rear"],"data":"{   \"entity_id\": \"light.bathroom_light_rear\",   \"brightness_pct\": 90\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":440,"wires":[[]]},{"id":"6a6327ae01179b80","type":"stoptimer","z":"f795a59d.45a6c8","duration":"5","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":340,"y":500,"wires":[["900d0260d3beaba6"],[]]},{"id":"900d0260d3beaba6","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn off Lights","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_front","light.bathroom_light_rear"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":560,"wires":[[]]},{"id":"ded1cbeb9fdbbebd","type":"api-call-service","z":"f795a59d.45a6c8","name":"Turn on Lights 100%","server":"f2fd78b9.353888","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bathroom_light_rear"],"data":"{   \"entity_id\": \"light.bathroom_light_front\",   \"brightness_pct\": 90\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":600,"y":380,"wires":[[]]},{"id":"dd1eb5493ae05c34","type":"api-current-state","z":"f795a59d.45a6c8","name":"Bathroom Door","server":"f2fd78b9.353888","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.bathroom_door_contact_2","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":940,"y":200,"wires":[["bed8e476.72b498"],[]]},{"id":"624ad3faa2049b37","type":"api-current-state","z":"f795a59d.45a6c8","name":"Bathroom Light Rear","server":"f2fd78b9.353888","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.bathroom_light_rear","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":340,"y":340,"wires":[["ded1cbeb9fdbbebd"],[]]},{"id":"b15f01c1bf4f004b","type":"api-current-state","z":"f795a59d.45a6c8","name":"Bathroom Light Front","server":"f2fd78b9.353888","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.bathroom_light_front","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":340,"y":380,"wires":[["ded1cbeb9fdbbebd"],[]]},{"id":"f2fd78b9.353888","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":"fc57fdf8.60e95","type":"position-config","name":"Within Time","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12"}]

I don’t have the within time node so I can’t test it.
But I assume it’s down here it turns off the lights?

Since I don’t have time to test it and install the node my advice is:

Where it detects that you have shut the door for this “extended” mode, use change node to set a flow variable to true.
Where I marked in the image above, use a switch node that looks at the flow variable if it’s true or false.
And then when the lights actually should turn off, set the flow variable to false.

Many many thanks, ill take a look cheers