Finally I figured it out.
The toilet light is triggerd by a LD2410
When it’s turned on a timer will start
After turning off the light it will check if the occupation was > 5 min.
In that case the window will be openend and closed after 30 min.
[{"id":"d1107b5fa75886af","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"b5aea008e81fba23","type":"server-state-changed","z":"d1107b5fa75886af","name":"WC occupied","server":"d04bf2be.f81e1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.wc_sturing_presence","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":"700","forType":"num","forUnits":"milliseconds","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":130,"y":140,"wires":[["bed38c70aff3e7cd","396b72639fdceedf"],["77c9074b2e83b46e","8ee031275521021b"]]},{"id":"396b72639fdceedf","type":"api-call-service","z":"d1107b5fa75886af","name":"Light on","server":"d04bf2be.f81e1","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.wc_fibaro_lamp"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":100,"wires":[[]]},{"id":"8ee031275521021b","type":"api-call-service","z":"d1107b5fa75886af","name":"Light off","server":"d04bf2be.f81e1","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.wc_fibaro_lamp"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":400,"y":180,"wires":[[]]},{"id":"866a4b48e4811907","type":"hourglass","z":"d1107b5fa75886af","name":"","persistId":"","humanizeLocale":"nl","x":560,"y":320,"wires":[["f5438ee87d6a5499"]]},{"id":"bed38c70aff3e7cd","type":"change","z":"d1107b5fa75886af","name":"Start","rules":[{"t":"set","p":"command","pt":"msg","to":"start","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":260,"wires":[["866a4b48e4811907"]]},{"id":"77c9074b2e83b46e","type":"change","z":"d1107b5fa75886af","name":"Stop","rules":[{"t":"set","p":"command","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":300,"wires":[["866a4b48e4811907","4f8b1dd3a19b91a9"]]},{"id":"bdd9b9ae203122b7","type":"change","z":"d1107b5fa75886af","name":"Reset","rules":[{"t":"set","p":"command","pt":"msg","to":"reset","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":380,"wires":[["866a4b48e4811907"]]},{"id":"4f8b1dd3a19b91a9","type":"change","z":"d1107b5fa75886af","name":"Status","rules":[{"t":"set","p":"command","pt":"msg","to":"status","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":340,"wires":[["866a4b48e4811907","bdd9b9ae203122b7"]]},{"id":"f5438ee87d6a5499","type":"function","z":"d1107b5fa75886af","name":"function 6","func":"const p=msg.elapsed.time;\nnode.log(typeof p);\nmsg.payload= p.minutes;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":320,"wires":[["e21e58ed413a1b83"]]},{"id":"e21e58ed413a1b83","type":"switch","z":"d1107b5fa75886af","name":"> 5 minuten?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"5","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":890,"y":320,"wires":[["5c6c2ec8475db45d","e10774f7c9d95317"]]},{"id":"5c6c2ec8475db45d","type":"stoptimer","z":"d1107b5fa75886af","duration":"30","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":1100,"y":320,"wires":[["6b65a9a669058110"],[]]},{"id":"e10774f7c9d95317","type":"api-call-service","z":"d1107b5fa75886af","name":"Open window","server":"d04bf2be.f81e1","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.wc_sturing_sturing_wc_raam"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1140,"y":260,"wires":[[]]},{"id":"6b65a9a669058110","type":"api-call-service","z":"d1107b5fa75886af","name":"Close window","server":"d04bf2be.f81e1","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.wc_sturing_sturing_wc_raam"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1360,"y":260,"wires":[[]]},{"id":"d04bf2be.f81e1","type":"server","name":"Home Assistant","addon":true}]