docker.recipes

Complete Home Automation Stack

intermediate

Home Assistant with Node-RED automation, InfluxDB metrics, Grafana dashboards, and Mosquitto MQTT

Overview

Home Assistant is an open-source home automation platform that puts local control and privacy first, integrating with over 2000 different devices and services to create a unified smart home experience. Originally created by Paulus Schoutsen in 2013, it has grown into the most comprehensive home automation solution available, supporting everything from simple light switches to complex climate systems, security cameras, and energy monitoring devices. This complete automation stack combines Home Assistant's central hub capabilities with Node-RED's visual automation flows, InfluxDB's time-series data storage, Grafana's analytical dashboards, and Mosquitto's MQTT message broker to create a comprehensive IoT ecosystem. The stack enables you to not only control devices but also collect historical data, create complex automations through visual programming, and gain insights through professional monitoring dashboards. Zigbee2MQTT adds direct Zigbee device support without requiring proprietary hubs. This configuration is ideal for serious home automation enthusiasts, IoT developers, and homelab operators who want complete control over their smart home infrastructure while maintaining data privacy and local operation. Unlike cloud-based solutions like SmartThings or commercial platforms, this stack keeps all data processing local while providing enterprise-grade monitoring and automation capabilities typically found in industrial IoT deployments.

Key Features

  • 2000+ device integrations including Philips Hue, Nest, Sonos, and major IoT protocols
  • Visual flow-based automation programming through Node-RED's drag-and-drop interface
  • Time-series sensor data storage with InfluxDB's high-performance write capabilities
  • Professional monitoring dashboards with Grafana's 50+ visualization types
  • Direct Zigbee device control without proprietary hubs via Zigbee2MQTT
  • MQTT message broker for reliable IoT device communication
  • Energy monitoring and solar panel integration for sustainability tracking
  • Voice assistant support for Alexa, Google Assistant, and local wake word detection

Common Use Cases

  • 1Complete smart home automation with heating, lighting, security, and entertainment systems
  • 2Energy monitoring and solar panel optimization with historical usage analytics
  • 3IoT sensor data collection for greenhouse, aquarium, or workshop monitoring
  • 4Home security system with camera integration, motion detection, and mobile alerts
  • 5Multi-protocol device integration combining WiFi, Zigbee, Z-Wave, and Bluetooth devices
  • 6Rental property monitoring with tenant-friendly automation and remote management
  • 7Small business or retail automation for lighting, HVAC, and occupancy sensing

Prerequisites

  • Docker host with minimum 4GB RAM (8GB recommended for full stack operation)
  • Available ports 8123, 1880, 3000, 8080, 8086, 1883, and 9001 on the host system
  • USB Zigbee coordinator device (like ConBee II or Sonoff Zigbee) for device integration
  • Basic understanding of YAML configuration and MQTT messaging concepts
  • Network access to IoT devices or ability to configure device discovery protocols
  • Storage space for time-series data (plan for 1-10GB depending on sensor count and retention)

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 homeassistant:
3 image: ghcr.io/home-assistant/home-assistant:stable
4 container_name: homeassistant
5 restart: unless-stopped
6 network_mode: host
7 volumes:
8 - ./homeassistant/config:/config
9 - /etc/localtime:/etc/localtime:ro
10 environment:
11 - TZ=${TZ:-UTC}
12
13 mosquitto:
14 image: eclipse-mosquitto:latest
15 container_name: mosquitto
16 restart: unless-stopped
17 ports:
18 - "1883:1883"
19 - "9001:9001"
20 volumes:
21 - ./mosquitto/config:/mosquitto/config
22 - ./mosquitto/data:/mosquitto/data
23 - ./mosquitto/log:/mosquitto/log
24
25 node-red:
26 image: nodered/node-red:latest
27 container_name: node-red
28 restart: unless-stopped
29 ports:
30 - "${NODERED_PORT:-1880}:1880"
31 volumes:
32 - node_red_data:/data
33 environment:
34 - TZ=${TZ:-UTC}
35
36 influxdb:
37 image: influxdb:2.7
38 container_name: influxdb
39 restart: unless-stopped
40 ports:
41 - "${INFLUXDB_PORT:-8086}:8086"
42 environment:
43 - DOCKER_INFLUXDB_INIT_MODE=setup
44 - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER}
45 - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD}
46 - DOCKER_INFLUXDB_INIT_ORG=home
47 - DOCKER_INFLUXDB_INIT_BUCKET=homeassistant
48 - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUX_TOKEN}
49 volumes:
50 - influxdb_data:/var/lib/influxdb2
51
52 grafana:
53 image: grafana/grafana:latest
54 container_name: grafana
55 restart: unless-stopped
56 ports:
57 - "${GRAFANA_PORT:-3000}:3000"
58 environment:
59 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
60 volumes:
61 - grafana_data:/var/lib/grafana
62 depends_on:
63 - influxdb
64
65 zigbee2mqtt:
66 image: koenkk/zigbee2mqtt:latest
67 container_name: zigbee2mqtt
68 restart: unless-stopped
69 ports:
70 - "${Z2M_PORT:-8080}:8080"
71 volumes:
72 - ./zigbee2mqtt/data:/app/data
73 - /run/udev:/run/udev:ro
74 environment:
75 - TZ=${TZ:-UTC}
76 devices:
77 - /dev/ttyUSB0:/dev/ttyUSB0
78 depends_on:
79 - mosquitto
80
81volumes:
82 node_red_data:
83 influxdb_data:
84 grafana_data:

