Trigger State has delay in updating context

I have a physical light switch that shows its status with an LED and a bunch of window sensors.

My Flow can be described like this:

  • Turn on the LED (which means the switch) when at least one window is open
  • Turn it off when no window is open
  • If pressed, check the window states and turn the LED according to the first two rules
  • Also, if pressed and window(s) are open, can Alexa to tell which windows are open

To achieve this, my input nodes are

  • event:state listens for changes to the window sensor states
  • trigger:state fired when the switch/led status is changed

Followed by a subflow that first marks the incoming msg if msg.data.context.user_id = null in the assumption that it is manually pressed. Then every window sensor is checked and if it is open, it adds an entry with its msg.topic in a join node. The last sensor sets msg.complete.
If the join array contains at least one item, the switch is turned on, and if it was also triggered manually, Alexa starts talking.
If the join array is empty, the switch is switched off.

Now the problem: If I just trigger the switch manually, context.user_id is properly null. Triggered by the flow either due to a change to a window sensors, or if the switch is switch back after been trigger manually, the context.user_id is correctly an ID from NodeRed.
If I trigger it manually again now, context.user_id still contains the ID - not null like I would assume it to be. It takes a few seconds after the last automatic toggle, and if I trigger it manually again, it will also be null again.
I checked this with a debug node directly attached to the trigger:state switch event node.

How can I get the switched event to have context.user_id cleared after a manual press every time and right away?

The flow:

