Trying to send an actionable notification to Android Companion - but its not working

I’m getting an RSS feed from Upwork. I’m trying to use NR to send actionable notifications to the Android Companion app. I get the notification, but the ‘Open Url’ doesn’t seem to work. It seems like it tries to open some invalid link on my HA instance as I get an error about HA not being available.

Here’s the JSON I’m using in the action. Remember, everything works, EXCEPT clicking on Open Url:

{
    "title": "Upwork Alert",
    "message": "{{article.title}} *url*:{{article.permalink}}",
    "data": {
        "actions": [
            {
                "action": "URI",
                "title": "Open Url",
                "uri": "{{article.permalink}}"
            }
        ]
    }
}

Note: I have article.permalink in the message as well. I was testing to make sure there wasn’t something odd in article.permalink.

looks like you’re missing - before action:

1 Like

How does that work? This is invalid:

{
    "title": "Upwork Alert",
    "message": "{{article.title}} *url*:{{article.permalink}}",
    "data": {
        "actions": [
            {
                - "action": "URI",
                  "title": "Open Url",
                  "uri": "{{article.permalink}}"
            }
        ]
    }
}

I don’t understand the rules of json but at the end of the day it has to parse to this for HA to process it.

service: notify.mobile_app_<your_device_id_here>
data:
  message: "Something happened at home!"
  data:
    actions:
      - action: "URI" # Must be set to URI if you plan to use a URI
        title: "Open Url"
        uri: "https://google.com" # URL to open when action is selected, can also be a lovelace view/dashboard      

So does json just add the dash?

use triple brackets around the uri {{{ }}}

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/mustache-templates.html

By default, Mustache will replace certain characters with their HTML escape codes. To stop this happening, you can use triple braces: {{{payload}}} .

1 Like

Just for your understanding:
JSON or YAML are just languages. HA has to parse/read both of them. It’s just the way you format your data. YAML gets used in HA because it’s more human-readable (I guess), and you don’t have to know the syntax of JSON like {"":""} or [,,]

  • - entry: value is the way YAML separates entries of an array
  • JSON does this with ["entry":value,]
    but you can’t use YAML in JSON or vice versa.

Take a translator as an example for HA:

  • you can tell it that you want to translate Spanish into English (.yaml file)
  • or that you want to translate Russian into English (JSON message)

but if you tell it that you want to translate Spanish into English and then give it a Russian word, it doesn’t know what to do

1 Like