This is it:
Debug 5 already displays the “wrong” context.
[
{
"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_z2m_contact",
"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_z2m_contact",
"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": "Wohnungstü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_wohnungstur_z2m_contact",
"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 Wohnungstü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": 130,
"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": 310,
"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
},
{
"id": "f5fa79c09a7c02ce",
"type": "subflow",
"name": "Status Fenster/Türen",
"info": "",
"category": "",
"in": [],
"out": [],
"env": [],
"meta": {},
"color": "#DDAA99",
"status": {
"x": 680,
"y": 180,
"wires": [
{
"id": "3f60512170c923fc",
"port": 0
}
]
}
},
{
"id": "85a6e72ee93fce16",
"type": "subflow:de639a6fbce15616",
"z": "f5fa79c09a7c02ce",
"name": "",
"x": 340,
"y": 100,
"wires": [
[
"b55ac076060cc762"
],
[
"e368f337e7dae5f6"
],
[
"3f60512170c923fc"
]
],
"outputLabels": [
"ja",
"nein",
"array"
]
},
{
"id": "b55ac076060cc762",
"type": "api-call-service",
"z": "f5fa79c09a7c02ce",
"name": "Status 2 Rot",
"server": "bb4214b1.c101f8",
"version": 7,
"debugenabled": false,
"action": "light.turn_off",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"light.statusschalter_haustur_gang_2"
],
"labelId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": true,
"domain": "light",
"service": "turn_off",
"x": 630,
"y": 60,
"wires": [
[
"995a39e1fe8ed168"
]
]
},
{
"id": "b927879ae9bb6c9c",
"type": "server-state-changed",
"z": "f5fa79c09a7c02ce",
"name": "Fenster/Tür offen",
"server": "bb4214b1.c101f8",
"version": 6,
"outputs": 2,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"binary_sensor.fenstersensor_schlafzimmer_1_z2m_contact",
"binary_sensor.tursensor_wohnzimmer_z2m_contact",
"binary_sensor.tursensor_wohnungstur_z2m_contact"
],
"substring": [],
"regex": []
},
"outputInitially": false,
"stateType": "habool",
"ifState": "true",
"ifStateType": "bool",
"ifStateOperator": "is",
"outputOnlyOnStateChange": 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": 120,
"y": 60,
"wires": [
[
"85a6e72ee93fce16"
],
[
"85a6e72ee93fce16"
]
]
},
{
"id": "e368f337e7dae5f6",
"type": "api-call-service",
"z": "f5fa79c09a7c02ce",
"name": "Status 2 Blau",
"server": "bb4214b1.c101f8",
"version": 7,
"debugenabled": false,
"action": "light.turn_on",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"light.statusschalter_haustur_gang_2"
],
"labelId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": true,
"domain": "light",
"service": "turn_on",
"x": 630,
"y": 120,
"wires": [
[]
]
},
{
"id": "1110de8f893b0c73",
"type": "trigger-state",
"z": "f5fa79c09a7c02ce",
"name": "Statusschalter 2",
"server": "bb4214b1.c101f8",
"version": 5,
"inputs": 0,
"outputs": 2,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"light.statusschalter_haustur_gang_2"
],
"substring": [],
"regex": []
},
"debugEnabled": false,
"constraints": [
{
"targetType": "this_entity",
"targetValue": "",
"propertyType": "current_state",
"propertyValue": "new_state.state",
"comparatorType": "is",
"comparatorValueDatatype": "str",
"comparatorValue": "off"
}
],
"customOutputs": [],
"outputInitially": true,
"stateType": "str",
"enableInput": false,
"x": 120,
"y": 320,
"wires": [
[
"85a6e72ee93fce16",
"007c4366f23d73b4"
],
[
"85a6e72ee93fce16",
"007c4366f23d73b4"
]
]
},
{
"id": "3f60512170c923fc",
"type": "change",
"z": "f5fa79c09a7c02ce",
"name": "Nutze msg.topic",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "topic",
"tot": "msg",
"dc": true
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 580,
"y": 180,
"wires": [
[]
]
},
{
"id": "a5899e3ffa28f204",
"type": "link call",
"z": "f5fa79c09a7c02ce",
"name": "",
"links": [
"dbe4febfe16afe9a"
],
"linkType": "static",
"timeout": "1",
"x": 750,
"y": 320,
"wires": [
[]
]
},
{
"id": "995a39e1fe8ed168",
"type": "function",
"z": "f5fa79c09a7c02ce",
"name": "Manuell ausgeführt?",
"func": "if (msg.manually === true)\n return msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 260,
"wires": [
[
"a5899e3ffa28f204"
]
]
},
{
"id": "b62dc5cb884be03b",
"type": "debug",
"z": "f5fa79c09a7c02ce",
"name": "debug 7",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1070,
"y": 180,
"wires": []
},
{
"id": "007c4366f23d73b4",
"type": "debug",
"z": "f5fa79c09a7c02ce",
"name": "debug 5",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 340,
"y": 320,
"wires": []
}
]