Whitelist_external_dirs path in docker

I am running HA 0.94 in Docker on a Synology. I wish to place files in the www directory so I can view them on the front end, but I am not sure how to configure this directory in whitelist_external_dirs (suspect this is a Docker thing). The following raises an error with the config validator:

homeassistant:
  whitelist_external_dirs:
    - /tmp # ok no error
    - /www # gives error

Any my folder structure:

2 Likes

OK solved, needed:

  whitelist_external_dirs:
    - /config/www

this works even though I have no actual directory /config, but this is the ‘mount path’ Docker is using for my configuration directory. I can now snap images from cameras and server with the www folder using a service call with data:

{ "entity_id": "camera.dericam_2", "filename":"/config/www/test.jpg" }

3 Likes

Whitelist_external_dirs is (as the name suggests) for external directories. Anything within your normal configuration directory does not need to be whitelisted.

Thusly, things in your www directory are already available without this setting.

1 Like

@anon43302295 I removed the entry from whitelist_external_dirs and the service call no longer saves an image (no error is raised). Can you point to the code where Whitelist_external_dirs is defined? I had a look through the HA repo but cannot see where it is defined

Is the only place it explains the key, which isn’t very informative, but yeah I use my www folder for all sorts and I don’t use whitelist_external_dirs.

Don’t know what more to say there other than have a look at the core code, which hopefully will make more sense to you (as a python man) than it does to me :slight_smile:

OK dug some more, www appears to be the only dir in the whitelist:

    # Init whitelist external dir
    hac.whitelist_external_dirs = {hass.config.path('www')}
    if CONF_WHITELIST_EXTERNAL_DIRS in config:
        hac.whitelist_external_dirs.update(
            set(config[CONF_WHITELIST_EXTERNAL_DIRS]))

So are we thinking that if you add something else to whitelist_external_dirs, then you overwrite the default and have to add www too because the ‘if’ is executed when you use it, and then it only includes what you give put and not www, whereas if you didn’t include it in your configuration the ‘if’ wouldn’t be executed and www would be included as standard?

1 Like

I am really unsure, but I think it just updates by adding additional configured directories

But if that was the case you wouldn’t be experiencing any issues by not including it in your configuration.

I agree, not sure what the deal is here

Yeah, maybe a chat on discord with someone more ‘in the know’ or a bug report. Well outside my realm of expertise :smile:

1 Like

Picking up an old thread here, but do you know how I would do to be able to access the “share” folder from the internet?

Meaning that I can access it with https://mydomain.duckdns.org/share/camera_video.mp4

Put it in the www directory

No, sorry if I was unclear. I want to be able to access the “share” folder below when I’m not at home. Any chance that is doable?

Not through homeassistant unless you put it in your www folder, that’s the folder that you can ‘see’ from the internet.

Maybe you can symlink it, never tried.

1 Like

Not a direct answer to your question, but if you want to access a specific file with a static file name, you can always add it as an ffmpeg camera and see the video through your lovelace. Also note that anything you put in the www folder is accessable through your duckdns ip without logging in.

Another option is to run a simple webserver, configure webDAV and expose the folder.

Hi, i followed the solution here to add /config at the whitelist dirs, so the configuration.yaml become like this.

  whitelist_external_dirs:
    - /config/www

But when i try to call camera.snapshots service, i have this error shows up.

Failed to call service camera/snapshot. a bytes-like object is required, not 'NoneType'

I used IP CCTV camera in this setup. Here is the configuration.yaml setup. The CCTV camera works fine, i can show live stream in lovelace UI.

camera:
  - platform: generic
    name: "CCTV_Depan"
    still_image_url: http://random-web-url-to-jpg.jpg
    username: "admin"
    password: "*****"
    stream_source: rtsp://192.168.1.99/user=admin_password=*****_channel=1_stream=0.sdp

Can someone please help me to figure this out? Thanks

The camera error has nothing to do with whitelist_external_dirs.
Check your stream_source, it should not be necessary to include the credentials in both the URL and seperately

I think the stream_source works just fine. I am able to stream through the CCTV using VLC media player → open network stream.
I also tried not including the credentials, but then the stream didn’t work anymore.

Would you be able to assist me in getting the whitelist thing to work home Assistant Unraid docker docker mount path is /mnt/user/appdata/homedock would like to save images to homedock/snapshots. Can get this to work whitelist_external_dirs but not
Whitelist_external_dirs - /snapshots