claude-homeassistant
CLAUDE.md392 starsChanged 10 months agoApache-2.0View on GitHub
This repository manages Home Assistant configuration files with automated validation, testing, and deployment. Always consult the latest Home Assistant documentation at https://www.home-assistant.io/docs/ before suggesting configurations, automations, or integrations. HA updates frequently and syntax/features change between versions. This project uses two separate exclude files for different sync operations: Why separate files? - make pull downloads most files including .storage/ (excluding sensitive auth files) for local reference - make push writes never overwrites HA's runtime state (.storage/) Do not change entities or…
- Reads credentials
- Installs packages
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
20 rules. About 0 are common, 13 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 47
Do not change entities or devices programmatically from this repo.
- Very specific: line 59
Run make pull to ensure local files are current
- Very specific: line 66
Only YAML configuration files will be synced (.storage/ is protected)
- Distinctive: line 70
Verify changes took effect in HA
- Distinctive: line 100
Verify all agent-produced configuration and automation changes before saving YAML files to Home Assistant
- Distinctive: line 101
Never generate, save, or push YAML changes that fail validation
- Distinctive: line 102
Use a layered validation suite that combines Home Assistant's own validation with repository-specific validators
- Very specific: line 151
Blueprint files: use !input tags which are normal and expected
- Very specific: line 155
All python tools need to be run with source venv/bin/activate && python <tool_path>
- Distinctive: line 160
Check YAML syntax errors first
- Very specific: line 161
Verify entity references exist in .storage/ files
- Distinctive: line 162
Run individual validators to isolate issues
- Distinctive: line 163
Check HA logs if official validation fails
- Very specific: line 166
Verify SSH key permissions: chmod 600 ~/.ssh/your_key
- Very specific: line 168
Check SSH config in ~/.ssh/config
- Distinctive: line 210
Clear location identification: - no ambiguity between properties
- Distinctive: line 216
All location-based entities follow this convention
- Distinctive: line 222
When creating automations, always ask the user for input if there are multiple choices for sensors or devices
- Distinctive: line 223
Use the entity explorer tools to discover available entities before writing automations
- Distinctive: line 224
Follow the naming convention when suggesting entity names in automations
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Home Assistant Configuration Management
This repository manages Home Assistant configuration files with automated validation, testing, and deployment.
Before Making Changes
Always consult the latest Home Assistant documentation at https://www.home-assistant.io/docs/ before suggesting configurations, automations, or integrations. HA updates frequently and syntax/features change between versions.
Project Structure
config/- Contains all Home Assistant configuration files (synced from HA instance)tools/- Validation and testing scriptsvenv/- Python virtual environment with dependenciestemp/- Temporary directory for Claude to write and test code before moving to final locationsMakefile- Commands for pulling/pushing configuration.claude-code/- Project-specific Claude Code settings and hookshooks/- Validation hooks that run automaticallysettings.json- Project configuration
Rsync Architecture
This project uses two separate exclude files for different sync operations:
| File | Used By | Purpose |
.rsync-excludes-pull | make pull | Less restrictive |
.rsync-excludes-push | make push | More restrictive |
Why separate files?
make pulldownloads most files including.storage/(excluding sensitive auth files) for local referencemake pushwrites never overwrites HA's runtime state (.storage/)
What This Repo Can and Cannot Manage
SAFE TO MANAGE (YAML files)
automations.yaml- Automation definitionsscenes.yaml- Scene definitionsscripts.yaml- Script definitionsconfiguration.yaml- Main configurationsecrets.yaml- Secret values
NEVER MODIFY LOCALLY (Runtime State)
These files in .storage/ are managed by Home Assistant at runtime. Local modifications will be overwritten by HA on restart or ignored entirely.
Entity/Device Changes (Manual Only)
Do not change entities or devices programmatically from this repo. If changes are needed, make them manually in the Home Assistant UI:
- Settings → Devices & Services → Entities → Edit
Reloading After YAML Changes
- Automations:
POST /api/services/automation/reload - Scenes:
POST /api/services/scene/reload - Scripts:
POST /api/services/script/reload
Workflow Rules
Before Making Changes
- Run
make pullto ensure local files are current - Identify if the change affects YAML files or
.storage/files - YAML files → edit locally, then
make push .storage/files → use the HA UI only (manual changes)
Before Running make push
- Validation runs automatically - do not push if validation fails
- Only YAML configuration files will be synced (
.storage/is protected)
After make push
- Reload the relevant HA components (automations, scenes, scripts)
- Verify changes took effect in HA
Available Commands
Configuration Management
make pull- Pull latest config from Home Assistant instancemake push- Push local config to Home Assistant (with validation)make backup- Create backup of current configmake validate- Run all validation tests
Validation Tools
python tools/run_tests.py- Run complete validation suitepython tools/yaml_validator.py- YAML syntax validation onlypython tools/reference_validator.py- Entity/device reference validationpython tools/ha_official_validator.py- Official HA configuration validation
Entity Discovery Tools
make entities- Explore available Home Assistant entitiespython tools/entity_explorer.py- Entity registry parser and explorer--search TERM- Search entities by name, ID, or device class--domain DOMAIN- Show entities from specific domain (e.g., climate, sensor)--area AREA- Show entities from specific area--full- Show complete detailed output
Validation System
This project includes comprehensive validation to prevent invalid configurations:
Core Goal
- Verify all agent-produced configuration and automation changes before saving YAML files to Home Assistant
- Never generate, save, or push YAML changes that fail validation
- Use a layered validation suite that combines Home Assistant's own validation with repository-specific validators
- YAML Syntax Validation - Ensures proper YAML syntax with HA-specific tags
- Entity Reference Validation - Checks that all referenced entities/devices exist
- Official HA Validation - Uses Home Assistant's own validation tools
Automated Validation Hooks
- Post-Edit Hook: Runs validation after editing any YAML files in
config/ - Pre-Push Hook: Validates configuration before pushing to Home Assistant
- Blocks invalid pushes: Prevents uploading broken configurations
Home Assistant Instance Details
- Host: Configure in Makefile
HA_HOSTvariable - User: Configure SSH access as needed
- SSH Key: Configure SSH key authentication
- Config Path: /config/ (standard HA path)
- Version: Compatible with Home Assistant Core 2024.x+
Entity Registry
The system tracks entities across these domains:
- alarm_control_panel, binary_sensor, button, camera, climate
- device_tracker, event, image, light, lock, media_player
- number, person, scene, select, sensor, siren, switch
- time, tts, update, vacuum, water_heater, weather, zone
Development Workflow
- Pull Latest:
make pullto sync from HA - Edit Locally: Modify files in
config/directory - Auto-Validation: Hooks automatically validate on edits
- Test Changes:
make validatefor full test suite - Deploy:
make pushto upload (blocked if validation fails)
Key Features
- ✅ Safe Deployments: Pre-push validation prevents broken configs
- ✅ Entity Validation: Ensures all references point to real entities
- ✅ Entity Discovery: Advanced tools to explore and search available entities
- ✅ Official HA Tools: Uses Home Assistant's own validation
- ✅ YAML Support: Handles HA-specific tags (!include, !secret, !input)
- ✅ Comprehensive Testing: Multiple validation layers
- ✅ Automated Hooks: Validation runs automatically on file changes
Important Notes
- Never push without validation: The hooks prevent this, but be aware
- Blueprint files use
!inputtags which are normal and expected - Secrets are skipped during validation for security
- SSH access required for pull/push operations
- Python venv required for validation tools
- All python tools need to be run with
source venv/bin/activate && python <tool_path>
Troubleshooting
Validation Fails
- Check YAML syntax errors first
- Verify entity references exist in
.storage/files - Run individual validators to isolate issues
- Check HA logs if official validation fails
SSH Issues
- Verify SSH key permissions:
chmod 600 ~/.ssh/your_key - Test connection:
ssh your_homeassistant_host - Check SSH config in
~/.ssh/config
Missing Dependencies
- Activate venv:
source venv/bin/activate - Install requirements:
pip install homeassistant voluptuous pyyaml
Security
- SSH keys are used for secure access
- Secrets.yaml is excluded from validation (contains sensitive data)
- No credentials are stored in this repository
- Access tokens in config are for authorized integrations
This system ensures you can confidently manage Home Assistant configurations with Claude while maintaining safety and reliability.
Entity Naming Convention
This Home Assistant setup uses a standardized entity naming convention for multi-location deployments:
Format: location_room_device_sensor
Structure:
- location:
home,office,cabin, etc. - room:
basement,kitchen,living_room,main_bedroom,guest_bedroom,driveway, etc. - device:
motion,heatpump,sonos,lock,vacuum,water_heater,alarm, etc. - sensor:
battery,tamper,status,temperature,humidity,door,running, etc.
Examples:
binary_sensor.home_basement_motion_battery
binary_sensor.home_basement_motion_tamper
media_player.home_kitchen_sonos
media_player.office_main_bedroom_sonos
climate.home_living_room_heatpump
climate.office_living_room_thermostat
lock.home_front_door_august
sensor.office_driveway_camera_battery
vacuum.home_roborock
vacuum.office_roborockBenefits:
- Clear location identification - no ambiguity between properties
- Consistent structure - easy to predict entity names
- Automation-friendly - simple to target location-specific devices
- Scalable - supports additional locations or rooms
Implementation:
- All location-based entities follow this convention
- Legacy entities have been systematically renamed
- New entities should follow this pattern
- Vendor prefixes (aquanta_, august_, etc.) are replaced with descriptive device names
Claude Code Integration:
- When creating automations, always ask the user for input if there are multiple choices for sensors or devices
- Use the entity explorer tools to discover available entities before writing automations
- Follow the naming convention when suggesting entity names in automations
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

