docker.recipes

Home Assistant Full Stack

intermediate

Home Assistant with MQTT, InfluxDB, and Grafana for home automation.

Overview

Home Assistant is an open-source home automation platform that puts local control and privacy first, integrating with over 2000 devices and services to create a unified smart home experience. Originally created in 2013 by Paulus Schoutsen, Home Assistant has grown into the most popular self-hosted home automation solution, emphasizing local processing and user privacy over cloud-dependent alternatives. This full stack combines Home Assistant with three essential data infrastructure components: Mosquitto MQTT broker for device communication, InfluxDB for time-series sensor data storage, and Grafana for advanced visualization and monitoring dashboards. Together, these components create a complete IoT data pipeline where MQTT handles real-time device messaging, InfluxDB stores historical sensor readings with high performance, and Grafana transforms raw data into actionable insights through customizable dashboards. This stack is ideal for serious smart home enthusiasts, IoT developers, and privacy-conscious users who want complete control over their home automation data. The combination provides enterprise-grade monitoring capabilities for residential use, enabling trend analysis, energy monitoring, predictive maintenance, and sophisticated automation rules based on historical patterns rather than just current sensor states.

Key Features

  • 2000+ device integrations including Zigbee, Z-Wave, WiFi, and proprietary protocols
  • High-performance time-series data storage with InfluxDB's purpose-built architecture
  • MQTT broker supporting both device communication and Home Assistant's internal messaging
  • 50+ Grafana data source plugins with rich visualization options for IoT dashboards
  • Local control and privacy with all data processing happening on-premises
  • Flux query language for complex time-series analysis and data correlations
  • Home Assistant's automation engine with state-based and time-based triggers
  • Energy management and monitoring with historical usage tracking and cost analysis

Common Use Cases

  • 1Comprehensive smart home monitoring with historical energy usage and environmental data analysis
  • 2IoT sensor network management for greenhouse automation, aquaponics, or hydroponic systems
  • 3Home security system with motion detection, door sensors, and camera integration with data retention
  • 4HVAC optimization using historical temperature patterns and occupancy data for automated scheduling
  • 5Solar panel and battery monitoring with production forecasting and grid tie-in management
  • 6Multi-property management for landlords monitoring multiple rental units remotely
  • 7Home lab environment monitoring tracking server temperatures, power consumption, and network performance

Prerequisites

  • Minimum 2GB RAM recommended for Home Assistant plus additional 1GB for InfluxDB and Grafana
  • Docker host with network access to smart home devices (may require host networking mode)
  • Available ports 8123 (Home Assistant), 1883 (MQTT), 3000 (Grafana), and 8086 (InfluxDB)
  • Basic understanding of YAML configuration for Home Assistant device setup and automation rules
  • Knowledge of time-series data concepts and InfluxDB bucket/retention policy configuration
  • Familiarity with Grafana dashboard creation and InfluxDB data source configuration

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 privileged: true
7 network_mode: host
8 volumes:
9 - ha_config:/config
10 - /etc/localtime:/etc/localtime:ro
11 depends_on:
12 - mosquitto
13 - influxdb
14
15 mosquitto:
16 image: eclipse-mosquitto:latest
17 container_name: mosquitto
18 restart: unless-stopped
19 ports:
20 - "${MQTT_PORT:-1883}:1883"
21 - "9001:9001"
22 volumes:
23 - mosquitto_data:/mosquitto/data
24 networks:
25 - ha-network
26
27 influxdb:
28 image: influxdb:2.7
29 container_name: influxdb
30 restart: unless-stopped
31 ports:
32 - "${INFLUX_PORT:-8086}:8086"
33 environment:
34 - DOCKER_INFLUXDB_INIT_MODE=setup
35 - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER:-admin}
36 - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD:-adminpassword}
37 - DOCKER_INFLUXDB_INIT_ORG=${INFLUX_ORG:-home}
38 - DOCKER_INFLUXDB_INIT_BUCKET=${INFLUX_BUCKET:-homeassistant}
39 volumes:
40 - influxdb_data:/var/lib/influxdb2
41 networks:
42 - ha-network
43
44 grafana:
45 image: grafana/grafana:latest
46 container_name: grafana
47 restart: unless-stopped
48 ports:
49 - "${GRAFANA_PORT:-3000}:3000"
50 environment:
51 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
52 volumes:
53 - grafana_data:/var/lib/grafana
54 depends_on:
55 - influxdb
56 networks:
57 - ha-network
58
59volumes:
60 ha_config:
61 mosquitto_data:
62 influxdb_data:
63 grafana_data:
64
65networks:
66 ha-network:
67 driver: bridge

.env Template

