HA push notification: Send a local image?

Lonely Node-Red user here!

Lipstick, were you able to figure out how to accomplish this?

Personally speaking, I have been able to push a notification to the HA-companion app on Android.

That will prompt me when I enter or leave a pre-set radius around my home using GPS.

The last thing I would like to add to this flow is an image from within my garage to come along with the Android Notification.

This is what I have cobbled together, though sadly no image pops up with the android notification:

{
    "title": "HA - Notification",
    "message": "Trigger Garage Door?",
    "data": {
        "attachment": {
            "content-type": "jpeg",
            "url": "https://??????.duckdns.org/local/garage_snapshot.jpg"
        },
        "actions": [
            {
                "action": "Garage_Door",
                "title": "Yes Please"
            }
        ]
    }
}

Thoughts anyone?

1 Like

You should always look at the proper documentation when doing these things, Android has never sent images in that format :slight_smile:

3 Likes

Too bad android doesn’t allow video, would be great…
Is there no other workaround? Maybe send each sec snapshots to the same notification popup?

Thank you for your feedback!

I am VERY interested in finding the correct format that I should be using in order for this function to be successful. I have looked at that HA document prior, though sadly I have not taken away anything that gave me correct format to use via NodeRed.

All of the helpful information is written in YAML, though it would seem that all NodeRed wants me to enter is JSON :frowning:

So, that is my disconnect.

I tried using a YAML - > JSON converter online, though that is causing some API errors with the call services node. (Most likely because I am sending redundant info)

It is possible that I might be barking up the wrong tree coming here to ask for a solution to an issue that is caused by my lack of knowledge with how to properly use NodeRed.

That said, I am sure if I just used the notification platform within HA, then it would be working as intended.

YAML and JSON may be formatted differently but the keywords and variables use are still the same. So where in the link I posted do you see attachment being used? You need to start there and look at the basics. If you don’t get YAML maybe consider focusing on understanding YAML before you move on to Node Red?

Follow the examples on the docs site and make sure your JSON sticks to that. There is also a discord channel for node red if you need more help too.

Thank you for your prompt reply and encouragement.

As you have suggested, it is more a matter of me understanding and navigating to nuances between YAML and JSON.

The real breakthrough came when I was reading a GitHub post that you had helped with last Oct 2020.

I have posted my findings here:
My solution

All the best,
Rob

1 Like

Hi All,

anybody a hint how to grab and send a 5 sec Video instead of the picture?

THX M

Android doesn’t support that.

Hi, someone know why in the iphone can se the image, but on android 13 don´t?

I save the image here:

/media/facesnap/snap.jpg

and this is how i sended:

android:

service: notify.mobile_app_androidluis
data_template:
  title: Están Tocando el timbre...
  message: Esta persona esta tocando...
  data:
    color: red
    image: /media/local/facesnap/snap.jpg

iphone:

service: notify.mobile_app_iphone_hosi
data_template:
  title: Están Tocando el timbre...
  message: Esta persona esta tocando...
  data:
    color: red
    image: /media/local/facesnap/snap.jpg

@dshokouhi is there a way I can display an image thats NOT in the www folder? I use a mail integration that places an image here:

/config/custom_components/mail_and_packages/images/1.gif`

yes add the folder to the external list

https://www.home-assistant.io/docs/configuration/basic/#allowlist_external_dirs

@dshokouhi

So would this setting in my config allow this notification to work?

image

image

the best way to test if it works is to enter the full URL in a browser to check that it is accessible

is this what you mean by full url?

yup thats it!

then if the above works, why does this not show me any picture in my notification? But if I copy 1.jpg to my www folder and change the notification link to /local/1.jpg it does (so I know the picture CAN be sent via notification)

can you check the companion app logs to see if there is an error upon image retrieval?

Correct me if I’m wrong but in this screenshot you are viewing the image using your internal address. What happens if you try to view it from your external HA address?

It just opens up my HA instance but does NOT display the picture.
If I use external to view /local/1.jpg, I DO see the picture.

I am just using local as a test. I need to be able to view the image located in the /config directory though

Here ya go…

10-11 23:14:04.870 20164 20164 D MessagingService: Creating notification with following data: {sticky=false, tag=picture_test, color=blue, image=/config/custom_components/mail_and_packages/images/amazon/1.jpg, webhook_id=981d46d926e4a9e33795aaaaef55b8a5625a00cfb4465d9d4ae2670fdf43b2a3, message=Picture test, server_id=1}
10-11 23:14:04.877 20164 20164 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: false
10-11 23:14:04.877 20164 20164 D ServerConnectionInfo: Using external URL
10-11 23:14:04.880 20164 20901 D ServerConnectionInfo: localUrl is: false, usesInternalSsid is: false, usesWifi is: false
10-11 23:14:04.880 20164 20901 D ServerConnectionInfo: Using external URL
10-11 23:14:05.033 20164 20901 D TrafficStats: tagSocket(115) with statsTag=0xffffffff, statsUid=-1
10-11 23:14:05.723 20164 20901 D OpenGLRenderer: --- Failed to create image decoder with message 'unimplemented'
10-11 23:14:05.732 20164 20164 D MessagingService: Show notification with tag "picture_test" and id "-785838285"
10-11 23:14:07.400 20164 20901 D LogcatReader: Read logcat for pid 20164