How to attach image entity to an email

It’s so dumb that they provided an Image entity without any useful way of actually using the image in anything else.

So after much thinking, I just made a script that downloads the image from URL and then sends an email with image attached, also I learned that in IOS notification you can use image URL and not local image, so you just add the URL to the action.
But what I found is that its very slow, the image gets updated about 1-2 minutes after the event, so using it in same automation as lets say motion detected from same devices is useless as image comes in much later to HA… I made a separate automation to just see the image after the fact.

1 Like

@stev3 , Can you please share the code?

Its a simple one line bash script, called by shell service passing the parameters.

#!/bin/bash
/usr/bin/wget https://URL_TO_HA$1 -O /config/www/proxy/doorbell.jpeg

then in automation.

alias: "Doorbell Image Updated. "
description: ""
trigger:
  - platform: state
    entity_id:
      - image.doorbell_event_image
    to: null
    from: null
condition: []
action:
  - service: shell_command.doorbellsnapshot
    data_template:
      arguments: "{{states.image.doorbell_event_image.attributes.entity_picture}}"
  - service: notify.mta_XXX.XXXX
    data:
      message: There was motion at doorbell, here is a screenshot.
      title: Image on DoorBell Changed
      target: [email protected]
      data:
        images:
          - /config/www/proxy/doorbell.jpeg
  - service: notify.mobile_app_iphone15pm
    data:
      message: Image at DoorBell Changed
      title: DoorBell Image Changed
      data:
        image: >-
          https://URL_TO_UR_HA{states.image.doorbell_event_image.attributes.entity_picture}}
mode: single

obviously you have to add shell scrip to config

shell_command:
  doorbellsnapshot: /config/www/proxy/doorbellimage.sh "{{ arguments }}"

Just hijacking this post to add my suggestion. Haven’t read the whole post but what you are describing seems to be related to the Eufy doorbell integration I have. Instead of a camera it has an ‘image’ entity. To allow capturing snapshots and saving them in a folder I found it easier to actually create a camera using the Generic Camera integration, where you should set the options as per below:

  • Still image URL: https://HA_IP:8123{{ state_attr(‘image.YOUR_DOORBELL’,‘entity_picture’) }}
  • RTSP transport protocol: HTTP
  • untick ‘Verify SSL certificate’

Then you can use the service in your automation to save a snapshot and send it in a notification:

service: camera.snapshot
data:
  filename: /config/www/images/doorbell_last_image.jpg
target:
  entity_id: camera.YOU_GENERIC_CAMERA_NAME

service: notify.YADAYADA
  data:
    message: There was motion at doorbell, here is a screenshot.
    title: Image on DoorBell Changed
    target: [email protected]
    image: /local/images/doorbell_last_image.jpg

Hope it helps.

Thats another great way to do it. Have to try it out.

Thanks for the feedback,

When I try to create a “Generic Camera” using the below:

  • Still image URL: https://192.168.0.100:8123{{ state_attr(‘image.doorbell_event_image’,‘entity_picture’) }}
  • RTSP transport protocol: HTTP
  • untick ‘Verify SSL certificate’

I get the Error: “Error rendering template. Review log for more info.”

Any more advice?

//Ase

Thanks Steve, This is sadly above my knowledge level :frowning:
I can do GUI and .yaml but not confortable with console commands.

Try this.

https://192.168.0.100:8123{{states.image.doorbell_event_image.attributes.entity_picture}}

2 Likes

Thanks, was able to generate the Generic Camera with this, still struggeling to get the image to email, but working on it!

That’s great! Not sure if you’re trying to implement now the notification to your email with the services I have shared on my post, but I realised I have made some mistakes, see below how it should look like (I have also amended my post):

The service to store an image of the doorbell when the automation is triggered:

service: camera.snapshot
data:
  filename: /config/www/images/doorbell_last_image.jpg
target:
  entity_id: camera.YOU_GENERIC_CAMERA_NAME

Service to send a notification with the image stored by the above script:

service: notify.YADAYADA
  data:
    message: There was motion at doorbell, here is a screenshot.
    title: Image on DoorBell Changed
    target: [email protected]
    image: /local/images/doorbell_last_image.jpg

Hope it works.

Hi,
I can see the jpg snapshot is generated in the /config/www/images/doorbell.jpg
I can send an email without the picture.

When I add the line image: /local/images/doorbell.jpg the email functionality breaks and I do not even get an email without the picture.

Ideas?

Hmm not really…anything in the logs? Try changing to:

service: notify.YADAYADA
  data:
    message: There was motion at doorbell, here is a screenshot.
    title: Image on DoorBell Changed
    target: [email protected]
    image:
       - /local/images/doorbell_last_image.jpg

No change in the behaviour from the last change.
Not sure how to check logs, please advice.

just try to use the same path as the snapshot if its for email. For ios notifications you add local.

Sadly this did not help, tried it earlier and now again, just to be sure.

This works for me when I send an email from developer tools, so not sure what you might be missing.



1 Like

Slowly getting closer, I receive a snapshot now.
The problem still is that I receive a cahed copy from earlier instead of the latest.
Many seems to struggle with this, tried different sollutions I found, but none working yet.
Anyone here that has solved this?

is it your old snapshot directly from the eufy or old snapshot from the generic camera ? Basically if you look at eufy image in HA did it update ?

and what does your automation look like ? What is the trigger ? I think I mentioned before that image is updated after the motion, so you have to wait for the state of image.doorbell_event_image to change, and not the attributes of it, but actual state and for the from/to is 0 (NULL) like this for example.

trigger:
  - platform: state
    entity_id:
      - image.doorbell_event_image
    to: null
    from: null