Call Service -- Notification w/ Image ... Works in HA but not NodeRED

Hi all,

I have a simple notification with an image which works 100% of the time to my Android phone:

service: notify.mobile_app_pixel_6_pro
data:
  title: "test title"
  message: "test message"
  data:
    image: "{{ states.camera.dahua_mediaprofile_channel1_mainstream.attributes.entity_picture }}"

A notification is generated and an image is included.

However, when I convert to JSON and invoke Call Service via NodeRED:

{
    "title": "test title",
    "message": "test message",
    "data": {
        "image": "{{ states.camera.dahua_mediaprofile_channel1_mainstream.attributes.entity_picture }}"
    }
}

The notification is sent but no image is included.

Does anyone have any idea what I am doing wrong? I have tested the {{ states.camera… }} variable interpolation in other fields (for example including the same variable in the “message” body and it DOES interpolate the variable. I have also tested using the absolute URL to a publicly available image as the value to the “image” property and this DOES work too.

Does anyone have any ideas what I might be doing wrong?

Edit: for the avoidance of doubt the “data” attribute is type JSON, not J-expression.

Thanks in advance!

1 Like

Try this using J;expression not json

1 Like

Thank you so much, that worked beautifully!

Your example is the first use of $entities that I have stumbled across. Is there some documentation that you are aware of that illustrates its use (and maybe other useful global variables)?

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

Hi
I’m using the notify service in Nodered to send an email when an alarm was triggerered. It worked for a long time. But now Nodered shows an API errror. Probably after a recent upgrade

What shoud I do?

  1. This is my configuration file. Before i used gmail to send the email, which was working fine, but not anymore probably since an update. So today, I tried with my private account and I still have the same problem (API error)
    image

  2. And this is an entity in nodered .

  3. And this is the json contents
    image

  4. And even without an image, I recive the same “API error”
    image

? What should i do to correct this problem?

try

{
  "title": "Intruder alert",
  "message": "Intruder alert at apartment!!",
  "target": [
    "[email protected]"
  ],
  "data": {
    "images": [
      "/home/pi/snapshot1.jpg",
      "/home/pi/snapshot2.jpg"
    ]
  }
}

how can I get a live feed instead of a snapshot?

It’s been a while since I last tried streaming to the ha app. I gave up on it because there was lag. Instead I use a command to open the official app if I need to see the video. Clicking the text itself will open dahua’s app.

{
    "title": "mailbox - Notification",
    "message": "front door",
    "data": {
        "image": "/media/local/camera/mailbox/snap{{count}}.jpg",
        "clickAction": "app://com.mm.android.DMSS",
        "data": {
            "ttl": 0,
            "priority": "high"
        }
    }
}
1 Like

Hello can you share a code if I want to open ha app on ios?

In the URL field, you put twitter:// or nameoftheapp://, this seems to work.