How to embed or attach a Camera Snapshot in an Email

Newbie here! I’m porting from OpenHab and the HA syntax me stumped for this one. I’ve got SMTP notifications working, but want to put a snapshot of the security cam (unifi) in the body or as an attachment of the email… but I need help with the syntax.

The camera of interest:

  • Entity ID is “camera.cellar_high”
  • The manual URL Snapshot is “192.168.1.xxx/snap.jpeg”

The following is a sample of the YAML from the Automations Tab → Actions → Data, but I can’t work out the syntax for the Images part:

service: notify.iot_mail
data:
  title: Cellar Motion
  message: Cellar Motion
  data:
    images:
      - ??????

Thanks
Nathan

Thanks to some hints in Attaching images to email notifications - #5 by AstroBBoy I’ve got it working by doing the following

  1. Add the following to Configuration.yaml
homeassistant:
  allowlist_external_dirs:
    - "/tmp"
  1. In the Automation → Actions section create 2 Actions

Action 1: Take a snapshot from the Camera

data:
  filename: /tmp/snapshot.jpeg
service: camera.snapshot
target:
  entity_id: camera.cellar_high

Action 2: Send the email with the Snapshot

service: notify.iot_mail
data:
  title: Cellar Motion
  message: Cellar Motion
  data:
    images:
      - /tmp/snapshot.jpeg

Thanks
Nathan

2 Likes

this detail right here - the specifics of adding (2) actions in the automation saved me a ton of time. Really appreciate the helpfulness for folks like me that don’t have the experience of others in HA to know where to put things like this.

thanks to everyone for the help!