Sending Frigate recognised image via notification

Posting this quite clunky solution for self-imagined problem. I would be interested what other methods there would be to solve this.

Recently Frigate integration took Image entities image entity to use for recognized objects (Image Entity | Home Assistant Developer Docs)
This entity points to URL /api/image_proxy/image.[camera name]_[object]?token=[token]
This part of URL is found from image entitys “entity_picture” attribute.
Token changes every time.

I wanted to get notification when car arrives to front yard (easy) with picture of recognized object (surprisingly not that easy). I could have used cameras snapshot functionality, but I specifically wanted the image of recognized object by Frigate. Yes, snapshot from camera at the same time would effectively be same, but my mind was set.

For notifications I use Pushover. It does not allow downloading pictures from URL in sending, file must be local. I was not able to find location of image entitys pictures from local disk.

Solution in use is:

  1. Download image entity image using Downloader
  2. Send pushover notification attaching downloaded picture

Here are relevant configurations:
downloader in configuration.yaml

downloader:
  download_dir: downloads

Automation:

alias: "Cameras: car arrival"
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.frontyard_car_count
    id: frontyard_car_count
condition: []
action:
  - choose:
      - conditions:
          - condition: and
            conditions:
              - condition: trigger
                id:
                  - frontyard_car_count
              - condition: template
                value_template: >-
                  {{ trigger.from_state.state|int < trigger.to_state.state|int
                  }}
        sequence:
          - service: downloader.download_file
            data:
              overwrite: true
              url: >-
                {{ 'http://[IP ADDRESS FOR HOME ASSISTANT]:8123'+state_attr('image.frontyard_car','entity_picture') }}
              subdir: frontyard
              filename: car.jpg
          - service: notify.pushover
            data:
              message: Car at front yard
              data: 
                attachment: downloads/frontyard/car.jpg
mode: single
3 Likes

Thanks for the post. I’m trying to adapt to the new image.frigate_camera thing also.
I’m using a snapshot right now, but get things that aren’t actual events sent through so I would like to get this method working. I’m using telegram to send the photos, but hopefully your post can help me figure it out.

Hi,

Can you please advise what path you added to allowlist_external_dirs so that pushover can access the attachment?

I am getting “Path is not whitelisted” and have tried various directory entries in configuration.yaml

Thanks!

Never mind, figured it out, needed:

“/config/downloads”

For some ancient reason I have following configurations, so I did not tumble for that message.

homeassistant:
  whitelist_external_dirs:
    - /tmp
  allowlist_external_dirs:
    - /config

1 Like