iOS Notification not displaying payload information

My goal is to create a flow that sends me an iPhone notification when I leave the house with the friendly name of any entities in a group that are open.

It works fine, except for the call service api node doesn’t display the actual payload information. I am sure it’s some formatting, but for the life of me, I can’t figure this out.

Here’s my Node Red code:

[
    {
        "id": "83b0b8f0.06cdf8",
        "type": "debug",
        "z": "5e7d351f.1f4d7c",
        "name": "debug11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 660,
        "y": 460,
        "wires": []
    },
    {
        "id": "7ab82e2e.a03d",
        "type": "debug",
        "z": "5e7d351f.1f4d7c",
        "name": "debug12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 880,
        "y": 460,
        "wires": []
    },
    {
        "id": "bffefc8e.2c2ea",
        "type": "debug",
        "z": "5e7d351f.1f4d7c",
        "name": "debug13",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1080,
        "y": 460,
        "wires": []
    },
    {
        "id": "d5240820.f04c08",
        "type": "debug",
        "z": "5e7d351f.1f4d7c",
        "name": "debug14",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 1320,
        "y": 460,
        "wires": []
    },
    {
        "id": "2e051ef8.067ca2",
        "type": "inject",
        "z": "5e7d351f.1f4d7c",
        "name": "",
        "topic": "",
        "payload": "not_home",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 180,
        "y": 500,
        "wires": [
            [
                "6105467.d7503b8"
            ]
        ]
    },
    {
        "id": "6105467.d7503b8",
        "type": "ha-get-entities",
        "z": "5e7d351f.1f4d7c",
        "server": "266be3ff.3fa20c",
        "name": "Grab Open Window/Door Entities",
        "rules": [
            {
                "property": "entity_id",
                "logic": "in_group",
                "value": "group.outside_alarm",
                "valueType": "str"
            },
            {
                "property": "state",
                "logic": "is",
                "value": "on",
                "valueType": "str"
            }
        ],
        "output_type": "random",
        "output_empty_results": false,
        "output_location_type": "msg",
        "output_location": "payload",
        "output_results_count": 1,
        "x": 440,
        "y": 500,
        "wires": [
            [
                "a732bd36.7fb9b",
                "83b0b8f0.06cdf8"
            ]
        ]
    },
    {
        "id": "771d981d.ee0218",
        "type": "trigger-state",
        "z": "5e7d351f.1f4d7c",
        "name": "Left Home",
        "server": "266be3ff.3fa20c",
        "exposeToHomeAssistant": false,
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "entityid": "device_tracker.bjl_iphone_xs",
        "entityidfiltertype": "exact",
        "debugenabled": false,
        "constraints": [
            {
                "id": "4h4if2xes8r",
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "previous_state",
                "propertyValue": "old_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "home"
            },
            {
                "id": "zagj77u9wwe",
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "not_home"
            }
        ],
        "constraintsmustmatch": "all",
        "outputs": 2,
        "customoutputs": [],
        "outputinitially": false,
        "state_type": "str",
        "x": 190,
        "y": 560,
        "wires": [
            [
                "6105467.d7503b8"
            ],
            []
        ]
    },
    {
        "id": "a732bd36.7fb9b",
        "type": "template",
        "z": "5e7d351f.1f4d7c",
        "name": "Format Friendly Name",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{\n    The following are open:\n    \"{{payload.attributes.friendly_name}}\"\n        }\n",
        "output": "str",
        "x": 700,
        "y": 500,
        "wires": [
            [
                "8280197c.8a75f8",
                "7ab82e2e.a03d"
            ]
        ]
    },
    {
        "id": "8280197c.8a75f8",
        "type": "join",
        "z": "5e7d351f.1f4d7c",
        "name": "",
        "mode": "custom",
        "build": "string",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": ",",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "3",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "num",
        "reduceFixup": "",
        "x": 870,
        "y": 500,
        "wires": [
            [
                "6eaea4f3.21e2bc",
                "bffefc8e.2c2ea"
            ]
        ]
    },
    {
        "id": "6eaea4f3.21e2bc",
        "type": "api-call-service",
        "z": "5e7d351f.1f4d7c",
        "name": "Notification: \"Window/Door Open\"",
        "server": "266be3ff.3fa20c",
        "version": 1,
        "debugenabled": false,
        "service_domain": "notify",
        "service": "mobile_app_bjl_iphone_xs",
        "entityId": "",
        "data": "{\"title\":\"ALERT\",\"message\":\"{payload}\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "payload",
        "output_location_type": "msg",
        "mustacheAltTags": false,
        "x": 1160,
        "y": 500,
        "wires": [
            [
                "d5240820.f04c08"
            ]
        ]
    },
    {
        "id": "266be3ff.3fa20c",
        "type": "server",
        "z": "",
        "name": "Home Assistant"
    }
]

Looks like the message is flowing through fine until the call service node:

Running Hass.io 0.105.3 n a RP4. Help is appreciated.

I’m not 100% certain, but I think you need to use "{{payload}}" instead of "{payload}" in your call service node.

Tried that. When I do that, I get an error:
“Call-service API error. Error Message: extra keys not allowed @ data[‘0’]”

It might be easier using a function node before the call-service node and setting the properties there. I’m a big fan of function nodes. :smiley: Pop it between your join node and the call-service node and see what happens.

image

Wow. This did it. Haven’t used function node yet, so will play around with later. Thank you! I spent hours on this yesterday.

1 Like

No problem! I use the function node A LOT! It’s just so much easier (for me, at least) then dealing with Mustache templating.