HA push notification: Send a local image?

When my camera detects a motion, i’m capturing a snapshot and saving it under:

/config/www/backyard_snapshot.jpg

now i want to access this image when i use a call service (in node red) and send it over to my phone. i’ve tried the following but haven’t been able to make it work:

{
    "title": "Backyard",
    "message": "Motion Detected!",
    "data": {
        "ttl": 0,
        "priority": "high",
        "image": "local/backyard_snapshot.jpg"
    }
}
{
    "title": "Backyard",
    "message": "Motion Detected!",
    "data": {
        "ttl": 0,
        "priority": "high",
        "image": "https://x.duckdns.org/local/backyard_snapshot.jpg"
    }
}
{
    "title": "Backyard",
    "message": "Motion Detected!",
    "data": {
        "ttl": 0,
        "priority": "high",
        "photo": [
            {
                "url": "https://x.duckdns.org/local/backyard_snapshot.jpg"
            }
        ]
    }
}

any ideas? thanks!

Do it the same way I mentioned in the other thread. This is the exact automation my example came from, sending a camera snapshot to me. As for the Node-Red side, I can’t help as I don’t use it.

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?