Previously I used Home Assistant Core, installed via pip. The config was in in my ~/.homeassistant directory, and custom plugins under ~/.homeassistant/custom_components. Since Core was deprecated, I moved to the Docker installation, mapping ~/.homeassistant to /config. The configuration is read by HA fine, but it doesn’t find the custom components. How to make this work?
It should work as it is.
Do you see messages in the log? No softlinks?
To check what HA sees, you can do:
❯ docker exec -it home-assistant bash
theia:/config# ls custom_components/
androidtv.tar.bz2 caldav epsonworkforce ideal_led lovelace_gen onkyo solaredge_modbus_multi toshl
apache_kafka caldav_todo.tar.bz2 exchangerate-api ideal_led_ble luci_config openrgb solcast_solar tuya_local
average circadian_lighting exchangeratesio irm_kmi luci_openvpn.tar.bz2 recycle_app spook volvooncall
bambu_lab cololight frigate jellyfin mediabrowser remote_command_line spook_inverse wundergroundpws
bermuda epic_games hacs jim_mobile meross_cloud ring_remote state_automate
browser_mod epic_games.tar.bz2 homeassistant-niceflors long_term_statistics mopidy smarthomesec tapo_control
Folder / file permissions incorrect?
This might be of interest…
I found out the problem. TL;DR: it’s really difficult to work with Docker.
My previous HA integration had several dependencies here and there, everything needs to be mounted to the container. I also tried running HA as a user instead of root to avoid it cluttering my filesystem with files owned by root, but then it can’t install Python dependencies.
My command line integrations are still broken, I’ll fix them some other time.
Here’s my docker-compose.yml in case it’s useful. My custom components are cloned from GitHub and live in my home directory.
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
volumes:
- /home/pi/home-assistant:/config
- /home/pi/ESPSomfy-RTS-HA/custom_components/espsomfy_rts:/config/custom_components/espsomfy_rts
- /home/pi/connectlife-ha/custom_components/connectlife:/config/custom_components/connectlife
- /home/pi/adaptive-lighting/custom_components/adaptive_lighting:/config/custom_components/adaptive_lighting
- /home/pi/hacs_waste_collection_schedule/custom_components/waste_collection_schedule:/config/custom_components/waste_collection_schedule
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
restart: unless-stopped
depends_on:
- zigbee2mqtt
privileged: true
network_mode: host
mqtt:
image: eclipse-mosquitto:2.0
restart: unless-stopped
volumes:
- '/home/pi/mosquitto-data:/mosquitto'
network_mode: host
command: 'mosquitto -c /mosquitto-no-auth.conf'
zigbee2mqtt:
container_name: zigbee2mqtt
restart: unless-stopped
depends_on:
- mqtt
image: koenkk/zigbee2mqtt
volumes:
- /home/pi/zigbee2mqtt-data:/app/data
- /run/udev:/run/udev:ro
network_mode: host
environment:
- TZ=Europe/Berlin
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
nginx:
container_name: nginx
hostname: nginx
image: nginx
volumes:
- /home/pi/nginx-conf:/etc/nginx/conf.d
- /home/pi/ssl:/etc/ssl/private:ro
network_mode: host
restart: unless-stopped
dependencies? docker brings dependencies so you shouldnt need to install anything
Same here. What dependencies? you dont install things in built docker containers.
you can use “user” to change user for HA container. This is a bit of a mess with docker. Sometimes is GID:UID and sometimes GUID:G??(forgot) but yeah mess. In this case its “user” like below
homeassistant:
container_name: homeassistant
hostname: homeassistant
user: 1050:1050
This maps to user on the host system. Create user/group there and assign correct system permission.
permissions issue or something…something…double quote instead of single.
For some reason command line on host is slightly different than command line in HA docker. I think it was something about the quotes. It always baffeled me and I didnt document the problem or fix so sorry cant help. Just know it is either your file permissions or some minor issue like double instead of single quote
Maybe I used the wrong word with “dependencies”. I have a lot of symlinks pointing to different locations. I removed some of them (moved the files in the right place instead), for others I had to mount the targets of the symlinks into the container.
As for the command line integrations, obviously these run commands on my machine. If the commands are not available inside the container, the integration won’t work. Worse, if the command is intended to do something with the computer (for example, calculating free memory or storage space), it won’t ever work inside a container. Probably ssh-ing into the machine would work.
Docker container should be treated like remote PC. SSH to host to run command.
Separately, macvlan is best for networking although more complex to setup. After you understand concept it is quite simple. My opinion