Several clarifications on paths

This is the overarching goal: How can I shorten references to /home/homeassistant/.homeassistant/www in my config to make it agnostic of the base path (i.e. /home/homeassistant/.homeassistant/)? Can I keep everything relative to the base path?

Note: I’m running HA Core. I know what in some of the other installation methods /config/ can be used (e.g. in HAOS).

It’s been a while since I’ve had to work with the www and /local/ paths and such. The functionality I’ve built before has been running unchanged.

I’m building some new automations and scripts that need to write to paths that can be used in notifications, be visible under the Media dashboard and custom views on my dashboards.

As part of this, I’ve been looking at my previous implementations to use them as the basis of my new functionality, but also to see where it can be improved or simplified.

As some users may know, documentation on paths is a little scattered.

I hope for this question to be useful as a guide, but also so that I can make some documentation updates.

  1. In the absence of allowlist_external_dirs in configuration.yaml, are there any publicly exposed directories by default?

I think the answer is no, but I couldn’t confirm this.

  1. When I take e.g. a camera snapshot, can I only use the full local file system path?

Typically, I will save images to my www directory using the full local file system path. From the web server’s point of view I reference this using /local/ in my resource path. I understand why these are different.

What I want to know is whether I can use a shorter full local file system path than e.g. /home/homeassistant/.homeassistant/www. I know that ~ can’t be used, since that’s an expansion handled by a shell and only works if it’s not quoted.

(Side note for others: If www doesn’t exist you need to create it.)

  1. Where can media URIs be used and are those URIs read-only?

If I’ve configured media_dirs so that one of these refer to a location under www, can I use source://... to refer to it as a way of achieving #2?

Now that I’ve written this it seems I must just use what I have and that anything else will probably just obscure things. I’ll still post this though, because something interesting might come from this.