Thanks for the response. Here is what I have including my test bench. I am not sure yet, if it works reliably
[{"id":"b6a69ab83c88ab3c","type":"server-state-changed","z":"ebb36f824d5bb606","name":"","server":"de5bcb2b.ec2a98","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.pantry_doors_contact","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":210,"y":360,"wires":[["05c2956dd1a95898","4e6de1f1f4d6d427"]]},{"id":"bd056577038681a7","type":"inject","z":"ebb36f824d5bb606","name":"timestamp","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"timestamp","payloadType":"msg","x":300,"y":560,"wires":[["05c2956dd1a95898"]]},{"id":"05c2956dd1a95898","type":"api-current-state","z":"ebb36f824d5bb606","name":"","server":"de5bcb2b.ec2a98","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.z_wave_plus_700_series_s2_dimmer_switch_6","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":740,"y":440,"wires":[["8156ce16ee5ef7d8"]]},{"id":"4e6de1f1f4d6d427","type":"switch","z":"ebb36f824d5bb606","name":"Pantry door open","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":570,"y":300,"wires":[["22ebdda6cc559940"],["708b43fa40f6387d"]]},{"id":"8fa32df313a5a3a1","type":"change","z":"ebb36f824d5bb606","name":"Get hallway status when On","rules":[{"t":"set","p":"hallway_brightness","pt":"flow","to":"data.attributes.brightness","tot":"msg"},{"t":"set","p":"hallway_state","pt":"flow","to":"on","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Hallway Status set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1420,"y":480,"wires":[["163fdb9e7a941128"]]},{"id":"8156ce16ee5ef7d8","type":"switch","z":"ebb36f824d5bb606","name":"Is hallway light on? ","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"false","repair":true,"outputs":2,"x":1130,"y":480,"wires":[["8fa32df313a5a3a1"],["a644c4084109e93c"]]},{"id":"22ebdda6cc559940","type":"api-call-service","z":"ebb36f824d5bb606","name":"Turn on hallway light","server":"de5bcb2b.ec2a98","version":3,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.z_wave_plus_700_series_s2_dimmer_switch_6","data":"{\"brightness\":255}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":840,"y":260,"wires":[[]]},{"id":"708b43fa40f6387d","type":"switch","z":"ebb36f824d5bb606","name":"Restore previous state if it was on","property":"hallway_state","propertyType":"flow","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":880,"y":320,"wires":[["b3789f6186d98927"],["ba1b4e10509f0fd8"]]},{"id":"ba1b4e10509f0fd8","type":"api-call-service","z":"ebb36f824d5bb606","name":"Keep off","server":"de5bcb2b.ec2a98","version":3,"debugenabled":true,"service_domain":"light","service":"turn_off","entityId":"light.z_wave_plus_700_series_s2_dimmer_switch_6","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1180,"y":400,"wires":[["fe3c8049e8d19911"]]},{"id":"996f8c343eb71320","type":"debug","z":"ebb36f824d5bb606","name":"Hallway Light was off","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1620,"y":600,"wires":[]},{"id":"fe3c8049e8d19911","type":"debug","z":"ebb36f824d5bb606","name":"Hallway light kept off","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1560,"y":400,"wires":[]},{"id":"dbac29e2e280dd9b","type":"inject","z":"ebb36f824d5bb606","name":"Read Hallway Light Status","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"hallway_state","payloadType":"flow","x":330,"y":620,"wires":[["0c500916203f6a20"]]},{"id":"0111c0df05f94a3f","type":"inject","z":"ebb36f824d5bb606","name":"Read Hallway Light Brightness","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"hallway_brightness","payloadType":"flow","x":340,"y":680,"wires":[["0c500916203f6a20"]]},{"id":"0c500916203f6a20","type":"debug","z":"ebb36f824d5bb606","name":"Show Hallway Variables","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":640,"wires":[]},{"id":"fb2935c5528f32e0","type":"inject","z":"ebb36f824d5bb606","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":60,"wires":[["c93f4e92d92e8c9a"]]},{"id":"c93f4e92d92e8c9a","type":"api-call-service","z":"ebb36f824d5bb606","name":"","server":"de5bcb2b.ec2a98","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.z_wave_plus_700_series_s2_dimmer_switch_6","data":"{\"brightness\":79}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":370,"y":80,"wires":[[]]},{"id":"f8cfadf62ccdc891","type":"debug","z":"ebb36f824d5bb606","name":"Status after turning back on","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1840,"y":280,"wires":[]},{"id":"163fdb9e7a941128","type":"debug","z":"ebb36f824d5bb606","name":"Hallway Variables Set","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1700,"y":480,"wires":[]},{"id":"a644c4084109e93c","type":"change","z":"ebb36f824d5bb606","name":"Get hallway status","rules":[{"t":"set","p":"hallway_brightness","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"hallway_state","pt":"flow","to":"off","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"Hallway Status set","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1390,"y":540,"wires":[["996f8c343eb71320"]]},{"id":"a66bf69c5e42510c","type":"change","z":"ebb36f824d5bb606","name":"Door closed","rules":[{"t":"set","p":"payload","pt":"msg","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":300,"wires":[["4e6de1f1f4d6d427","12aa71c73609912d"]]},{"id":"a2f0e7479913cf9c","type":"inject","z":"ebb36f824d5bb606","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":300,"wires":[["a66bf69c5e42510c"]]},{"id":"12aa71c73609912d","type":"debug","z":"ebb36f824d5bb606","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":200,"wires":[]},{"id":"77c1743adbf1a12b","type":"api-call-service","z":"ebb36f824d5bb606","name":"Restore Hallway to previous state","server":"de5bcb2b.ec2a98","version":3,"debugenabled":true,"service_domain":"light","service":"turn_on","entityId":"light.z_wave_plus_700_series_s2_dimmer_switch_6","data":"{ \"brightness\" : {{payload}} }","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1540,"y":280,"wires":[["f8cfadf62ccdc891"]]},{"id":"12841b37ef3e4fb5","type":"change","z":"ebb36f824d5bb606","name":"Door open","rules":[{"t":"set","p":"payload","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":220,"wires":[["4e6de1f1f4d6d427","12aa71c73609912d"]]},{"id":"8974374df8d955a5","type":"inject","z":"ebb36f824d5bb606","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":220,"wires":[["12841b37ef3e4fb5"]]},{"id":"b3789f6186d98927","type":"function","z":"ebb36f824d5bb606","name":"Set JSON Expression","func":"var hwb = flow.get(\"hallway_brightness\");\nreturn {payload: hwb};","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":280,"wires":[["77c1743adbf1a12b"]]},{"id":"de5bcb2b.ec2a98","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}]