How to properly filter on mobile_app_notification_action events?

I have several events nodes across NodeRED and I would like to have each of them listen only to it is related actions fired from iOS. Below is an example:

But having a JSON in the Event Data as:

{
    "action": "OFFICE_TURN_FAN_ON"
}

for some reason does not do the trick. What I am missing?

For reference this is the entire WF:

[
    {
        "id": "5cdda8e6b658dc74",
        "type": "tab",
        "label": "OFFICE_ALL_ON",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "0b37c1c4d7825ad2",
        "type": "server-events",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "server": "e593dd3.052432",
        "version": 2,
        "eventType": "ios.action_fired",
        "exposeToHomeAssistant": false,
        "eventData": "",
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "waitForRunning": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "$outputData(\"eventData\").event_type",
                "valueType": "jsonata"
            }
        ],
        "event_type": "",
        "x": 220,
        "y": 220,
        "wires": [
            [
                "f352a1b1ccc6fd87"
            ]
        ]
    },
    {
        "id": "f352a1b1ccc6fd87",
        "type": "switch",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "property": "payload.event.actionID",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "OFFICE_ALL_ON",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 430,
        "y": 220,
        "wires": [
            [
                "f8f5846de809fcf0",
                "808f025a334b0af1"
            ]
        ]
    },
    {
        "id": "f8f5846de809fcf0",
        "type": "api-call-service",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "server": "e593dd3.052432",
        "version": 5,
        "debugenabled": false,
        "domain": "light",
        "service": "turn_on",
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.home_office"
        ],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 650,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "a83007ad516aaa98",
        "type": "api-call-service",
        "z": "5cdda8e6b658dc74",
        "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": 710,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "bbb4cb0b2824526d",
        "type": "server-events",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "server": "e593dd3.052432",
        "version": 2,
        "eventType": "mobile_app_notification_action",
        "exposeToHomeAssistant": false,
        "eventData": "{\"action\":\"OFFICE_TURN_FAN_ON\"}",
        "haConfig": [
            {
                "property": "name",
                "value": ""
            },
            {
                "property": "icon",
                "value": ""
            }
        ],
        "waitForRunning": true,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "$outputData(\"eventData\").event_type",
                "valueType": "jsonata"
            }
        ],
        "event_type": "",
        "x": 270,
        "y": 340,
        "wires": [
            [
                "0903e6f0863283f6"
            ]
        ]
    },
    {
        "id": "0903e6f0863283f6",
        "type": "switch",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "property": "payload.event.actionID",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "OFFICE_TURN_FAN_ON",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 530,
        "y": 340,
        "wires": [
            [
                "a83007ad516aaa98"
            ]
        ]
    },
    {
        "id": "c9a81e2f2df22841",
        "type": "api-call-service",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "server": "e593dd3.052432",
        "version": 5,
        "debugenabled": true,
        "domain": "notify",
        "service": "notify",
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "data": "{\"message\":\"Do you want to turn on the fan?\",\"data\":{\"group\":\"HomeAssistantNotifications\",\"actions\":[{\"action\":\"OFFICE_TURN_FAN_ON\",\"title\":\"YES\",\"authenticationRequired\":\"no\",\"icon\":\"sfsymbols:checkmark.circle.fill\"}],\"push\":{\"sound\":{\"name\":\"GoToSleep_Haptic.caf\",\"critical\":1,\"volume\":1}}}}",
        "dataType": "json",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 970,
        "y": 180,
        "wires": [
            []
        ]
    },
    {
        "id": "808f025a334b0af1",
        "type": "api-current-state",
        "z": "5cdda8e6b658dc74",
        "name": "",
        "server": "e593dd3.052432",
        "version": 3,
        "outputs": 2,
        "halt_if": "on",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "fan.home_office",
        "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": 710,
        "y": 160,
        "wires": [
            [],
            [
                "c9a81e2f2df22841"
            ]
        ]
    },
    {
        "id": "e593dd3.052432",
        "type": "server",
        "name": "Home Assistant",
        "addon": true
    }
]

did you resolve this? Looking for correct payload as well

Specifically what is the switch payload for this payload to get “Garage Alerts Off” passed? msg.payload.event.action not it.

{"event_type":"mobile_app_notification_action","event":{"action":"Garage Alerts Off"},"origin":"REMOTE","time_fired":"2023-06-13T17:48:02.153921+00:00","context":{"id":"01H2TXYB791QKJKQSSGPF1ZTGN","parent_id":null,"user_id":"4a5463630c32461a82c47a31a5260ae6"}}

Sadly no, I haven’t found the right way to do this.

Figured it out by following this Create simple, actionable notifications with Home Assistant using Node-RED and the Home Assistant Companion App – Daniel Carr

also note the action name worked with lowercase and not spaces

1 Like

I still can’t get this to work. I can send a message with two option, but Node Red never “hears” any events regardless of which action I select. This is my code:

{
    "message": "This is a sample Alert.",
    "title": "Should we proceed?",
    "data": {
        "actions": [
            {
                "action": "YES",
                "title": "Yes"
            },
            {
                "action": "NO",
                "title": "No"
            }
        ]
    }
}