Home Assistant is a free and open-source home automation platform that runs on Python. It puts local control and privacy first, serving as a FOSS alternative to proprietary smart home platforms like Google Home, Amazon Alexa, Apple HomeKit, or Samsung SmartThings. Home Assistant supports over 2000 integrations and protocols for controlling smart home devices locally without requiring cloud connectivity.
FOSS Alternatives
Home Assistant is part of a rich ecosystem of free and open-source home automation solutions:
1. Prerequisites
Hardware Requirements
Operating System Requirements
Network Requirements
Dependencies
Required System Access
Domain/DNS Requirements (Optional)
2. Installation
RHEL/CentOS/Rocky Linux/AlmaLinux
#### Method 1: Core Installation (Recommended)
# Install EPEL repository for additional packages
sudo dnf install -y epel-release
# Install Python 3.11 and development tools
sudo dnf install -y python3.11 python3.11-pip python3.11-devel python3.11-venv \
gcc gcc-c++ make git curl wget \
systemd-devel libffi-devel openssl-devel \
bluez-libs-devel
# Create dedicated homeassistant user
sudo useradd -r -s /bin/bash -d /opt/homeassistant homeassistant
# Create installation directory
sudo mkdir -p /opt/homeassistant
sudo chown homeassistant:homeassistant /opt/homeassistant
# Switch to homeassistant user
sudo -u homeassistant -H -s
# Create and activate virtual environment
cd /opt/homeassistant
python3.11 -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
# Exit homeassistant user session
exit
#### Method 2: Supervised Installation
# Install Docker (required for Supervised)
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Start and enable Docker
sudo systemctl enable --now docker
# Install additional dependencies
sudo dnf install -y curl jq apparmor-utils systemd-journal-remote
# Download and install Home Assistant Supervised
curl -Lo installer.sh https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.sh
sudo bash installer.sh --machine qemux86-64
Debian/Ubuntu
#### Method 1: Core Installation (Recommended)
# Update package list
sudo apt update
# Install Python 3.11 and development tools
sudo apt install -y python3.11 python3.11-pip python3.11-dev python3.11-venv \
build-essential git curl wget \
libsystemd-dev libffi-dev libssl-dev \
bluetooth libbluetooth-dev
# Create dedicated homeassistant user
sudo useradd -r -s /bin/bash -d /opt/homeassistant homeassistant
# Create installation directory
sudo mkdir -p /opt/homeassistant
sudo chown homeassistant:homeassistant /opt/homeassistant
# Switch to homeassistant user
sudo -u homeassistant -H -s
# Create and activate virtual environment
cd /opt/homeassistant
python3.11 -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
# Exit homeassistant user session
exit
#### Method 2: Supervised Installation
# Install Docker
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
# Add Docker GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Add Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Install additional dependencies
sudo apt install -y jq curl apparmor systemd-journal-remote
# Download and install Home Assistant Supervised
curl -Lo installer.sh https://github.com/home-assistant/supervised-installer/releases/latest/download/homeassistant-supervised.sh
sudo bash installer.sh --machine qemux86-64
Arch Linux
# Update system
sudo pacman -Syu
# Install Python and development tools
sudo pacman -S python python-pip python-virtualenv \
base-devel git curl wget \
systemd libffi openssl \
bluez-libs
# Create dedicated homeassistant user
sudo useradd -r -s /bin/bash -d /opt/homeassistant homeassistant
# Create installation directory
sudo mkdir -p /opt/homeassistant
sudo chown homeassistant:homeassistant /opt/homeassistant
# Switch to homeassistant user
sudo -u homeassistant -H -s
# Create and activate virtual environment
cd /opt/homeassistant
python -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
# Exit homeassistant user session
exit
Alpine Linux
# Update package index
apk update
# Install Python and development tools
apk add --no-cache python3 py3-pip python3-dev \
build-base git curl wget \
systemd-dev libffi-dev openssl-dev \
bluez-dev linux-headers
# Create dedicated homeassistant user
adduser -D -s /bin/ash -h /opt/homeassistant homeassistant
# Create installation directory
mkdir -p /opt/homeassistant
chown homeassistant:homeassistant /opt/homeassistant
# Switch to homeassistant user
su - homeassistant
# Create and activate virtual environment
cd /opt/homeassistant
python3 -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
# Exit homeassistant user session
exit
openSUSE/SLES
# Install Python and development tools
sudo zypper install -y python311 python311-pip python311-devel python311-virtualenv \
gcc gcc-c++ make git curl wget \
systemd-devel libffi-devel libopenssl-devel \
bluez-devel
# Create dedicated homeassistant user
sudo useradd -r -s /bin/bash -d /opt/homeassistant homeassistant
# Create installation directory
sudo mkdir -p /opt/homeassistant
sudo chown homeassistant:homeassistant /opt/homeassistant
# Switch to homeassistant user
sudo -u homeassistant -H -s
# Create and activate virtual environment
cd /opt/homeassistant
python3.11 -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
# Exit homeassistant user session
exit
macOS
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Python 3.11
brew install python@3.11
# Create dedicated homeassistant user directory
sudo mkdir -p /opt/homeassistant
sudo chown $(whoami):staff /opt/homeassistant
# Create and activate virtual environment
cd /opt/homeassistant
python3.11 -m venv .
source bin/activate
# Upgrade pip and install wheel
python -m pip install --upgrade pip wheel
# Install Home Assistant
python -m pip install homeassistant
3. Configuration
Production Configuration Setup
#### Complete Home Assistant Configuration
# Create comprehensive configuration
sudo -u homeassistant tee /opt/homeassistant/.homeassistant/configuration.yaml << 'EOF'
# Home Assistant Production Configuration
homeassistant:
# Basic information
name: Smart Home
latitude: !secret home_latitude
longitude: !secret home_longitude
elevation: !secret home_elevation
unit_system: metric # or imperial
time_zone: America/New_York
currency: USD
country: US
# Customization
customize: !include customize.yaml
packages: !include_dir_named packages
allowlist_external_dirs:
- /tmp
- /backup
- /config/www
# Authentication providers
auth_providers:
- type: trusted_networks
trusted_networks:
- 192.168.1.0/24
- 10.0.0.0/24
allow_bypass_login: false
- type: homeassistant
# Security settings
auth_mfa_modules:
- type: totp
name: "Authenticator App"
- type: notify
include:
- notify.admin_devices
# HTTP Configuration with Security
http:
server_host: 0.0.0.0
server_port: 8123
ssl_certificate: /opt/homeassistant/.homeassistant/certificates/fullchain.pem
ssl_key: /opt/homeassistant/.homeassistant/certificates/privkey.pem
trusted_proxies:
- 127.0.0.1
- 192.168.1.1
- 10.0.0.1
use_x_forwarded_for: true
ip_ban_enabled: true
login_attempts_threshold: 5
cors_allowed_origins:
- https://cast.home-assistant.io
# Advanced Logging Configuration
logger:
default: warning
logs:
# Core components
homeassistant.core: info
homeassistant.setup: info
homeassistant.config: info
homeassistant.components.http: info
homeassistant.components.websocket_api: info
homeassistant.components.api: info
homeassistant.auth: info
# Automation and scripts
homeassistant.components.automation: debug
homeassistant.components.script: debug
homeassistant.components.scene: debug
# Integration specific
homeassistant.components.mqtt: info
homeassistant.components.zwave: info
homeassistant.components.zigbee: info
homeassistant.components.bluetooth: info
# Suppress verbose logging
homeassistant.helpers.entity: warning
homeassistant.loader: warning
# Custom components
custom_components: debug
# Database Configuration with Performance Optimization
recorder:
db_url: !secret db_url # Use external database for production
db_retry_wait: 10
purge_keep_days: 30
commit_interval: 5
exclude:
domains:
- automation
- updater
- camera
- media_player
- group
- scene
entity_globs:
- sensor.weather_*
- sensor.*_battery_level
- sensor.*_link_quality
entities:
- sun.sun
- sensor.date
- sensor.time
event_types:
- call_service
- component_loaded
- platform_discovered
- service_registered
include:
domains:
- switch
- light
- binary_sensor
- climate
- cover
- lock
entities:
- sensor.temperature_*
- sensor.humidity_*
- sensor.power_*
# History Configuration
history:
use_include_order: true
exclude:
domains:
- automation
- updater
- camera
include:
domains:
- sensor
- switch
- light
- binary_sensor
# InfluxDB for Long-term Statistics
influxdb:
host: !secret influxdb_host
port: 8086
database: homeassistant
username: !secret influxdb_username
password: !secret influxdb_password
ssl: true
verify_ssl: true
max_retries: 3
default_measurement: state
exclude:
domains:
- automation
- group
include:
domains:
- sensor
- binary_sensor
- switch
component_config_glob:
sensor.*temperature*:
override_measurement: temperature
sensor.*humidity*:
override_measurement: humidity
# System Health Monitoring
system_health:
system_log:
max_entries: 50
# Frontend Configuration
frontend:
themes: !include_dir_merge_named themes
extra_module_url:
- /local/custom-cards.js
lovelace:
mode: storage
dashboards:
admin-dashboard:
mode: yaml
title: Admin
icon: mdi:shield
show_in_sidebar: true
filename: dashboards/admin.yaml
require_admin: true
# Mobile App Support
mobile_app:
default_config:
# Cloud Integration (optional)
# cloud:
# alexa:
# filter:
# include_entities:
# - light.living_room
# - switch.bedroom
# google_actions:
# filter:
# include_domains:
# - light
# - switch
# MQTT Configuration
mqtt:
broker: !secret mqtt_broker
port: 8883
username: !secret mqtt_username
password: !secret mqtt_password
certificate: /opt/homeassistant/.homeassistant/certificates/ca.crt
tls_insecure: false
protocol: 3.1.1
keepalive: 60
discovery: true
discovery_prefix: homeassistant
birth_message:
topic: 'homeassistant/status'
payload: 'online'
qos: 1
retain: true
will_message:
topic: 'homeassistant/status'
payload: 'offline'
qos: 1
retain: true
# Z-Wave Configuration
zwave:
usb_path: /dev/ttyUSB0
network_key: !secret zwave_network_key
config_path: /opt/homeassistant/.homeassistant/zwcfg/
polling_interval: 60000
device_config: !include zwave_device_config.yaml
# Zigbee Configuration
zha:
usb_path: /dev/ttyUSB1
database_path: /opt/homeassistant/.homeassistant/zigbee.db
enable_quirks: true
custom_quirks_path: /opt/homeassistant/.homeassistant/custom_zha_quirks/
# Notification Configuration
notify:
- platform: smtp
name: email_admin
server: !secret smtp_server
port: 587
encryption: starttls
username: !secret smtp_username
password: !secret smtp_password
sender: !secret smtp_sender
recipient: !secret admin_email
- platform: pushbullet
name: pushbullet_admin
api_key: !secret pushbullet_api_key
# Backup Configuration
backup:
auto_purge: true
password: !secret backup_password
# Prometheus Metrics Export
prometheus:
namespace: hass
component_config_glob:
sensor.*temperature*:
override_metric: temperature_celsius
sensor.*humidity*:
override_metric: humidity_percent
filter:
include_domains:
- sensor
- binary_sensor
- switch
- light
# Stream Configuration
stream:
ll_hls: true
part_duration: 0.75
segment_duration: 6
# Media Configuration
media_source:
media_extractor:
# Text-to-Speech
tts:
- platform: google_translate
cache: true
cache_dir: /tmp/tts
time_memory: 57600
service_name: google_say
# Weather
weather:
- platform: openweathermap
api_key: !secret openweather_api_key
# Device Tracking
device_tracker:
- platform: nmap_tracker
hosts:
- 192.168.1.0/24
home_interval: 10
consider_home: 180
interval_seconds: 30
track_new_devices: true
# Scenes
scene: !include scenes.yaml
# Groups
group: !include groups.yaml
# Automations
automation: !include automations.yaml
# Scripts
script: !include scripts.yaml
# Zones
zone: !include zones.yaml
# Sensors
sensor: !include_dir_merge_list sensors/
# Binary Sensors
binary_sensor: !include_dir_merge_list binary_sensors/
# Switches
switch: !include_dir_merge_list switches/
# Lights
light: !include_dir_merge_list lights/
# Input Boolean/Number/Select/Text/Datetime
input_boolean: !include input_boolean.yaml
input_number: !include input_number.yaml
input_select: !include input_select.yaml
input_text: !include input_text.yaml
input_datetime: !include input_datetime.yaml
# Timers and Counters
timer: !include timers.yaml
counter: !include counters.yaml
# Utility Meter
utility_meter: !include utility_meter.yaml
# REST Commands
rest_command: !include rest_commands.yaml
# Shell Commands
shell_command: !include shell_commands.yaml
# Panel Configuration
panel_iframe:
configurator:
title: Configurator
icon: mdi:wrench
url: https://homeassistant.local:3218
require_admin: true
grafana:
title: Grafana
icon: mdi:chart-timeline
url: https://grafana.local:3000
require_admin: false
EOF
#### Secrets Configuration
# Create secrets file with sensitive information
sudo -u homeassistant tee /opt/homeassistant/.homeassistant/secrets.yaml << 'EOF'
# Location secrets
home_latitude: 40.7128
home_longitude: -74.0060
home_elevation: 10
# Database
db_url: postgresql://homeassistant:HA_DB_Pass_2024!@localhost/homeassistant
# InfluxDB
influxdb_host: localhost
influxdb_username: homeassistant
influxdb_password: InfluxDB_Pass_2024!
# MQTT
mqtt_broker: localhost
mqtt_username: homeassistant
mqtt_password: MQTT_Pass_2024!
# Z-Wave
zwave_network_key: "0x2e, 0xcc, 0xab, 0x1c, 0xa3, 0x7f, 0x0e, 0xb5, 0x70, 0x71, 0x2d, 0x98, 0x25, 0x43, 0xee, 0x0c"
# Email
smtp_server: smtp.gmail.com
smtp_username: your_email@gmail.com
smtp_password: App_Specific_Password
smtp_sender: your_email@gmail.com
admin_email: admin@example.com
# API Keys
openweather_api_key: your_openweather_api_key
pushbullet_api_key: your_pushbullet_api_key
# Backup
backup_password: Backup_Encryption_Pass_2024!
EOF
# Set proper permissions
sudo chmod 600 /opt/homeassistant/.homeassistant/secrets.yaml
sudo chown homeassistant:homeassistant /opt/homeassistant/.homeassistant/secrets.yaml
#### Advanced Security Configuration
# Create advanced security configuration
sudo -u homeassistant tee /opt/homeassistant/.homeassistant/packages/security.yaml << 'EOF'
# Security Package Configuration
# Failed Login Notification
automation:
- alias: "Security: Notify Failed Login Attempts"
trigger:
- platform: state
entity_id: persistent_notification.http_login
condition:
- condition: template
value_template: "{{ 'invalid authentication' in trigger.to_state.state|lower }}"
action:
- service: notify.email_admin
data:
title: "Security Alert: Failed Login Attempt"
message: |
Failed login attempt detected:
{{ trigger.to_state.attributes.message }}
Time: {{ now() }}
- service: persistent_notification.create
data:
title: "Security Alert"
message: "Failed login attempt detected. Check logs for details."
notification_id: security_alert
- alias: "Security: Lock Down After Multiple Failed Attempts"
trigger:
- platform: template
value_template: "{{ states('sensor.failed_login_attempts')|int > 10 }}"
action:
- service: homeassistant.turn_on
entity_id: input_boolean.lockdown_mode
- service: notify.pushbullet_admin
data:
title: "CRITICAL: System Lockdown"
message: "More than 10 failed login attempts. System entering lockdown mode."
- alias: "Security: Daily Security Report"
trigger:
- platform: time
at: "23:00:00"
action:
- service: notify.email_admin
data:
title: "Daily Security Report"
message: |
Daily Security Summary:
- Failed Login Attempts: {{ states('sensor.failed_login_attempts') }}
- Successful Logins: {{ states('sensor.successful_logins') }}
- New Devices: {{ states('sensor.new_devices_today') }}
- System Uptime: {{ states('sensor.uptime') }}
- SSL Certificate Expiry: {{ states('sensor.ssl_cert_expiry') }} days
# Security Sensors
sensor:
- platform: command_line
name: SSL Certificate Expiry
unit_of_measurement: days
scan_interval: 86400
command: "echo $(( ($(date -d \"$(openssl x509 -in /opt/homeassistant/.homeassistant/certificates/fullchain.pem -noout -enddate | cut -d= -f2)\" +%s) - $(date +%s)) / 86400 ))"
- platform: file
name: Failed Login Attempts
file_path: /opt/homeassistant/.homeassistant/home-assistant.log
value_template: "{{ value.count('Login attempt') }}"
- platform: uptime
name: System Uptime
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /
- type: memory_use_percent
- type: processor_use
- type: load_1m
- type: load_5m
- type: load_15m
# Security Input Booleans
input_boolean:
lockdown_mode:
name: Lockdown Mode
initial: off
icon: mdi:shield-lock
vacation_mode:
name: Vacation Mode
initial: off
icon: mdi:beach
guest_mode:
name: Guest Mode
initial: off
icon: mdi:account-multiple
# Security Scripts
script:
emergency_lockdown:
alias: "Emergency Lockdown"
sequence:
- service: input_boolean.turn_on
entity_id: input_boolean.lockdown_mode
- service: lock.lock
entity_id: all
- service: alarm_control_panel.alarm_arm_away
entity_id: alarm_control_panel.home_alarm
- service: notify.all
data:
title: "EMERGENCY LOCKDOWN ACTIVATED"
message: "All locks secured. Alarm armed. Notifications sent."
security_check:
alias: "Security Check"
sequence:
- service: script.check_all_locks
- service: script.check_all_windows
- service: script.check_cameras
- service: notify.email_admin
data:
title: "Security Check Complete"
message: "All security systems checked and verified."
# Binary Sensors for Security
binary_sensor:
- platform: template
sensors:
security_status:
friendly_name: "Security Status"
device_class: safety
value_template: |
{{ is_state('input_boolean.lockdown_mode', 'off')
and is_state('binary_sensor.all_doors', 'off')
and is_state('binary_sensor.all_windows', 'off') }}
all_doors:
friendly_name: "All Doors"
device_class: door
value_template: "{{ is_state('group.all_doors', 'on') }}"
all_windows:
friendly_name: "All Windows"
device_class: window
value_template: "{{ is_state('group.all_windows', 'on') }}"
EOF
#### Nginx Reverse Proxy Configuration
# Create Nginx configuration for Home Assistant
sudo tee /etc/nginx/sites-available/homeassistant << 'EOF'
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Rate limiting
limit_req_zone $binary_remote_addr zone=ha_limit:10m rate=10r/s;
server {
listen 80;
listen [::]:80;
server_name homeassistant.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name homeassistant.example.com;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/homeassistant.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/homeassistant.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_stapling on;
ssl_stapling_verify on;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "strict-origin-when-cross-origin";
# Rate limiting
limit_req zone=ha_limit burst=20 nodelay;
# Proxy settings
proxy_buffering off;
location / {
proxy_pass http://127.0.0.1:8123;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location /api/websocket {
proxy_pass http://127.0.0.1:8123/api/websocket;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# Media files
location /media {
proxy_pass http://127.0.0.1:8123;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_max_temp_file_size 0;
client_max_body_size 100M;
}
}
EOF
sudo ln -s /etc/nginx/sites-available/homeassistant /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
#### Database Optimization
# Create PostgreSQL database for better performance
sudo -u postgres psql << EOF
CREATE USER homeassistant WITH PASSWORD 'HA_DB_Pass_2024!';
CREATE DATABASE homeassistant OWNER homeassistant;
GRANT ALL PRIVILEGES ON DATABASE homeassistant TO homeassistant;
EOF
# Create database maintenance script
sudo tee /opt/homeassistant/db-maintenance.sh << 'EOF'
#!/bin/bash
# Home Assistant Database Maintenance Script
# Vacuum and analyze PostgreSQL database
psql -U homeassistant -d homeassistant -c "VACUUM ANALYZE;"
# Reindex database
psql -U homeassistant -d homeassistant -c "REINDEX DATABASE homeassistant;"
# Clean old statistics
psql -U homeassistant -d homeassistant -c "DELETE FROM statistics WHERE created < NOW() - INTERVAL '90 days';"
# Clean old events
psql -U homeassistant -d homeassistant -c "DELETE FROM events WHERE time_fired < NOW() - INTERVAL '30 days';"
echo "Database maintenance completed at $(date)"
EOF
sudo chmod +x /opt/homeassistant/db-maintenance.sh
# Add to crontab for weekly maintenance
(crontab -l 2>/dev/null; echo "0 3 * * 0 /opt/homeassistant/db-maintenance.sh >> /var/log/homeassistant/db-maintenance.log 2>&1") | crontab -
Custom Components Configuration
# Create directory structure for custom components
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/custom_components
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/www
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/packages
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/themes
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/dashboards
sudo -u homeassistant mkdir -p /opt/homeassistant/.homeassistant/certificates
# Set proper permissions
sudo chmod -R 755 /opt/homeassistant/.homeassistant/
sudo chmod 700 /opt/homeassistant/.homeassistant/certificates
4. Service Management
systemd (RHEL, Debian, Arch, SUSE)
# Create systemd service file
sudo tee /etc/systemd/system/homeassistant.service > /dev/null <<EOF
[Unit]
Description=Home Assistant
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=homeassistant
Group=homeassistant
WorkingDirectory=/opt/homeassistant
ExecStart=/opt/homeassistant/bin/hass -c "/opt/homeassistant/.homeassistant"
RestartForceExitStatus=100
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd and enable service
sudo systemctl daemon-reload
sudo systemctl enable homeassistant.service
# Service management commands
sudo systemctl start homeassistant # Start service
sudo systemctl stop homeassistant # Stop service
sudo systemctl restart homeassistant # Restart service
sudo systemctl status homeassistant # Check status
sudo journalctl -u homeassistant -f # View logs
OpenRC (Alpine)
# Create OpenRC service file
sudo tee /etc/init.d/homeassistant > /dev/null <<'EOF'
#!/sbin/openrc-run
name="Home Assistant"
description="Open source home automation"
user="homeassistant"
group="homeassistant"
pidfile="/var/run/homeassistant.pid"
command="/opt/homeassistant/bin/hass"
command_args="-c /opt/homeassistant/.homeassistant --pid-file ${pidfile} --daemon"
command_background="yes"
depend() {
need net
after firewall
}
EOF
# Make executable and enable
sudo chmod +x /etc/init.d/homeassistant
sudo rc-update add homeassistant
# Service management commands
sudo service homeassistant start # Start service
sudo service homeassistant stop # Stop service
sudo service homeassistant restart # Restart service
sudo service homeassistant status # Check status
launchd (macOS)
# Create launchd plist file
sudo tee /Library/LaunchDaemons/io.homeassistant.plist > /dev/null <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>io.homeassistant</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homeassistant/bin/hass</string>
<string>-c</string>
<string>/opt/homeassistant/.homeassistant</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardErrorPath</key>
<string>/opt/homeassistant/homeassistant.log</string>
<key>StandardOutPath</key>
<string>/opt/homeassistant/homeassistant.log</string>
</dict>
</plist>
EOF
# Load and start service
sudo launchctl load /Library/LaunchDaemons/io.homeassistant.plist
sudo launchctl start io.homeassistant
# Service management commands
sudo launchctl start io.homeassistant # Start service
sudo launchctl stop io.homeassistant # Stop service
sudo launchctl unload /Library/LaunchDaemons/io.homeassistant.plist # Disable
Advanced Configuration
#### Configuration File Syntax
Home Assistant uses YAML for configuration. Key concepts:
# Basic syntax
key: value
key_with_list:
- item1
- item2
key_with_dict:
subkey: value
# Including other files
group: !include groups.yaml
automation: !include_dir_list automations/
script: !include_dir_named scripts/
# Using secrets
api_key: !secret weather_api_key
#### Environment Variables
# Set environment variables for Home Assistant
export HASS_SERVER_HOST=0.0.0.0
export HASS_SERVER_PORT=8123
# Add to ~/.bashrc or systemd service file
Environment=HASS_SERVER_HOST=0.0.0.0
Environment=HASS_SERVER_PORT=8123
#### Command-line Parameters
# Common command-line options
hass -c /path/to/config # Specify config directory
hass --script check_config # Check configuration
hass --script ensure_config # Create default config
hass --open-ui # Open web interface after start
hass --debug # Enable debug logging
hass --daemon # Run as daemon
hass --pid-file /var/run/hass.pid # Specify PID file
#### Integration with Other Services
MQTT Integration:
# Add to configuration.yaml
mqtt:
broker: localhost
port: 1883
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
Zigbee Integration (zigbee2mqtt):
# Add to configuration.yaml
mqtt:
broker: localhost
port: 1883
discovery: true
discovery_prefix: homeassistant
# zigbee2mqtt will automatically create devices
Z-Wave Integration:
# Add to configuration.yaml (for Z-Wave JS)
zwave_js:
url: "ws://localhost:3000"
5. Troubleshooting
Installation Issues
Python version conflicts:
# Check Python version
python3 --version
# Should be 3.10 or later
# If wrong version, install correct Python
sudo dnf install python3.11 # RHEL/CentOS
sudo apt install python3.11 # Debian/Ubuntu
Missing development packages:
# Install missing development tools
sudo dnf groupinstall "Development Tools" # RHEL/CentOS
sudo apt install build-essential # Debian/Ubuntu
Permission errors during pip install:
# Ensure you're in the virtual environment
source /opt/homeassistant/bin/activate
# Check virtual environment is active
which python
# Should show: /opt/homeassistant/bin/python
Service Issues
Service fails to start:
# Check service status
sudo systemctl status homeassistant
# Check logs
sudo journalctl -u homeassistant -f
# Common issues:
# 1. Configuration errors
# 2. Port already in use
# 3. Permission problems
Configuration validation:
# Check configuration syntax
sudo -u homeassistant -H -s
cd /opt/homeassistant
source bin/activate
hass --script check_config -c .homeassistant
Port conflicts:
# Check what's using port 8123
sudo netstat -tlnp | grep 8123
sudo lsof -i :8123
# Kill conflicting process or change port in configuration.yaml
Permission Issues
File permission issues:
# Fix ownership
sudo chown -R homeassistant:homeassistant /opt/homeassistant
# Fix permissions
sudo chmod -R 755 /opt/homeassistant
sudo chmod -R 644 /opt/homeassistant/.homeassistant/*.yaml
SELinux context issues (RHEL/CentOS):
# Check SELinux status
sestatus
# Fix SELinux contexts
sudo restorecon -Rv /opt/homeassistant
sudo setsebool -P httpd_can_network_connect 1
Network Issues
Web interface not accessible:
# Check if service is running
sudo systemctl status homeassistant
# Check listening ports
sudo netstat -tlnp | grep python
# Check firewall
sudo firewall-cmd --list-all # RHEL/CentOS
sudo ufw status # Ubuntu/Debian
mDNS discovery not working:
# Install and start Avahi
sudo dnf install avahi avahi-tools # RHEL/CentOS
sudo apt install avahi-daemon avahi-utils # Debian/Ubuntu
sudo systemctl enable --now avahi-daemon
# Test mDNS
avahi-browse -r _http._tcp
Debug Configuration
# Enable debug logging
# Edit configuration.yaml
logger:
default: debug
logs:
homeassistant.core: debug
homeassistant.components: debug
# Restart Home Assistant
sudo systemctl restart homeassistant
# Monitor logs
sudo journalctl -u homeassistant -f
Log Management
# Common log locations
tail -f /opt/homeassistant/.homeassistant/home-assistant.log
# Filter specific components
grep "ERROR" /opt/homeassistant/.homeassistant/home-assistant.log
grep "WARNING" /opt/homeassistant/.homeassistant/home-assistant.log
# Check startup issues
sudo journalctl -u homeassistant --since "10 minutes ago"
6. Security Considerations
Authentication and Access Control
# Add to configuration.yaml
homeassistant:
auth_providers:
- type: homeassistant
- type: trusted_networks
trusted_networks:
- 192.168.1.0/24
- 127.0.0.1
trusted_users:
192.168.1.0/24:
- user_id_here
SSL/TLS Configuration
# Add to configuration.yaml
http:
ssl_certificate: /etc/ssl/certs/homeassistant.crt
ssl_key: /etc/ssl/private/homeassistant.key
ssl_profile: modern
server_port: 8123
cors_allowed_origins:
- https://cast.home-assistant.io
Firewall Configuration
#### firewalld (RHEL/CentOS/Fedora)
# Allow Home Assistant port
sudo firewall-cmd --permanent --add-port=8123/tcp
sudo firewall-cmd --reload
# Create custom service
sudo tee /etc/firewalld/services/homeassistant.xml > /dev/null <<EOF
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Home Assistant</short>
<description>Home Assistant automation platform</description>
<port protocol="tcp" port="8123"/>
<port protocol="udp" port="5353"/>
</service>
EOF
sudo firewall-cmd --reload
sudo firewall-cmd --permanent --add-service=homeassistant
sudo firewall-cmd --reload
#### ufw (Ubuntu/Debian)
# Allow Home Assistant ports
sudo ufw allow 8123/tcp comment 'Home Assistant'
sudo ufw allow 5353/udp comment 'mDNS'
# Enable firewall
sudo ufw enable
#### iptables
# Add rules for Home Assistant
sudo iptables -A INPUT -p tcp --dport 8123 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 5353 -j ACCEPT
# Save rules (command varies by distribution)
sudo iptables-save > /etc/iptables/rules.v4 # Debian/Ubuntu
sudo service iptables save # RHEL/CentOS
SELinux Configuration (RHEL/CentOS/Fedora)
# Allow Home Assistant to bind to port 8123
sudo setsebool -P httpd_can_network_connect 1
# Create custom SELinux policy if needed
sudo ausearch -c 'hass' --raw | audit2allow -M homeassistant
sudo semodule -i homeassistant.pp
Security Best Practices
# Add to configuration.yaml
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
- ::1
ip_ban_enabled: true
login_attempts_threshold: 5
# Enable additional security features
logger:
default: warning
logs:
homeassistant.components.http.ban: warning
Reverse Proxy Setup
#### nginx Configuration
# /etc/nginx/sites-available/homeassistant
server {
listen 80;
server_name homeassistant.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name homeassistant.example.com;
ssl_certificate /etc/ssl/certs/homeassistant.crt;
ssl_certificate_key /etc/ssl/private/homeassistant.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384;
location / {
proxy_pass http://127.0.0.1:8123;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
}
}
#### Apache Configuration
# /etc/apache2/sites-available/homeassistant.conf
<VirtualHost *:80>
ServerName homeassistant.example.com
Redirect permanent / https://homeassistant.example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName homeassistant.example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/homeassistant.crt
SSLCertificateKeyFile /etc/ssl/private/homeassistant.key
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
ProxyPreserveHost On
ProxyRequests Off
ProxyPass / http://127.0.0.1:8123/
ProxyPassReverse / http://127.0.0.1:8123/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:8123/$1" [P,L]
</VirtualHost>
API Token Management
# Create long-lived access tokens in Home Assistant UI
# Navigate to Profile -> Long-Lived Access Tokens
# Use in external applications
Authorization: Bearer YOUR_LONG_LIVED_ACCESS_TOKEN
7. Performance Tuning
Resource Optimization
# configuration.yaml
recorder:
purge_keep_days: 3 # Reduce database size
auto_purge: true
commit_interval: 1
exclude:
domains:
- automation
- updater
entity_globs:
- sensor.weather_*
# Reduce logging
logger:
default: warning
# Optimize frontend
frontend:
javascript_version: latest
Database Optimization
#### SQLite (Default)
# configuration.yaml
recorder:
db_url: sqlite:////opt/homeassistant/.homeassistant/home-assistant_v2.db
purge_keep_days: 7
auto_purge: true
#### PostgreSQL
# Install PostgreSQL
sudo dnf install -y postgresql postgresql-server # RHEL/CentOS
sudo apt install -y postgresql postgresql-contrib # Debian/Ubuntu
# Initialize and start PostgreSQL
sudo postgresql-setup --initdb # RHEL/CentOS
sudo systemctl enable --now postgresql
# Create database and user
sudo -u postgres psql <<EOF
CREATE DATABASE homeassistant;
CREATE USER hass WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE homeassistant TO hass;
\q
EOF
# configuration.yaml
recorder:
db_url: postgresql://hass:secure_password@localhost/homeassistant
purge_keep_days: 7
auto_purge: true
Memory and CPU Optimization
# For Raspberry Pi - increase swap
sudo dphys-swapfile swapoff
sudo sed -i 's/CONF_SWAPSIZE=100/CONF_SWAPSIZE=1024/' /etc/dphys-swapfile
sudo dphys-swapfile setup
sudo dphys-swapfile swapon
# Add to /boot/config.txt
gpu_mem=16
disable_overscan=1
Caching Configuration
# Enable caching for better performance
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
# Cache static files
frontend:
themes: !include_dir_merge_named themes
extra_module_url:
- /local/my-custom-card.js?v=1
Monitoring and Metrics
# Add to configuration.yaml
system_health:
# Enable system monitor
sensor:
- platform: systemmonitor
resources:
- type: disk_use_percent
arg: /opt/homeassistant
- type: memory_use_percent
- type: processor_use
- type: last_boot
# Enable Prometheus metrics
prometheus:
namespace: hass
8. Backup and Restore
What to Backup
Essential files and directories:
/opt/homeassistant/.homeassistant/ (entire config directory)Backup Scripts
#!/bin/bash
# /usr/local/bin/homeassistant-backup.sh
BACKUP_DIR="/backup/homeassistant"
CONFIG_DIR="/opt/homeassistant/.homeassistant"
DATE=$(date +%Y%m%d_%H%M%S)
# Create backup directory
mkdir -p "$BACKUP_DIR"
# Stop Home Assistant
sudo systemctl stop homeassistant
# Create backup
tar -czf "$BACKUP_DIR/homeassistant_backup_$DATE.tar.gz" \
-C "/opt/homeassistant" ".homeassistant"
# Start Home Assistant
sudo systemctl start homeassistant
# Keep only last 7 backups
find "$BACKUP_DIR" -name "homeassistant_backup_*.tar.gz" -mtime +7 -delete
echo "Backup completed: homeassistant_backup_$DATE.tar.gz"
Restore Procedures
#!/bin/bash
# Restore Home Assistant from backup
BACKUP_FILE="/backup/homeassistant/homeassistant_backup_20250923_120000.tar.gz"
CONFIG_DIR="/opt/homeassistant/.homeassistant"
# Stop Home Assistant
sudo systemctl stop homeassistant
# Backup current config (safety)
sudo mv "$CONFIG_DIR" "${CONFIG_DIR}.$(date +%Y%m%d_%H%M%S)"
# Restore from backup
sudo tar -xzf "$BACKUP_FILE" -C "/opt/homeassistant"
# Fix permissions
sudo chown -R homeassistant:homeassistant "$CONFIG_DIR"
# Start Home Assistant
sudo systemctl start homeassistant
echo "Restore completed from $BACKUP_FILE"
Automated Backup Setup
# Add to crontab for automated daily backups
sudo crontab -e
# Add this line for daily backups at 2 AM
0 2 * * * /usr/local/bin/homeassistant-backup.sh >> /var/log/homeassistant-backup.log 2>&1
Testing Restore Procedures
# Test restore on separate system
# 1. Install Home Assistant on test system
# 2. Stop service
# 3. Replace config with backup
# 4. Start service and verify functionality
# 5. Test automations and integrations
# Verify backup integrity
tar -tzf /backup/homeassistant/homeassistant_backup_latest.tar.gz | head -20
9. System Requirements
Minimum Hardware Requirements
CPU: Dual-core processor (ARM or x86)
Memory (RAM):
Storage:
Network:
Operating System Compatibility
Officially Supported:
Secondary Support:
Software Dependencies
Python Requirements:
System Libraries:
Optional Dependencies:
Performance Scaling
Small Installation (1-50 devices):
Medium Installation (50-200 devices):
Large Installation (200+ devices):
10. Support
Official Resources
Documentation and Help:
Development and Source:
Community Support
Forums and Communities:
Learning Resources:
Commercial Support
Professional Services:
Training and Certification:
Getting Help
Before Seeking Help:
1. Check the official documentation
2. Search the community forum
3. Review GitHub issues
4. Verify your configuration with hass --script check_config
When Reporting Issues:
hass --version)Response Expectations:
11. Contributing
Ways to Contribute
Code Contributions:
Community Contributions:
Development Setup
Preparation:
# Fork the repository on GitHub
# Clone your fork locally
git clone https://github.com/YOUR_USERNAME/core.git
cd core
# Set up development environment
python3 -m venv venv
source venv/bin/activate
pip install -e .
Code Standards:
Testing:
# Run specific tests
pytest tests/components/your_integration/
# Run all tests (time-consuming)
pytest
# Check code style
black --check homeassistant/
pylint homeassistant/
Submitting Contributions
Pull Request Process:
1. Create a feature branch from dev
2. Make your changes with clear commit messages
3. Add tests for new functionality
4. Update documentation as needed
5. Submit pull request with detailed description
Review Process:
Integration Development:
Documentation Contributions
Types of Documentation:
Documentation Guidelines:
Recognition
Contributor Recognition:
12. License
Home Assistant Software License
Apache License 2.0:
Home Assistant Core is released under the Apache License 2.0, which permits:
License Requirements:
Related Component Licenses
Core Dependencies:
Integration-Specific Licenses:
This Guide License
MIT License:
This installation guide is licensed under the MIT License:
MIT License
Copyright (c) 2025 HowToMgr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Third-Party Licenses
Hardware Drivers:
Cloud Service Integration:
License Compliance
For Distributions:
For Commercial Use:
13. Acknowledgments
Core Development Team
Founding and Leadership:
Major Contributors:
Community Recognition
Integration Developers:
Community Support:
Technology Acknowledgments
Core Technologies:
Frontend Technologies:
Hardware Ecosystem
Supported Protocols:
Hardware Partners:
Special Thanks
Nabu Casa:
Community Infrastructure:
Open Source Projects:
Recognition Programs
Annual Awards:
This project stands on the shoulders of giants in the open source community, and we are grateful for all contributions, large and small, that make Home Assistant possible.
14. Version History
Release Timeline
Major Releases:
2025.x Series (Current)
2024.x Series
2023.x Series
2022.x Series
2021.x Series
Breaking Changes History
Recent Breaking Changes:
Migration Guidelines:
Installation Guide Versions
This Guide Version History:
v1.0.0 (2025-09-23)
Previous Versions:
Compatibility Matrix
Python Versions:
Operating System Support:
Future Roadmap
Planned Enhancements:
Community Requested Features:
Deprecation Schedule
Planned Deprecations:
End-of-Life Support:
15. Maintenance
Update Procedures
Update Home Assistant Core:
# Switch to homeassistant user
sudo -u homeassistant -H -s
cd /opt/homeassistant
source bin/activate
# Update pip and Home Assistant
python -m pip install --upgrade pip
python -m pip install --upgrade homeassistant
# Check for breaking changes before updating
# Visit: https://www.home-assistant.io/blog/categories/release-notes/
# Restart service
sudo systemctl restart homeassistant
Update Python dependencies:
# Update all packages
python -m pip list --outdated
python -m pip install --upgrade package_name
# Or update all at once (use with caution)
python -m pip freeze | cut -d'=' -f1 | xargs python -m pip install --upgrade
Version Upgrades
Major version upgrades:
# Before upgrading, always backup
/usr/local/bin/homeassistant-backup.sh
# Check breaking changes
# Visit release notes at: https://www.home-assistant.io/blog/
# Perform upgrade
sudo -u homeassistant -H -s
cd /opt/homeassistant
source bin/activate
python -m pip install --upgrade homeassistant
# Check configuration after upgrade
hass --script check_config -c .homeassistant
# Restart service
sudo systemctl restart homeassistant
Migration Between Systems
Export configuration:
# Create migration package
tar -czf homeassistant_migration.tar.gz \
-C /opt/homeassistant .homeassistant \
--exclude=.homeassistant/home-assistant.log \
--exclude=.homeassistant/home-assistant_v2.db
# Copy SSL certificates if used
tar -czf ssl_certs.tar.gz /etc/ssl/private/homeassistant.*
Import on new system:
# Install Home Assistant on new system
# Stop service
sudo systemctl stop homeassistant
# Extract configuration
sudo tar -xzf homeassistant_migration.tar.gz -C /opt/homeassistant
sudo chown -R homeassistant:homeassistant /opt/homeassistant/.homeassistant
# Update IP addresses and device paths in configuration
sudo -u homeassistant nano /opt/homeassistant/.homeassistant/configuration.yaml
# Start service
sudo systemctl start homeassistant
Cleanup Procedures
Database cleanup:
# Enable database purging
# Add to configuration.yaml
recorder:
purge_keep_days: 7
auto_purge: true
# Manual purge
sudo -u homeassistant -H -s
cd /opt/homeassistant
source bin/activate
hass --script purge_db --days 30
Log rotation:
# Configure logrotate
sudo tee /etc/logrotate.d/homeassistant > /dev/null <<EOF
/opt/homeassistant/.homeassistant/home-assistant.log {
daily
missingok
rotate 7
compress
notifempty
copytruncate
su homeassistant homeassistant
}
EOF
Clear cache and temporary files:
# Clear Home Assistant cache
sudo -u homeassistant rm -rf /opt/homeassistant/.homeassistant/.cache
sudo -u homeassistant rm -rf /opt/homeassistant/.homeassistant/deps
# Clear pip cache
sudo -u homeassistant python -m pip cache purge
Integration Examples
MQTT Device Integration:
# configuration.yaml
mqtt:
sensor:
- name: "Temperature Sensor"
state_topic: "home/livingroom/temperature"
unit_of_measurement: "°C"
device_class: temperature
- name: "Humidity Sensor"
state_topic: "home/livingroom/humidity"
unit_of_measurement: "%"
device_class: humidity
switch:
- name: "Living Room Light"
state_topic: "home/livingroom/light/state"
command_topic: "home/livingroom/light/set"
payload_on: "ON"
payload_off: "OFF"
REST API Usage Examples:
# Get states of all entities
curl -X GET \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
http://localhost:8123/api/states
# Control a switch
curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"entity_id": "switch.living_room_light"}' \
http://localhost:8123/api/services/switch/turn_on
# Get specific entity state
curl -X GET \
-H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8123/api/states/sensor.temperature
Python Client Library Example:
# pip install homeassistant-api
import homeassistant.remote as remote
# Connect to Home Assistant
api = remote.API('localhost', 'YOUR_TOKEN', 8123)
# Get all states
states = remote.get_states(api)
for state in states:
print(f"{state.entity_id}: {state.state}")
# Turn on a light
remote.call_service(api, 'switch', 'turn_on', {'entity_id': 'switch.living_room_light'})
# Get state of specific entity
state = remote.get_state(api, 'sensor.temperature')
print(f"Temperature: {state.state}°C")
Webhook Configuration:
# configuration.yaml
automation:
- alias: "Webhook Triggered Action"
trigger:
platform: webhook
webhook_id: your_webhook_id
action:
service: notify.mobile_app_your_phone
data:
message: "Webhook triggered with data: {{ trigger.json }}"
# URL to trigger webhook:
# POST http://localhost:8123/api/webhook/your_webhook_id
Zigbee2MQTT Integration:
# Install Mosquitto MQTT broker
sudo dnf install mosquitto mosquitto-clients # RHEL/CentOS
sudo apt install mosquitto mosquitto-clients # Debian/Ubuntu
# Start MQTT broker
sudo systemctl enable --now mosquitto
# Install Node.js and npm
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo dnf install -y nodejs
# Install Zigbee2MQTT
sudo npm install -g zigbee2mqtt
# Configure Zigbee2MQTT
sudo mkdir -p /opt/zigbee2mqtt
sudo tee /opt/zigbee2mqtt/configuration.yaml > /dev/null <<EOF
homeassistant: true
permit_join: false
mqtt:
base_topic: zigbee2mqtt
server: 'mqtt://localhost'
serial:
port: /dev/ttyUSB0 # Adjust to your Zigbee dongle
advanced:
network_key: GENERATE
pan_id: GENERATE
EOF
16. Appendices
Appendix A: Command Reference
Installation Commands:
# Core installation
python3 -m venv /opt/homeassistant
source /opt/homeassistant/bin/activate
python -m pip install homeassistant
# Service management
sudo systemctl start homeassistant
sudo systemctl stop homeassistant
sudo systemctl restart homeassistant
sudo systemctl status homeassistant
# Configuration validation
hass --script check_config
hass --script ensure_config
# Database operations
hass --script purge_db --days 30
Troubleshooting Commands:
# Log analysis
sudo journalctl -u homeassistant -f
tail -f /opt/homeassistant/.homeassistant/home-assistant.log
# Network debugging
sudo netstat -tlnp | grep 8123
sudo lsof -i :8123
# Permission fixes
sudo chown -R homeassistant:homeassistant /opt/homeassistant
sudo chmod -R 755 /opt/homeassistant
Appendix B: Configuration Examples
Basic configuration.yaml:
homeassistant:
name: Home
latitude: 32.87336
longitude: 117.22743
elevation: 430
unit_system: metric
time_zone: America/Los_Angeles
frontend:
themes: !include_dir_merge_named themes
http:
server_port: 8123
recorder:
purge_keep_days: 7
auto_purge: true
logger:
default: info
MQTT Integration:
mqtt:
broker: localhost
port: 1883
username: !secret mqtt_username
password: !secret mqtt_password
discovery: true
discovery_prefix: homeassistant
Automation Example:
automation:
- alias: "Motion Light"
trigger:
platform: state
entity_id: binary_sensor.motion_sensor
to: 'on'
action:
service: light.turn_on
target:
entity_id: light.living_room
Appendix C: Integration Examples
MQTT Device Integration:
# Install Mosquitto MQTT broker
sudo dnf install mosquitto mosquitto-clients # RHEL/CentOS
sudo apt install mosquitto mosquitto-clients # Debian/Ubuntu
# Start MQTT broker
sudo systemctl enable --now mosquitto
# Test MQTT communication
mosquitto_pub -h localhost -t home/test -m "Hello World"
mosquitto_sub -h localhost -t home/test
Zigbee2MQTT Setup:
# Install Node.js
curl -fsSL https://rpm.nodesource.com/setup_18.x | sudo bash -
sudo dnf install -y nodejs
# Install Zigbee2MQTT
sudo npm install -g zigbee2mqtt
# Configuration
sudo tee /opt/zigbee2mqtt/configuration.yaml > /dev/null <<EOF
homeassistant: true
permit_join: false
mqtt:
base_topic: zigbee2mqtt
server: 'mqtt://localhost'
serial:
port: /dev/ttyUSB0
advanced:
network_key: GENERATE
pan_id: GENERATE
EOF
Appendix D: API Reference
REST API Examples:
# Get all states
curl -X GET \
-H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8123/api/states
# Control a device
curl -X POST \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"entity_id": "light.living_room"}' \
http://localhost:8123/api/services/light/turn_on
# Get configuration
curl -X GET \
-H "Authorization: Bearer YOUR_TOKEN" \
http://localhost:8123/api/config
WebSocket API:
const socket = new WebSocket('ws://localhost:8123/api/websocket');
socket.onmessage = function(event) {
const message = JSON.parse(event.data);
console.log('Received:', message);
};
// Subscribe to state changes
socket.send(JSON.stringify({
id: 1,
type: 'subscribe_events',
event_type: 'state_changed'
}));
Appendix E: Hardware Compatibility
Supported USB Devices:
Recommended Hardware:
Network Requirements:
Appendix F: Troubleshooting Checklist
Installation Issues:
Service Issues:
Performance Issues:
Security Checklist:
---
Note: This guide is part of the HowToMgr collection. Always refer to official documentation for the most up-to-date information.