Hi. First post in the HA community ever. Hi.
Question:
How can Home assistant running in docker access an image in a specific folder on the host machine?
TL;DR:
If I’ve mounted an external docker path when installing docker and verified (indirectly, through doods) that HA can write to that path, why can’t HA read (display an image) from that specific path?
More info:
I’ve read a lot of info out there about this, but still failed to find a solution.
I have Home assistant 2021.2.1 installed from docker hub, running on a QNAP NAS (TS-453A)
I installed HA with
docker run -d \
--network=host \
--name home-assistant \
[...]
-v /share/CACHEDEV1_DATA/AppData/homeassistant:/config \
-v /share/CACHEDEV1_DATA/Surveillance/captured_person_detection:/captured_person:rw \
-v /etc/localtime:/etc/localtime:ro \
--restart unless-stopped \
homeassistant/home-assistant:2021.2.1
Note my attempt at mounting external path /share/CACHEDEV1_DATA/Surveillance/captured_person_detection
as internal path /captured_person
.
I then installed snowzach/doods:latest
as another docker container and configured it in configuration.yaml with:
image_processing:
- platform: doods
file_out:
- "/captured_person/camera_latest.jpg"
That’s not the full config above, I only included the relevant bits. Doods can be easily triggered with a service call to image_processing.scan
which successfully creates the camera_latest.jpg within the /share/CACHEDEV1_DATA/Surveillance/captured_person_detection folder. Easy to see the jpg update, easy to browse to it from the NAS. All good so far.
What I’d love to do is display the captured image within HA somehow. My attempt was to create a generic camera in configuration.yaml and show the image:
camera:
- platform: generic
name: Virtual Cam
still_image_url: /captured_person/camera_latest.jpg
When creating a Picture glance or Picture type of card,
type: picture-glance
camera_image: camera.virtual_cam
This always gives me errors of this type in the docker log:
2021-02-12 11:12:49 ERROR (MainThread) [homeassistant.components.generic.camera] Error getting new camera image from Virtual Cam: /captured_person/camera_latest.jpg
I also tried adding
allowlist_external_dirs:
- /captured_person
to my ‘homeassistant:’ section in configuration.yaml to no avail.
If I SSH into the NAS and ls -l
from the folder, I get
-rw-r--r-- 1 admin administrators 338988 2021-02-11 10:59 camera_latest.jpg
and the folder the jpg is in reports
drwxrwxrwx 3 admin administrators 4096 2021-02-12 09:09 captured_person_detection/
I won’t claim to properly understand linux file permissions, but it looks to me like anyone can read the file?
I know I could change file paths to use the ‘/config/www’ approach, but I wouldn’t want to expose those images over internet and I also prefer to have them in that specific NAS folder (because other external tools would manage those images as well).
Did I approach this correctly? I assumed /captured_person is a valid path for the HA docker since configuration.yaml points to it for the doods configuration and it works successfully. But why can’t HA (the generic camera or a simple picture card) read from it?
Thank you