.env Template

.env
1# Complete Home Automation Stack
2NODERED_PORT=1880
3INFLUXDB_PORT=8086
4GRAFANA_PORT=3000
5Z2M_PORT=8080
6TZ=America/New_York
7
8# InfluxDB
9INFLUX_USER=admin
10INFLUX_PASSWORD=adminpassword
11INFLUX_TOKEN=your-influxdb-token
12
13# Grafana
14GRAFANA_PASSWORD=admin

Usage Notes

  1. 1Home Assistant at http://localhost:8123 (network_mode: host)
  2. 2Node-RED at http://localhost:1880
  3. 3Grafana at http://localhost:3000
  4. 4Zigbee2MQTT at http://localhost:8080
  5. 5Configure HA to send data to InfluxDB
  6. 6Create mosquitto.conf with listener settings

Individual Services(6 services)

Copy individual services to mix and match with your existing compose files.

homeassistant
homeassistant:
  image: ghcr.io/home-assistant/home-assistant:stable
  container_name: homeassistant
  restart: unless-stopped
  network_mode: host
  volumes:
    - ./homeassistant/config:/config
    - /etc/localtime:/etc/localtime:ro
  environment:
    - TZ=${TZ:-UTC}
mosquitto
mosquitto:
  image: eclipse-mosquitto:latest
  container_name: mosquitto
  restart: unless-stopped
  ports:
    - "1883:1883"
    - "9001:9001"
  volumes:
    - ./mosquitto/config:/mosquitto/config
    - ./mosquitto/data:/mosquitto/data
    - ./mosquitto/log:/mosquitto/log
node-red
node-red:
  image: nodered/node-red:latest
  container_name: node-red
  restart: unless-stopped
  ports:
    - ${NODERED_PORT:-1880}:1880
  volumes:
    - node_red_data:/data
  environment:
    - TZ=${TZ:-UTC}
influxdb
influxdb:
  image: influxdb:2.7
  container_name: influxdb
  restart: unless-stopped
  ports:
    - ${INFLUXDB_PORT:-8086}:8086
  environment:
    - DOCKER_INFLUXDB_INIT_MODE=setup
    - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER}
    - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD}
    - DOCKER_INFLUXDB_INIT_ORG=home
    - DOCKER_INFLUXDB_INIT_BUCKET=homeassistant
    - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUX_TOKEN}
  volumes:
    - influxdb_data:/var/lib/influxdb2
grafana
grafana:
  image: grafana/grafana:latest
  container_name: grafana
  restart: unless-stopped
  ports:
    - ${GRAFANA_PORT:-3000}:3000
  environment:
    - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
  volumes:
    - grafana_data:/var/lib/grafana
  depends_on:
    - influxdb
