it's not very pretty but it works well.
[{"id":"bf54e42bbb243fab","type":"tab","label":"Flow alarme test","disabled":false,"info":"","env":[]},{"id":"f02add9212c79299","type":"inject","z":"bf54e42bbb243fab","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"switch_on","payloadType":"str","x":100,"y":180,"wires":[["5e6cc9945dfb26d8"]]},{"id":"e575a5d3ac10195a","type":"inject","z":"bf54e42bbb243fab","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"switch_off","payloadType":"str","x":100,"y":220,"wires":[["5e6cc9945dfb26d8"]]},{"id":"b8013777e540be29","type":"inject","z":"bf54e42bbb243fab","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"pir_on","payloadType":"str","x":90,"y":320,"wires":[["4c464465cae112a5"]]},{"id":"a669b618d825ac6d","type":"inject","z":"bf54e42bbb243fab","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"pir_off","payloadType":"str","x":90,"y":360,"wires":[["4c464465cae112a5"]]},{"id":"276a7239eeac557a","type":"function","z":"bf54e42bbb243fab","name":"","func":"let sensors = msg.payload; //don't need to write msg.payload to acces sensors\n\n//Door open and window not false, or garage 0\nif (sensors.alarme === \"switch_on\" && sensors.pir_hall === \"pir_on\")\n { return [msg, null]; }\n \n else {\n return [null, msg]; //Send message to second output\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":280,"wires":[["3bf66e090680aed5"],["1e0a2a1a3bf29a86"]]},{"id":"5e6cc9945dfb26d8","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"alarme","tot":"str"},{"t":"set","p":"alarme","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":200,"wires":[["23b715a59369d6e5"]]},{"id":"4c464465cae112a5","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"pir_hall","tot":"str"},{"t":"set","p":"pir_hall","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":340,"wires":[["23b715a59369d6e5"]]},{"id":"23b715a59369d6e5","type":"join","z":"bf54e42bbb243fab","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":470,"y":280,"wires":[["276a7239eeac557a"]]},{"id":"c42d5047228c82a7","type":"debug","z":"bf54e42bbb243fab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":80,"wires":[]},{"id":"98508b4f7c1d2c68","type":"debug","z":"bf54e42bbb243fab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":440,"wires":[]},{"id":"c11ccd637234e10a","type":"inject","z":"bf54e42bbb243fab","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":640,"wires":[["701ce8e588a465bd"]]},{"id":"701ce8e588a465bd","type":"function","z":"bf54e42bbb243fab","name":"","func":"let sensors = {\n door: global.get(\"door\"),\n garage: global.get(\"garage\"),\n window: global.get(\"window\")\n}\n\n//Door open and window not false, or garage 0\nif ( (sensors.door === \"close\" && !sensors.window) || sensors.garage === 0){\n return [msg, null]; //Send message to first output\n}else if (sensors.garage === 1){\n return [null, msg]; //Send message to second output\n}\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":300,"y":640,"wires":[["723ffc4aa03623cd"],["efd81456e2377e5f"]]},{"id":"723ffc4aa03623cd","type":"debug","z":"bf54e42bbb243fab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":600,"wires":[]},{"id":"efd81456e2377e5f","type":"debug","z":"bf54e42bbb243fab","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":680,"wires":[]},{"id":"21f33a4dd9d78bc4","type":"comment","z":"bf54e42bbb243fab","name":"Sensor check on external event","info":"","x":630,"y":640,"wires":[]},{"id":"3bf66e090680aed5","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":180,"wires":[["c42d5047228c82a7","543e61eb5a75e7d5"]]},{"id":"1e0a2a1a3bf29a86","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":360,"wires":[["98508b4f7c1d2c68","0f498f62b38e18fe"]]},{"id":"543e61eb5a75e7d5","type":"api-call-service","z":"bf54e42bbb243fab","name":"Prise ON","server":"d260f8f066987915","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.prise_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":760,"y":40,"wires":[[]]},{"id":"0f498f62b38e18fe","type":"api-call-service","z":"bf54e42bbb243fab","name":"Prise off","server":"d260f8f066987915","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":["hall"],"deviceId":[],"entityId":["switch.prise_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":800,"y":300,"wires":[[]]},{"id":"65bdaf8a00c82f91","type":"server-state-changed","z":"bf54e42bbb243fab","name":"presence Hall","server":"d260f8f066987915","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.pir_hall_occupancy","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":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":90,"y":100,"wires":[["5934e1a664547d86"]]},{"id":"b882e4912395ce85","type":"server-state-changed","z":"bf54e42bbb243fab","name":"alarme on/off","server":"d260f8f066987915","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.alarme","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":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":90,"y":480,"wires":[["d2f93990fa908a59"]]},{"id":"d2f93990fa908a59","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"pir_on","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"pir_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":420,"wires":[["4c464465cae112a5"]]},{"id":"5934e1a664547d86","type":"change","z":"bf54e42bbb243fab","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"on","fromt":"str","to":"switch_on","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"off","fromt":"str","to":"switch_off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":120,"wires":[["5e6cc9945dfb26d8"]]},{"id":"d260f8f066987915","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"}]