I’ll start by saying I’m fairly sure I’m affected by the issue described in this feature request and the bugs linked to it (I am on Android) so really I want to check if that’s right and then get advice on what the best workaround is.
Config.yaml, my automation and the script the automation calls are all below.
Problem
Attempting to open an image from a notification generates a 401 Unauthorized response. This applies whether using the recommended media source integration or linking directly to the image.
What have I tried?
- Reading the docs, reading posts here, and on GitHub, and on Reddit
- Using the media source integration to link to the image
- Adding the image location to allowlist_external_dirs and linking to it directly
I’m particularly confused about the allowlist_external_dirs option not working, I thought that would be the workaround so any guidance on what I’ve got wrong there would be great.
Config.yaml (to show my various attempts to make the image folder externally accessible)
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml
zha:
enable_quirks: True
custom_quirks_path: custom_zha_quirks
homeassistant:
whitelist_external_dirs:
- '/media/security/driveway/'
- '/media/security/driveway'
- /media/security/driveway/
- /media/security/driveway
allowlist_external_dirs:
- '/media/security/driveway/'
- '/media/security/driveway'
- /media/security/driveway/
- /media/security/driveway
The automation which triggers when my camera detects a person. It was using path.value for all the link locations but I hardcoded some of them while trying to debug it.
I’ve got continue_on_error: true set because the camera can be a little slow so the 10 second timeout is occasionally hit.
alias: Person notification
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.driveway_person_detection
from: "off"
to: "on"
condition: []
action:
- alias: Get an image
continue_on_error: true
action: script.driveway_snapshot
metadata: {}
data: {}
response_variable: path
- action: notify.mobile_app_matt_s_s22
metadata: {}
data:
message: "{{path.value}}"
data:
image: /media/local/security/driveway/snapshot.jpeg
clickAction: http://homeassistant:8123/media/local/security/driveway/snapshot.jpeg
actions:
- action: URI
title: Open
uri: /media/local/security/driveway/snapshot.jpeg
mode: single
And finally the snapshot script.
alias: Driveway snapshot
variables:
path: |
{{ { 'value': "/media/security/driveway/snapshot.jpeg" } }}
sequence:
- alias: Get image
continue_on_error: true
action: camera.snapshot
metadata: {}
data:
filename: "{{path.value}}"
target:
device_id: [redacted]
- stop: Returning file path
response_variable: path
description: Take a picture from the driveway camera
icon: mdi:cctv
Any suggestions appreciated!