I have a flow:
[{"id":"8ff18cfd6c25cca5","type":"api-call-service","z":"2ce2e6f1666de406","name":"Light Off","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.backyard_house_sconce_1"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1480,"y":640,"wires":[[]]},{"id":"41a831c8a7d0cd82","type":"api-call-service","z":"2ce2e6f1666de406","name":"Restore Lights","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"scene","service":"turn_on","areaId":[],"deviceId":[],"entityId":["scene.before"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1300,"y":640,"wires":[["8ff18cfd6c25cca5"]]},{"id":"6c35f34cbb6727df","type":"trigger","z":"2ce2e6f1666de406","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"20","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1110,"y":640,"wires":[["41a831c8a7d0cd82"]]},{"id":"8112aa0d6c65d5a3","type":"api-call-service","z":"2ce2e6f1666de406","name":"Light Green","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["83b837db33f4f0f4658aceff6f445719"],"entityId":[],"data":"{\"color_name\":\"green\", \"brightness_pct\":100}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":890,"y":660,"wires":[["6c35f34cbb6727df"]]},{"id":"6db195116d1bcaf1","type":"api-call-service","z":"2ce2e6f1666de406","name":"Light Flash","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["83b837db33f4f0f4658aceff6f445719"],"entityId":[],"data":"{\t \"flash\":\"long\"\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1030,"y":580,"wires":[["6c35f34cbb6727df"]]},{"id":"8b29c66a0b3ce92b","type":"api-current-state","z":"2ce2e6f1666de406","name":"Gate Status","server":"6e751b1b.8f17c4","version":3,"outputs":2,"halt_if":"closed","halt_if_type":"str","halt_if_compare":"is_not","entity_id":"cover.gate","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":690,"y":640,"wires":[["13d97a6dfd9a6271"],["8112aa0d6c65d5a3"]]},{"id":"13d97a6dfd9a6271","type":"api-call-service","z":"2ce2e6f1666de406","name":"Light Red","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":["83b837db33f4f0f4658aceff6f445719"],"entityId":[],"data":"{\"color_name\":\"red\",\"brightness_pct\":100}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":880,"y":600,"wires":[["6db195116d1bcaf1"]]},{"id":"478219914ae0c7fc","type":"api-call-service","z":"2ce2e6f1666de406","name":"Save Light State","server":"6e751b1b.8f17c4","version":5,"debugenabled":false,"domain":"scene","service":"create","areaId":[],"deviceId":[],"entityId":[],"data":"{\"scene_id\":\"before\",\"snapshot_entities\":[\"light.backyard_house_sconce_1\"]}","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":660,"wires":[["8b29c66a0b3ce92b"]]},{"id":"86df51de9e773b1b","type":"server-state-changed","z":"2ce2e6f1666de406","name":"Dining Room Door North Open","server":"6e751b1b.8f17c4","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"binary_sensor.dining_room_door_north_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":170,"y":660,"wires":[["478219914ae0c7fc"],[]]},{"id":"6e751b1b.8f17c4","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}]
The design of the flow is to capture the state of a single light and then change the color of the light based upon whether a gate is open/close and then restore the prior state.
Example: Door Opens and Gate is Open (light is off) → Light turns on/flashes red and then turns off.
If, however the door is opened a second time while the light is green or while flashing red that becomes the prior scene and now my light stays red/green for the rest of the day.
Can someone help me fix this?