zigbee2mqtt
zigbee2mqtt:
  image: koenkk/zigbee2mqtt:latest
  container_name: zigbee2mqtt
  restart: unless-stopped
  ports:
    - ${Z2M_PORT:-8080}:8080
  volumes:
    - ./zigbee2mqtt/data:/app/data
    - /run/udev:/run/udev:ro
  environment:
    - TZ=${TZ:-UTC}
  devices:
    - /dev/ttyUSB0:/dev/ttyUSB0
  depends_on:
    - mosquitto

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 homeassistant:
5 image: ghcr.io/home-assistant/home-assistant:stable
6 container_name: homeassistant
7 restart: unless-stopped
8 network_mode: host
9 volumes:
10 - ./homeassistant/config:/config
11 - /etc/localtime:/etc/localtime:ro
12 environment:
13 - TZ=${TZ:-UTC}
14
15 mosquitto:
16 image: eclipse-mosquitto:latest
17 container_name: mosquitto
18 restart: unless-stopped
19 ports:
20 - "1883:1883"
21 - "9001:9001"
22 volumes:
23 - ./mosquitto/config:/mosquitto/config
24 - ./mosquitto/data:/mosquitto/data
25 - ./mosquitto/log:/mosquitto/log
26
27 node-red:
28 image: nodered/node-red:latest
29 container_name: node-red
30 restart: unless-stopped
31 ports:
32 - "${NODERED_PORT:-1880}:1880"
33 volumes:
34 - node_red_data:/data
35 environment:
36 - TZ=${TZ:-UTC}
37
38 influxdb:
39 image: influxdb:2.7
40 container_name: influxdb
41 restart: unless-stopped
42 ports:
43 - "${INFLUXDB_PORT:-8086}:8086"
44 environment:
45 - DOCKER_INFLUXDB_INIT_MODE=setup
46 - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER}
47 - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD}
48 - DOCKER_INFLUXDB_INIT_ORG=home
49 - DOCKER_INFLUXDB_INIT_BUCKET=homeassistant
50 - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUX_TOKEN}
51 volumes:
52 - influxdb_data:/var/lib/influxdb2
53
54 grafana:
55 image: grafana/grafana:latest
56 container_name: grafana
57 restart: unless-stopped
58 ports:
59 - "${GRAFANA_PORT:-3000}:3000"
60 environment:
61 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
62 volumes:
63 - grafana_data:/var/lib/grafana
64 depends_on:
65 - influxdb
66
67 zigbee2mqtt:
68 image: koenkk/zigbee2mqtt:latest
69 container_name: zigbee2mqtt
70 restart: unless-stopped
71 ports:
72 - "${Z2M_PORT:-8080}:8080"
73 volumes:
74 - ./zigbee2mqtt/data:/app/data
75 - /run/udev:/run/udev:ro
76 environment:
77 - TZ=${TZ:-UTC}
78 devices:
79 - /dev/ttyUSB0:/dev/ttyUSB0
80 depends_on:
81 - mosquitto
82
83volumes:
84 node_red_data:
85 influxdb_data:
86 grafana_data:
87EOF
88
89# 2. Create the .env file
90cat > .env << 'EOF'
91# Complete Home Automation Stack
92NODERED_PORT=1880
93INFLUXDB_PORT=8086
94GRAFANA_PORT=3000
95Z2M_PORT=8080
96TZ=America/New_York
97
98# InfluxDB
99INFLUX_USER=admin
100INFLUX_PASSWORD=adminpassword
101INFLUX_TOKEN=your-influxdb-token
102
103# Grafana
104GRAFANA_PASSWORD=admin
105EOF
106
107# 3. Start the services
108docker compose up -d
109
110# 4. View logs
111docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/complete-home-automation/run | bash

Troubleshooting

  • Home Assistant 'Recorder database is corrupt': Stop container, delete home-assistant.db from config volume, restart to rebuild database from scratch
  • Zigbee2MQTT 'Error: No such file or directory: /dev/ttyUSB0': Check USB device path with 'ls /dev/tty*' and update device mapping in compose file
  • InfluxDB connection refused from Grafana: Verify INFLUX_TOKEN environment variable matches between services and check InfluxDB initialization logs
  • Node-RED flows not triggering Home Assistant: Ensure Home Assistant Node-RED addon or companion nodes are installed and HA long-lived access token is configured
  • Mosquitto MQTT authentication failures: Create mosquitto.conf with 'allow_anonymous true' for testing, then implement proper authentication with password file
  • Grafana shows no data sources: Configure InfluxDB data source with proper URL 'http://influxdb:8086', organization 'home', and valid authentication token

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space