I have the following sub-flow and as you can see there is an INPUT and an OUTPUT. The function before the output is building something but I am not able to reach that information where I am using the sub-flow, what I am missing here?
this is the sub-flow:
and this is where I am using it:
but I never get the payload.title
nor the payload.message
outside the sub-flow … why?
This is the JSON:
[
{
"id": "da99cd55eda41977",
"type": "subflow",
"name": "TurnOnTheOfficeDevices",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 200,
"wires": [
{
"id": "819a3202cf268b27"
}
]
}
],
"out": [
{
"x": 1320,
"y": 160,
"wires": [
{
"id": "679154354b335914",
"port": 0
}
]
}
],
"env": [],
"meta": {},
"color": "#DDAA99"
},
{
"id": "819a3202cf268b27",
"type": "time-range-switch",
"z": "da99cd55eda41977",
"name": "",
"lat": "28.496890",
"lon": "-82.553900",
"startTime": "07:00",
"endTime": "19:00",
"startOffset": 0,
"endOffset": 0,
"x": 210,
"y": 200,
"wires": [
[
"3bd127bfaccec40a",
"5bf5b6e1f79c45cd"
],
[]
]
},
{
"id": "cf664570e6f68d85",
"type": "switch",
"z": "da99cd55eda41977",
"name": "",
"property": "status",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "TURN_ON",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 610,
"y": 180,
"wires": [
[
"98dddf80862dab28",
"3d35f16ee11691f4"
]
]
},
{
"id": "98dddf80862dab28",
"type": "api-call-service",
"z": "da99cd55eda41977",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "fan",
"service": "turn_on",
"areaId": [],
"deviceId": [
"9d619875a573ed84d7ad0cb444f3f425"
],
"entityId": [],
"data": "{\"percentage\":100}",
"dataType": "json",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 810,
"y": 160,
"wires": [
[
"8ef549f22a458b1b"
]
]
},
{
"id": "8ef549f22a458b1b",
"type": "ha-wait-until",
"z": "da99cd55eda41977",
"name": "",
"server": "e593dd3.052432",
"version": 2,
"outputs": 2,
"entityId": [
"fan.office",
"light.office"
],
"entityIdFilterType": "list",
"property": "state",
"comparator": "is",
"value": "on",
"valueType": "str",
"timeout": "15",
"timeoutType": "num",
"timeoutUnits": "seconds",
"checkCurrentState": true,
"blockInputOverrides": true,
"outputProperties": [],
"entityLocation": "data",
"entityLocationType": "none",
"x": 1000,
"y": 180,
"wires": [
[
"679154354b335914"
],
[]
]
},
{
"id": "3d35f16ee11691f4",
"type": "api-call-service",
"z": "da99cd55eda41977",
"name": "",
"server": "e593dd3.052432",
"version": 5,
"debugenabled": false,
"domain": "light",
"service": "turn_on",
"areaId": [],
"deviceId": [
"9d619875a573ed84d7ad0cb444f3f425"
],
"entityId": [],
"data": "",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"x": 810,
"y": 220,
"wires": [
[
"8ef549f22a458b1b"
]
]
},
{
"id": "3bd127bfaccec40a",
"type": "function",
"z": "da99cd55eda41977",
"name": "Is the fan OFF?",
"func": "let homeAssistant = global.get('homeassistant').homeAssistant;\n\nlet fan = homeAssistant.states[\"fan.office\"].state;\nlet ac = homeAssistant.states[\"climate.home\"].state;\nlet weather = homeAssistant.states[\"weather.home\"].attributes.temperature;\n\nif (fan === \"off\" || (ac === \"off\" && weather >= 76)) {\n msg.status = \"TURN_ON\";\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 160,
"wires": [
[
"cf664570e6f68d85"
]
]
},
{
"id": "5bf5b6e1f79c45cd",
"type": "function",
"z": "da99cd55eda41977",
"name": "Is the light OFF?",
"func": "let lightOfficeState = global.get('homeassistant').homeAssistant.states[\"light.office\"].state;\n\nif (lightOfficeState === \"off\") {\n msg.status = \"TURN_ON\";\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 440,
"y": 220,
"wires": [
[
"cf664570e6f68d85"
]
]
},
{
"id": "679154354b335914",
"type": "function",
"z": "da99cd55eda41977",
"name": "Build payload",
"func": "msg.title = \"Office ready for Work\";\nmsg.message = \"The Office devices has been turned on!!\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1180,
"y": 160,
"wires": [
[]
]
},
{
"id": "e593dd3.052432",
"type": "server",
"name": "Home Assistant",
"addon": true
}
]
and this is how I am reading the output of the function in the notify
node:
{
"title": "{{msg.payload.title}}",
"message": "{{msg.payload.message}}"
}