-
Notifications
You must be signed in to change notification settings - Fork 0
Home Assistant Setup Guide
Home Assistant is an open-source, local-first home automation platform designed to centralize control of smart devices across your network. It provides unified dashboards, complex automation capabilities, and integration support for thousands of protocols and platforms (including Zigbee, Z-Wave, MQTT, HomeKit, and cloud APIs).
⚠️ Containerized (Docker) vs HAOS Note: Running Home Assistant via Docker Compose uses Home Assistant Container. It does not include the Home Assistant Supervisor or Add-ons Store. External applications (like Mosquitto MQTT or Frigate) are run as separate, sidecar Docker containers in your stack rather than installed through the HA UI.
- Copy the
homeassistant.yamlfile into your active server compose directory:
cp compose/templates/homeassistant.yaml compose/server1/homeassistant.yaml- Ensure your root
.envfile contains your server configuration variables:
DOMAINNAME=yourdomain.com
HOST_NAME=server1
TZ=America/New_York
PUID=1000
PGID=100
- Create the host directory for configuration files and logs:
sudo mkdir -p ${DOCKERDIR}/homeassistant/config ${DOCKERDIR}/logs/homeassistant- Launch the container:
docker compose -p mediaserver -f docker-compose-server1.yaml up -d homeassistant
⚠️ Network & Hardware Notice: Home Assistant usesnetwork_mode: hostto facilitate mDNS device discovery, UPnP, and local network scans. It also runs inprivilegedmode to allow direct access to attached hardware, such as USB Zigbee or Z-Wave dongles.
# ------------------------------------------------------------------------------
# Home Assistant - Smart Home Control Center
# ------------------------------------------------------------------------------
services:
homeassistant:
container_name: homeassistant.${HOST_NAME}
hostname: homeassistant.${HOST_NAME}.lan
image: ghcr.io/home-assistant/home-assistant:stable
environment:
PUID: ${PUID}
PGID: ${PGID}
TZ: ${TZ}
DOMAINNAME: ${DOMAINNAME}
HOST_NAME: ${HOST_NAME}.lan
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DOCKERDIR}/homeassistant/config:/config
- ${DOCKERDIR}/logs/homeassistant:/var/log
restart: always
network_mode: host
privileged: true
security_opt:
- no-new-privileges:true
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8123"]
interval: 30s
timeout: 10s
retries: 5
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
labels:
- "com.centurylinklabs.watchtower.enable=true"
- "homepage.group=Infrastructure"
- "homepage.name=Home Assistant"
- "homepage.icon=home-assistant.png"
- "homepage.href=http://ha.${DOMAINNAME}/"
- "homepage.description=Smart home control center"Because Home Assistant runs on the host network behind reverse proxies (Traefik, Cloudflared, etc.), you must update your HA HTTP settings before remote or proxy access will function cleanly.
- Open
${DOCKERDIR}/homeassistant/config/configuration.yamlin a text editor:
nano ${DOCKERDIR}/homeassistant/config/configuration.yaml- Add the
httpblock to trust your local subnet and Docker proxy headers:
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- 10.0.0.0/8 # Adjust to match your local LAN subnet
- 172.16.0.0/12 # Adjust to match your Docker network bridge subnets
- 192.168.1.0/24 # Adjust to match your home network subnet- Restart Home Assistant to apply the configuration:
docker compose -p mediaserver -f docker-compose-server1.yaml restart homeassistant- Open your browser and navigate to
http://<your-ip-address>:8123. - Follow the setup wizard to create your admin account, set your home location, and set time zones.
-
MQTT (Mosquitto): Go to Settings -> Devices & Services -> Add Integration -> MQTT. Enter your container host (
mosquittoorserver1.lan) and port1883. -
HACS (Home Assistant Community Store): Execute the HACS download script inside the running container to install community custom cards and integrations:
After running the script, restart Home Assistant and add HACS via Settings -> Devices & Services.
docker exec -it homeassistant.${HOST_NAME} bash -c "wget -O - https://get.hacs.xyz | bash -"
-
Built-in System Backup: Go to Settings -> System -> Backups inside the HA UI to generate downloadable
.tarbackup files. -
Directory Backup: Stop the container and back up the entire
${DOCKERDIR}/homeassistant/configdirectory.
On a fresh Home Assistant setup screen, click Restore from backup on the initial onboarding page and upload your backup file.
-
400 Bad Request when accessing via Proxy: Ensure your reverse proxy IP/subnet is explicitly listed under
trusted_proxiesinconfiguration.yaml. -
Zigbee / Z-Wave USB Stick Not Detected: Ensure the physical device (e.g.,
/dev/ttyUSB0or/dev/serial/by-id/...) is plugged in and accessible by the host user. -
Logs: Monitor startup errors in real time:
docker logs -f homeassistant.${HOST_NAME}