Home Assistant Full Stack
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:stable4 container_name: homeassistant5 restart: unless-stopped6 privileged: true7 network_mode: host8 volumes: 9 - ha_config:/config10 - /etc/localtime:/etc/localtime:ro11 depends_on: 12 - mosquitto13 - influxdb1415 mosquitto: 16 image: eclipse-mosquitto:latest17 container_name: mosquitto18 restart: unless-stopped19 ports: 20 - "${MQTT_PORT:-1883}:1883"21 - "9001:9001"22 volumes: 23 - mosquitto_data:/mosquitto/data24 networks: 25 - ha-network2627 influxdb: 28 image: influxdb:2.729 container_name: influxdb30 restart: unless-stopped31 ports: 32 - "${INFLUX_PORT:-8086}:8086"33 environment: 34 - DOCKER_INFLUXDB_INIT_MODE=setup35 - 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/influxdb241 networks: 42 - ha-network4344 grafana: 45 image: grafana/grafana:latest46 container_name: grafana47 restart: unless-stopped48 ports: 49 - "${GRAFANA_PORT:-3000}:3000"50 environment: 51 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}52 volumes: 53 - grafana_data:/var/lib/grafana54 depends_on: 55 - influxdb56 networks: 57 - ha-network5859volumes: 60 ha_config: 61 mosquitto_data: 62 influxdb_data: 63 grafana_data: 6465networks: 66 ha-network: 67 driver: bridge.env Template
.env
1# Home Assistant Full Stack2MQTT_PORT=18833INFLUX_PORT=80864INFLUX_USER=admin5INFLUX_PASSWORD=adminpassword6INFLUX_ORG=home7INFLUX_BUCKET=homeassistant8GRAFANA_PORT=30009GRAFANA_PASSWORD=adminUsage Notes
- 1Home Assistant at http://localhost:8123
- 2Grafana at http://localhost:3000
- 3InfluxDB at http://localhost:8086
- 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 file2cat > docker-compose.yml << 'EOF'3services:4 homeassistant:5 image: ghcr.io/home-assistant/home-assistant:stable6 container_name: homeassistant7 restart: unless-stopped8 privileged: true9 network_mode: host10 volumes:11 - ha_config:/config12 - /etc/localtime:/etc/localtime:ro13 depends_on:14 - mosquitto15 - influxdb1617 mosquitto:18 image: eclipse-mosquitto:latest19 container_name: mosquitto20 restart: unless-stopped21 ports:22 - "${MQTT_PORT:-1883}:1883"23 - "9001:9001"24 volumes:25 - mosquitto_data:/mosquitto/data26 networks:27 - ha-network2829 influxdb:30 image: influxdb:2.731 container_name: influxdb32 restart: unless-stopped33 ports:34 - "${INFLUX_PORT:-8086}:8086"35 environment:36 - DOCKER_INFLUXDB_INIT_MODE=setup37 - 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/influxdb243 networks:44 - ha-network4546 grafana:47 image: grafana/grafana:latest48 container_name: grafana49 restart: unless-stopped50 ports:51 - "${GRAFANA_PORT:-3000}:3000"52 environment:53 - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASSWORD:-admin}54 volumes:55 - grafana_data:/var/lib/grafana56 depends_on:57 - influxdb58 networks:59 - ha-network6061volumes:62 ha_config:63 mosquitto_data:64 influxdb_data:65 grafana_data:6667networks:68 ha-network:69 driver: bridge70EOF7172# 2. Create the .env file73cat > .env << 'EOF'74# Home Assistant Full Stack75MQTT_PORT=188376INFLUX_PORT=808677INFLUX_USER=admin78INFLUX_PASSWORD=adminpassword79INFLUX_ORG=home80INFLUX_BUCKET=homeassistant81GRAFANA_PORT=300082GRAFANA_PASSWORD=admin83EOF8485# 3. Start the services86docker compose up -d8788# 4. View logs89docker compose logs -fOne-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 | bashTroubleshooting
- 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
Components
home-assistantmosquittoinfluxdbgrafana
Tags
#home-assistant#iot#mqtt#smart-home#automation
Category
Home Lab & Self-HostingAd Space
Shortcuts: C CopyF FavoriteD Download