A comprehensive system for managing Home Assistant configurations with automated validation, testing, and deployment - all enhanced by Claude Code for natural language automation creation.
- π€ AI-Powered Automation Creation: Use Claude Code to write automations in plain English
- π‘οΈ Multi-Layer Validation: Comprehensive validation prevents broken configurations
- π Safe Deployments: Pre-push validation blocks invalid configs from reaching HA
- π Entity Discovery: Advanced tools to explore and search available entities
- β‘ Automated Hooks: Validation runs automatically on file changes
- π Entity Registry Integration: Real-time validation against your actual HA setup
This repository provides a complete framework for managing Home Assistant configurations with Claude Code. Here's how it works:
- Template Configs: The
config/
folder contains sanitized example configurations (no secrets) - Validation Tools: The
tools/
folder has all validation scripts - Management Commands: The
Makefile
contains pull/push commands - Development Setup:
pyproject.toml
and other dev files for tooling
git clone [email protected]:philippb/claude-homeassistant.git
cd claude-homeassistant
make setup # Creates Python venv and installs dependencies
Copy the example environment file and configure your settings:
cp .env.example .env
# Edit .env with your actual Home Assistant details
The .env
file should contain:
# Home Assistant Configuration
HA_TOKEN=your_home_assistant_token
HA_URL=http://your_homeassistant_host:8123
# SSH Configuration for rsync operations
HA_HOST=your_homeassistant_host
HA_REMOTE_PATH=/config/
# Local Configuration (optional - defaults provided)
LOCAL_CONFIG_PATH=config/
BACKUP_DIR=backups
VENV_PATH=venv
TOOLS_PATH=tools
Set up SSH access to your Home Assistant instance.
Recommended: Install the Advanced SSH & Web Terminal add-on for Home Assistant, which provides excellent SSH/SFTP access needed for the rsync operations in this project.
make pull # Downloads YOUR actual HA config, overwriting template files
Important: This step replaces the template config/
folder with your real Home Assistant configuration files.
- Edit your real configs locally with full validation
- Use Claude Code to create automations in natural language
- Validation hooks automatically check syntax and entity references
make push # Uploads changes back to your HA instance (with validation)
- Template Start: You begin with example configs showing proper structure
- Real Data: First
make pull
overwrites templates with your actual HA setup - Local Development: Edit real configs locally with validation safety
- Safe Deployment:
make push
validates before uploading to prevent broken configs
This gives you a complete development environment while only modifying your HA instance when completed.
This project uses make
commands for configuration management. If you don't have make
installed:
macOS:
xcode-select --install # Installs Command Line Tools including make
Windows:
- Option 1: Use WSL (Windows Subsystem for Linux) - recommended
- Option 2: Install via Chocolatey:
choco install make
- Option 3: Use Git Bash (includes make)
- Option 4: Install MinGW-w64
Alternative: If you can't install make
, you can run the underlying commands directly by checking the Makefile
for the actual command syntax.
βββ config/ # Home Assistant configuration files, downloaded from HA via script
β βββ configuration.yaml
β βββ automations.yaml
β βββ scripts.yaml
β βββ .storage/ # Entity registry (pulled from HA)
βββ tools/ # Validation scripts for Claude
β βββ run_tests.py # Main test suite runner
β βββ yaml_validator.py # YAML syntax validation
β βββ reference_validator.py # Entity reference validation
β βββ ha_official_validator.py # Official HA validation
β βββ entity_explorer.py # Entity discovery tool
βββ .claude-code/ # Claude Code project settings
β βββ hooks/ # Automated validation hooks
β βββ settings.json # Project configuration
βββ .env.example # Environment configuration template
βββ venv/ # Python virtual environment
βββ Makefile # Management commands
βββ CLAUDE.md # Claude Code instructions
make pull # Pull latest config from Home Assistant
make push # Push local config to HA (with validation)
make backup # Create timestamped backup
make validate # Run all validation tests
make entities # Show entity summary
make entities ARGS='--domain climate' # Climate entities only
make entities ARGS='--search motion' # Search for motion sensors
make entities ARGS='--area kitchen' # Kitchen entities only
make entities ARGS='--full' # Complete detailed output
. venv/bin/activate
python tools/yaml_validator.py # YAML syntax only
python tools/reference_validator.py # Entity references only
python tools/ha_official_validator.py # Official HA validation
The system provides three layers of validation:
- Validates YAML syntax with HA-specific tags (
!include
,!secret
,!input
) - Checks file encoding (UTF-8 required)
- Validates basic HA file structures
- Verifies all entity references exist in your HA instance
- Checks device and area references
- Warns about disabled entities
- Extracts entities from Jinja2 templates
- Uses Home Assistant's own validation tools
- Most comprehensive check available
- Catches integration-specific issues
Two hooks ensure configuration safety:
- Post-Edit Hook: Runs validation after editing YAML files
- Pre-Push Hook: Validates before syncing to HA (blocks if invalid)
This system supports standardized entity naming:
Format: location_room_device_sensor
Examples:
binary_sensor.home_basement_motion_battery
media_player.office_kitchen_sonos
climate.home_living_room_heatpump
With Claude Code, you can:
-
Describe automations in English:
"Turn off all lights at midnight on weekdays"
-
Claude writes the YAML:
- id: weekday_midnight_lights_off alias: "Weekday Midnight Lights Off" trigger: - platform: time at: "00:00:00" condition: - condition: time weekday: [mon, tue, wed, thu, fri] action: - service: light.turn_off target: entity_id: all
-
Automatic validation ensures correctness
-
Deploy safely with
make push
The entity explorer helps you understand what's available:
# Find all motion sensors
. venv/bin/activate && python tools/entity_explorer.py --search motion
# Show all climate controls
. venv/bin/activate && python tools/entity_explorer.py --domain climate
# Kitchen devices only
. venv/bin/activate && python tools/entity_explorer.py --area kitchen
- Secrets Management:
secrets.yaml
is excluded from validation - SSH Authentication: Uses SSH keys for secure HA access
- No Credentials Stored: Repository contains no sensitive data
- Pre-Push Validation: Prevents broken configs from reaching HA
- Backup System: Automatic timestamped backups before changes
- Check YAML syntax first:
. venv/bin/activate && python tools/yaml_validator.py
- Verify entity references:
. venv/bin/activate && python tools/reference_validator.py
- Check HA logs if official validation fails
- Test connection:
ssh your_homeassistant_host
- Check SSH key permissions:
chmod 600 ~/.ssh/your_key
- Verify SSH config in
~/.ssh/config
. venv/bin/activate
pip install homeassistant voluptuous pyyaml jsonschema requests
Configure via .env
file in project root (copy from .env.example
):
cp .env.example .env
Available variables:
# Home Assistant Configuration
HA_TOKEN=your_home_assistant_token # HA API token
HA_URL=http://your_homeassistant_host:8123 # HA instance URL
# SSH Configuration for rsync operations
HA_HOST=your_homeassistant_host # SSH hostname for HA
HA_REMOTE_PATH=/config/ # Remote config path
# Local Configuration (optional - defaults provided)
LOCAL_CONFIG_PATH=config/ # Local config directory
BACKUP_DIR=backups # Backup directory
VENV_PATH=venv # Python virtual environment path
TOOLS_PATH=tools # Tools directory
Located in .claude-code/settings.json
:
{
"hooks": {
"enabled": true,
"posttooluse": [".claude-code/hooks/posttooluse-ha-validation.sh"],
"pretooluse": [".claude-code/hooks/pretooluse-ha-push-validation.sh"]
},
"validation": {
"enabled": true,
"auto_run": true,
"block_invalid_push": true
}
}
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all validations pass
- Submit a pull request
Apache 2.0
- Home Assistant for the amazing platform
- Claude Code for AI-powered development
- The HA community for validation best practices
Ready to revolutionize your Home Assistant automation workflow? Start by describing what you want in plain English and let Claude Code handle the rest! π