Unable to create multiple actionable notifications

Hey all,

I've been working on converting everything to node red, I am trying to do notifications to my mobile which are actionable, I can create the notification correctly, I can also include images, all this is good, I however am struggling to make the actionable with more than one entry, for example the below config works fine:

{
    "data": {
        "title": "Bin Day",
        "message": "Put the recycling bin out",
        "data": {
            "image": "/local/images/bins/Recycling.png",
            "actions": [
                {
                    "action": "binchorecomplete",
                    "title": "Chore Complete"
                }
            ]
        }
    }
}

This comes through OK and produces the below
image

I want to add a second action called cancel, but no matter what I do I either end up with formatting which isn't correct and errors when run, or will run but without any of the actions, does anyone know of a simple way to add a second action please as my googlefu and searches of the forums are failing me, everything I've found sofar either doesn't work, or uses really convoluted methods which are now defunct.

Regards
XcOM987

Welcome to the forum @XcOM987

Is this using a Home Assistant specific feature to send notification to the phone? Few here use HA so this might not be the best place to ask. I would be interested to know the mechanism it uses to get the notification to the phone though.

1 Like

Hi, Yes this is via Home Assistant, here is my flow:

[{"id":"0e87cef598688f0a","type":"comment","z":"bf778e73.f0fbd","name":"Chores","info":"","x":90,"y":960,"wires":[]},{"id":"380a06d14d60ada3","type":"inject","z":"bf778e73.f0fbd","name":"","props":[{"p":"nextbin","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 17 * * 3","once":false,"onceDelay":0.1,"topic":"","x":90,"y":1020,"wires":[["887de15e0c78161a"]]},{"id":"887de15e0c78161a","type":"api-current-state","z":"bf778e73.f0fbd","name":"Next_Bin","server":"b3a3253e.d12568","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.calendar_house_bin","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"nextbin","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":240,"y":1020,"wires":[["7084f58df041dedb"]]},{"id":"7084f58df041dedb","type":"switch","z":"bf778e73.f0fbd","name":"","property":"nextbin","propertyType":"msg","rules":[{"t":"eq","v":"Waste Bin","vt":"str"},{"t":"eq","v":"Recycling Bin","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":390,"y":1020,"wires":[["543678f944cb1ac8"],["ca1f832110a0c977"]]},{"id":"543678f944cb1ac8","type":"change","z":"bf778e73.f0fbd","name":"Waste bin","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"title\":\"Bin Day\",\"message\":\"Put the waste bin out\",\"data\":{\"image\":\"/local/images/bins/waste.png\",\"actions\":[{\"action\":\"binchorecomplete\",\"title\":\"Chore Complete\"}]}}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":1000,"wires":[["e8721f168fb3eba9"]]},{"id":"e8721f168fb3eba9","type":"link out","z":"bf778e73.f0fbd","name":"System - Notify - Phone - Soapstone","mode":"link","links":["c319e07b20de0916"],"x":665,"y":1000,"wires":[]},{"id":"ca1f832110a0c977","type":"change","z":"bf778e73.f0fbd","name":"Recycling bin","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"data\":{\"title\":\"Bin Day\",\"message\":\"Put the recycling bin out\",\"data\":{\"image\":\"/local/images/bins/Recycling.png\",\"actions\":{\"action\":\"binchorecomplete\",\"title\":\"Chore Complete\"}}}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":550,"y":1040,"wires":[["bd0780465b409910"]]},{"id":"bd0780465b409910","type":"link out","z":"bf778e73.f0fbd","name":"System - Notify - Phone - Soapstone","mode":"link","links":["c319e07b20de0916"],"x":665,"y":1040,"wires":[]},{"id":"b3a3253e.d12568","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
[{"id":"2f11bf1007dc6be3","type":"api-call-service","z":"bf778e73.f0fbd","name":"Notify Phone","server":"b3a3253e.d12568","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_soapstone","areaId":[],"deviceId":[],"entityId":[],"data":"{\t    \"title\": msg.title,\t    \"message\": msg.message\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":170,"y":300,"wires":[[]]},{"id":"c319e07b20de0916","type":"link in","z":"bf778e73.f0fbd","name":"System - Notify - Phone - Soapstone","links":["347e2a3566a2ab36","47bb8a82e358a654","3d8d9905c9fa2e99","e8721f168fb3eba9","bd0780465b409910"],"x":55,"y":300,"wires":[["2f11bf1007dc6be3"]]},{"id":"b3a3253e.d12568","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

I meant at a higher level how does the notification get to the phone? Do you need a specific app running on the phone for example?

Oh sorry, yes you need the home assistant companion app logged in and when you reference images for example they need to be accessible to the outside world either with or without authentication, mine are locked behind auth which is managed by the home assistant android app, works 99% the same with the iOS app but you have to change a few bits of syntax.

In other news I worked out the error with my array, I was misunderstanding how to end lines with a comma when I didn't need to end the last entry in an array with a comma but the close curly bracket for that entry in the array:

{
    "data": {
        "title": "Bin Day",
        "message": "Put the recycling bin out",
        "data": {
            "image": "/local/images/bins/Recycling.png",
            "actions": [
                {
                    "action": "binchorecomplete",
                    "title": "Chore Complete"
                },
                {
                    "action": "cancelchore",
                    "title": "Cancel Chore"
                }
            ]
        }
    }
}

Works fine now, and Nodered also has a nice events system where I can poll for the notification response by listening for events which match "mobile_app_notification_action"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.