.env
1# Home Assistant Full Stack
2MQTT_PORT=1883
3INFLUX_PORT=8086
4INFLUX_USER=admin
5INFLUX_PASSWORD=adminpassword
6INFLUX_ORG=home
7INFLUX_BUCKET=homeassistant
8GRAFANA_PORT=3000
9GRAFANA_PASSWORD=admin

Usage Notes

  1. 1Home Assistant at http://localhost:8123
  2. 2Grafana at http://localhost:3000
  3. 3InfluxDB at http://localhost:8086
  4. 4Configure HA to send data to InfluxDB

Individual Services(4 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
  privileged: true
  network_mode: host
  volumes:
    - ha_config:/config
    - /etc/localtime:/etc/localtime:ro
  depends_on:
    - mosquitto
    - influxdb
mosquitto
mosquitto:
  image: eclipse-mosquitto:latest
  container_name: mosquitto
  restart: unless-stopped
  ports:
    - ${MQTT_PORT:-1883}:1883
    - "9001:9001"
  volumes:
    - mosquitto_data:/mosquitto/data
  networks:
    - ha-network
influxdb
influxdb:
  image: influxdb:2.7
  container_name: influxdb
  restart: unless-stopped
  ports:
    - ${INFLUX_PORT:-8086}:8086
  environment:
    - DOCKER_INFLUXDB_INIT_MODE=setup
    - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER:-admin}
    - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD:-adminpassword}
    - DOCKER_INFLUXDB_INIT_ORG=${INFLUX_ORG:-home}
    - DOCKER_INFLUXDB_INIT_BUCKET=${INFLUX_BUCKET:-homeassistant}
  volumes:
    - influxdb_data:/var/lib/influxdb2
  networks:
    - ha-network
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
  networks:
    - ha-network

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 privileged: true
9 network_mode: host
10 volumes:
11 - ha_config:/config
12 - /etc/localtime:/etc/localtime:ro
13 depends_on:
14 - mosquitto
15 - influxdb
16
17 mosquitto:
18 image: eclipse-mosquitto:latest
19 container_name: mosquitto
20 restart: unless-stopped
21 ports:
22 - "${MQTT_PORT:-1883}:1883"
23 - "9001:9001"
24 volumes:
25 - mosquitto_data:/mosquitto/data
26 networks:
27 - ha-network
28
29 influxdb:
30 image: influxdb:2.7
31 container_name: influxdb
32 restart: unless-stopped
33 ports:
34 - "${INFLUX_PORT:-8086}:8086"
35 environment:
36 - DOCKER_INFLUXDB_INIT_MODE=setup
37 - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUX_USER:-admin}
38 - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUX_PASSWORD:-adminpassword}
39 - DOCKER_INFLUXDB_INIT_ORG=${INFLUX_ORG:-home}
40 - DOCKER_INFLUXDB_INIT_BUCKET=${INFLUX_BUCKET:-homeassistant}
41 volumes:
42 - influxdb_data:/var/lib/influxdb2
43 networks:
44 - ha-network
45
46 grafana:
47 image: grafana/grafana:latest
48 container_name: grafana
49 restart: unless-stopped
50 ports:
51 - "${GRAFANA_PORT:-3000}:3000"
52 environment:
53 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}
54 volumes:
55 - grafana_data:/var/lib/grafana
56 depends_on:
57 - influxdb
58 networks:
59 - ha-network
60
61volumes:
62 ha_config:
63 mosquitto_data:
64 influxdb_data:
65 grafana_data:
66
67networks:
68 ha-network:
69 driver: bridge
70EOF
71
72# 2. Create the .env file
73cat > .env << 'EOF'
74# Home Assistant Full Stack
75MQTT_PORT=1883
76INFLUX_PORT=8086
77INFLUX_USER=admin
78INFLUX_PASSWORD=adminpassword
79INFLUX_ORG=home
80INFLUX_BUCKET=homeassistant
81GRAFANA_PORT=3000
82GRAFANA_PASSWORD=admin
83EOF
84
85# 3. Start the services
86docker compose up -d
87
88# 4. View logs
89docker 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/home-assistant-full/run | bash

Troubleshooting

  • Home Assistant shows 'Unable to connect to MQTT broker': Verify mosquitto container is running and MQTT integration uses correct broker IP address
  • InfluxDB connection fails with 'unauthorized access': Check DOCKER_INFLUXDB_INIT_USERNAME and password match Home Assistant InfluxDB integration credentials
  • Grafana shows 'InfluxDB connection error': Ensure InfluxDB data source URL uses container name 'influxdb:8086' and correct authentication token
  • Home Assistant devices not discovered: Run container in privileged mode with network_mode: host for proper device discovery
  • MQTT devices not responding: Check firewall rules allow port 1883 and verify MQTT device broker configuration points to correct IP
  • Grafana dashboards empty despite InfluxDB data: Verify Home Assistant InfluxDB integration includes desired entities and measurement names match Grafana queries

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