How to refer a file outside the www-directory in a ui-based floorplan-dashboard?

At first: I’m still a beginner and the floorplan does work, but i want to make some adjustments which don’t work.

I did create a floorplan dashboard via ui and the embedded raw-configuration-editor.
The content (the important part, the rest does not affect the problem):

views:
  - title: Home
    config:
      show_side_bar: false
      show_app_header: false
    type: sidebar
    cards:
      - type: custom:floorplan-card
        full_height: true
        config: /local/community/ha-floorplan/home.yaml

This works fine.
Now i want to place the home.yaml file outside the www-directory. For that i created the folder ‘ha-floorplan’ directly inside the config-folder, so the new location is now:
/config/ha-floorplan/home.yaml

If i change the last line to (after that always restarting HA and refreshing cache):
config: /config/ha-floorplan/home.yaml or to
config: config/ha-floorplan/home.yaml or to
config: /ha-floorplan/home.yaml or to
config: ha-floorplan/home.yaml

i got a black screen and !include-statements don’t work in ui-mode-based dashboards.

SO, please:
is it possible to refer a file in a ui-mode-based dashboard outside the www-folder or does this only work on a yaml-mode-based dashboard [via !include-statement]?

Many thanks id advance!

No, it is not possible and if such a thing were possible it would be a serious security issue. Files under the www folder (/local/) are public and they don’t need any kind of authentication. If you allow to access any file in your system using a URL path, that would allow anyone to query your config file or your secrets just querying them from the URL.

Edit: Not exactly the solution that you are searching, but try to create a folder to store your files and use the allowlist_external_dirs parameter, you would be able to whitelist this directory to store your files.

Many thanks. You’re welcome! This is/was the first seriously answer i got in the last four months about this problem.
I will try your solution and report asap.

Many many thanks !
So long
Perlchamp

1 Like

Hi,
sorry for the late post, but i didn’t find some time for that…
seems that this does not work either, i got an empty (or black) dashboard :frowning: … i hope i did make a mistake.

What i did in the configuration.yaml (only affected lines):

homeassistant:
  allowlist_external_dirs:
    - "/config/ha-floorplan"
    - "/config/ha-floorplan/rules"

Then i did create the folders. In the /config/ha-floorplan folder i put in the working ha-floorplan-configuration yaml-file (affected lines):

image: /local/ha-floorplan/floorplan.svg
stylesheet: /local/ha-floorplan/floorplan.css
cache: false
log_level: info
console_log_level: info

image and stylesheet-sections refer to a file inside the www-directory, so it should work for both dashboards.
Then i opened the floorplan-dashboard via gui and there i opened the raw-configuration-editor. There i put in the following lines (affected lines only):

views:
  - title: Home
    config:
      show_side_bar: false
      show_app_header: false
    type: sidebar
    cards:
      - type: custom:floorplan-card
        full_height: true
        config: /config/ha-floorplan/floorplan-home.yaml

outside of the www-directory → does not work…
floorplan-home.yaml is the ha-floorplan-configuration-file

I have another directory with the same files (content is the same, the name of the files are different).
The working reference is:
config: /local/community/ha-floorplan/home.yaml
… still inside the www-directory → works

After the adjustments i did restart HA and refresh the browser-cache, too.

Some solutions for that ?

Many thanks in advance !
So long
Pc

Hi @perlchamp,
I am seeing that you want to access that folder from a front-end custom plugin. Unfortunately, the aforementioned option is to make the folder available to any integration or script that wants to access it to store files, but it will not make those files available through the URL for the reason that I explained before. If you want to provide files for being available by front-end plugin you must put those files inside the www folder, there is no alternative solution for that.

1 Like

Hi @elchininet ,
many thanks. Maybe there is a little missunderstanding.
It is possible to have access to files outside the www-directory by using yaml-based dashboard instead of using gui-based dashboards (my case).
The working codes:
configuration.yaml (affected files only):
lovelace: !include lovelace.yaml

lovelace.yaml (complete content):


mode: storage
dashboards:
  lovelace-floorplan:
    mode: yaml
    title: FLOORPLAN
    icon: mdi:script
    show_in_sidebar: true
    filename: ha-floorplan/floorplan-dashboard.yaml

… you see the reference is outside www-directory (without whitlisting) and the file ‘floorplan-home.yaml’ is placed in the same folder.

floorplan-home.yaml (the complete content, but only with one rule [so no nearly duplicated lines here]):

image: /local/ha-floorplan/floorplan.svg
stylesheet: /local/ha-floorplan/floorplan.css
cache: false
log_level: info
console_log_level: info

defaults:
  hover_action: hover-info
  tap_action: more-info

rules:
  - entity: weather.forecast_home
    element: weather.forecast_home
    state_action:
      - service: floorplan.text_set
        service_data: |
          ${entity.attributes.friendly_name ? entity.attributes.friendly_name + "/Pfalz"  : ""}

But my problem is solved, because it is not possible to refer to a file outside the www-directory by gui-based dashboards.
So it is no bug and so i’m not getting crazy (by that gui-behavior)…but the documentation per se did say, that gui(-integration) is recommended (for anything [in the future for a better usability])…LOL

That HACKS !

Many thanks, for your time, too.

So long
Pc

Yes, I think that there is a little misunderstanding here. :slightly_smiling_face:

The code of the configuration file (or a dashboard in yaml mode) is processed by the Home Assistant back-end and it is possible to split it

lovelace: !include lovelace.yaml

In that case it does not need to be located in the www folder.

Do not confuse that process with trying that a custom front-end plugin loads a file, in those cases the file must be inside the www folder because a front-end code cannot access a file inside the config folder through a URL path.

1 Like

the link is well known.

1 Like