0

I am able to manually start the Home Assistant Docker container and its companion Matter container without issue. My Docker installation is running as root (which is the default for Docker to my knowledge), so I have to use sudo to start the container (e.g., sudo docker compose up matter-server -d).

However when I try to start the container using systemd the Matter container fails to load any nodes and thus the devices become 'Unavailable' in Home Assistant:

(MainThread) INFO [matter_server.server.device_controller] Loaded 0 nodes from stored configuration

and also a new warning from Docker about no HOME environment variable being set comes up while the container is starting:

WARNING time="2024-05-22T02:26:17-07:00" level=warning msg="The \"HOME\" variable is not set. Defaulting to a blank string."

Here is my systemd service:

[Unit]
Description=Restart Home Assistant Matter server

[Service]
ExecStart=docker compose down matter-server && docker compose up matter-server -d
WorkingDirectory=/path/to/my/docker/compose/file/

Why is the Matter container failing to find nodes when started with systemd?

How should I start the Matter container using systemd?

1 Answer 1

1

systemd has the quirk that running a service as root behaves differently with and without adding the User=root field to the service definition. Namely without User=root, environment variables such as USER, LOGNAME, HOME, and SHELL are not set. This is what causes the warning in the logs about HOME not being set, and apparently the Matter server is relying on this to load the list of configured devices.

Here is the corrected systemd service adding User=root which should avoid the warning and load the Matter devices as expected:

[Unit]
Description=Restart Home Assistant Matter server

[Service]
User=root
ExecStart=docker compose down matter-server && docker compose up matter-server -d
WorkingDirectory=/path/to/my/docker/compose/file/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.