Flow
[
    {
        "id": "a7851ab230b3ef83",
        "type": "subflow",
        "name": "Marker: Manuell ausgeführt",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 60,
                "y": 240,
                "wires": [
                    {
                        "id": "6a62f612b7b0ef3c"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 700,
                "y": 240,
                "wires": [
                    {
                        "id": "6a62f612b7b0ef3c",
                        "port": 1
                    },
                    {
                        "id": "aba83476cf9f4785",
                        "port": 1
                    },
                    {
                        "id": "25ee3ca067bd307a",
                        "port": 1
                    },
                    {
                        "id": "f1cc60b4e9db854d",
                        "port": 1
                    },
                    {
                        "id": "e27bc7ef9b80721d",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
        ],
        "meta": {
        },
        "color": "#DDAA99"
    },
    {
        "id": "6a62f612b7b0ef3c",
        "type": "switch",
        "z": "a7851ab230b3ef83",
        "name": "data != undefined",
        "property": "data",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "undefined",
                "vt": "jsonata"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 290,
        "y": 240,
        "wires": [
            [
                "aba83476cf9f4785"
            ],
            [
            ]
        ]
    },
    {
        "id": "aba83476cf9f4785",
        "type": "switch",
        "z": "a7851ab230b3ef83",
        "name": "context != undefined",
        "property": "data.context",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "undefined",
                "vt": "jsonata"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 300,
        "y": 180,
        "wires": [
            [
                "25ee3ca067bd307a"
            ],
            [
            ]
        ]
    },
    {
        "id": "25ee3ca067bd307a",
        "type": "switch",
        "z": "a7851ab230b3ef83",
        "name": "context != null",
        "property": "data.context",
        "propertyType": "msg",
        "rules": [
            {
                "t": "nnull"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 280,
        "y": 120,
        "wires": [
            [
                "f1cc60b4e9db854d"
            ],
            [
            ]
        ]
    },
    {
        "id": "f1cc60b4e9db854d",
        "type": "switch",
        "z": "a7851ab230b3ef83",
        "name": "user_id == null",
        "property": "data.context.user_id",
        "propertyType": "msg",
        "rules": [
            {
                "t": "null"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 280,
        "y": 60,
        "wires": [
            [
                "e27bc7ef9b80721d"
            ],
            [
            ]
        ]
    },
    {
        "id": "e27bc7ef9b80721d",
        "type": "change",
        "z": "a7851ab230b3ef83",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "manually",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 540,
        "y": 60,
        "wires": [
            [
            ]
        ]
    },
    {
        "id": "de639a6fbce15616",
        "type": "subflow",
        "name": "Fenster offen?",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 40,
                "y": 40,
                "wires": [
                    {
                        "id": "eacf6d5c176c2e7f"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 700,
                "y": 80,
                "wires": [
                    {
                        "id": "ca3d2e933e450c5f",
                        "port": 0
                    }
                ]
            },
            {
                "x": 710,
                "y": 160,
                "wires": [
                    {
                        "id": "ca3d2e933e450c5f",
                        "port": 1
                    }
                ]
            },
            {
                "x": 710,
                "y": 300,
                "wires": [
                    {
                        "id": "adc2e297705c5ad8",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [
        ],
        "meta": {
        },
        "color": "#DDAA99",
        "outputLabels": [
            "ja",
            "nein",
            "array"
        ],
        "status": {
            "x": 680,
            "y": 380,
            "wires": [
                {
                    "id": "adc2e297705c5ad8",
                    "port": 0
                }
            ]
        }
    },
    {
        "id": "7aac9afe7a54bbb5",
        "type": "api-current-state",
        "z": "de639a6fbce15616",
        "name": "Balkontür Auf",
        "server": "bb4214b1.c101f8",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "binary_sensor.tursensor_wohnzimmer_offnung",
        "state_type": "str",
        "blockInputOverrides": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "die Balkontür",
                "valueType": "str"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 120,
        "y": 200,
        "wires": [
            [
                "349fba9f70c77b70",
                "2ad0dd313dfdeed8"
            ],
            [
                "349fba9f70c77b70"
            ]
        ],
        "outputLabels": [
            "ja",
            "nein"
        ]
    },
    {
        "id": "9a504cb3815b5163",
        "type": "api-current-state",
        "z": "de639a6fbce15616",
        "name": "Fenster Schlafzimmer Auf",
        "server": "bb4214b1.c101f8",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "binary_sensor.fenstersensor_schlafzimmer_1_offnung",
        "state_type": "str",
        "blockInputOverrides": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "das Schlafzimmerfenster",
                "valueType": "str"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 150,
        "y": 140,
        "wires": [
            [
                "7aac9afe7a54bbb5",
                "2ad0dd313dfdeed8"
            ],
            [
                "7aac9afe7a54bbb5"
            ]
        ],
        "outputLabels": [
            "ja",
            "nein"
        ]
    },
    {
        "id": "349fba9f70c77b70",
        "type": "api-current-state",
        "z": "de639a6fbce15616",
        "name": "Haustür Auf",
        "server": "bb4214b1.c101f8",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "binary_sensor.tursensor_haustur_offnung",
        "state_type": "str",
        "blockInputOverrides": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "complete",
                "propertyType": "msg",
                "value": "true",
                "valueType": "bool"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "die Haustür",
                "valueType": "str"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 110,
        "y": 260,
        "wires": [
            [
                "2ad0dd313dfdeed8"
            ],
            [
                "2814f12828762764"
            ]
        ],
        "outputLabels": [
            "ja",
            "nein"
        ]
    },
    {
        "id": "2814f12828762764",
        "type": "change",
        "z": "de639a6fbce15616",
        "name": "Clear Topic",
        "rules": [
            {
                "t": "delete",
                "p": "topic",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 290,
        "y": 300,
        "wires": [
            [
                "2ad0dd313dfdeed8"
            ]
        ]
    },
    {
        "id": "ca3d2e933e450c5f",
        "type": "switch",
        "z": "de639a6fbce15616",
        "name": "",
        "property": "topic.length",
        "propertyType": "msg",
        "rules": [
            {
                "t": "gt",
                "v": "0",
                "vt": "num"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 570,
        "y": 120,
        "wires": [
            [
            ],
            [
            ]
        ]
    },
    {
        "id": "adc2e297705c5ad8",
        "type": "join",
        "z": "de639a6fbce15616",
        "name": "",
        "mode": "custom",
        "build": "array",
        "property": "topic",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "useparts": false,
        "accumulate": false,
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 550,
        "y": 300,
        "wires": [
            [
                "ca3d2e933e450c5f"
            ]
        ]
    },
    {
        "id": "eacf6d5c176c2e7f",
        "type": "subflow:a7851ab230b3ef83",
        "z": "de639a6fbce15616",
        "name": "",
        "x": 240,
        "y": 40,
        "wires": [
            [
                "9a504cb3815b5163"
            ]
        ]
    },
    {
        "id": "2ad0dd313dfdeed8",
        "type": "change",
        "z": "de639a6fbce15616",
        "name": "",
        "rules": [
            {
                "t": "delete",
                "p": "data.context",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 220,
        "wires": [
            [
                "adc2e297705c5ad8"
            ]
        ]
    },
    {
        "id": "bb4214b1.c101f8",
        "type": "server",
        "name": "Home Assistant",
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "",
        "connectionDelay": false,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "10",
        "statusSeparator": "",
        "enableGlobalContextStore": false
    }
]