Authentication issues with Mobile Notification and Media Source

Hi all, I am trying to send a notification through to the official app that is running on my android device, and I am trying to reference a photo to show in the notification.

I thought the best way to achieve this is to use the media source given that it allows the authentication process of HA to protect those files. I used the following resource…

In here it says…

If you are using the media_source integration you can alternatively use /media/local/path/to/file.jpg . Using media_source has the advantage that access requires authentication headers (which Home Assistant provides to the companion app). This means the content is not publicly available.

So with that, my automation looks like…

alias: Doorbell (Test)
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.doorbell
    to: 'on'
    from: 'off'
condition: []
action:
  - service: camera.snapshot
    data:
      filename: /mnt/dataraid/homeassistant/media/doorcam.jpg
    entity_id: camera.front_door
  - service: notify.mobile_app_xxxxxxxxx
    data:
      title: Doorbell
      message: There is someone at the door!
      data:
        image: 'https://xxxxxxxxxxxxxxxxxxxx/media/local/doorcam.jpg'
mode: single

The notification comes through, but it looks like an authentication fails for the image attachment, as I also get a notification from my syslog alert system…

2021-02-27 10:11:40 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from xxxxxxx (xxxxxxxx). (Dalvik/2.1.0 (Linux; U; Android 10; xxxxxxxxxxxxxxxxxxxx))

What am I doing wrong?

2 Likes

So I solved it myself. I thought you had to do a full URL, apparently not, just media/local/myfile.jpg works fine for the app.