agentleFS
philippbphilippb/claude-homeassistant/CLAUDE.md

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
  1. Distinctive:

    Do not change entities or devices programmatically from this repo.

    line 47
  2. Very specific:

    Run make pull to ensure local files are current

    line 59
  3. Very specific:

    Only YAML configuration files will be synced (.storage/ is protected)

    line 66
  4. Distinctive:

    Verify changes took effect in HA

    line 70
  5. Distinctive:

    Verify all agent-produced configuration and automation changes before saving YAML files to Home Assistant

    line 100
  6. Distinctive:

    Never generate, save, or push YAML changes that fail validation

    line 101
  7. Distinctive:

    Use a layered validation suite that combines Home Assistant's own validation with repository-specific validators

    line 102
  8. Very specific:

    Blueprint files: use !input tags which are normal and expected

    line 151
  9. Very specific:

    All python tools need to be run with source venv/bin/activate && python <tool_path>

    line 155
  10. Distinctive:

    Check YAML syntax errors first

    line 160
  11. Very specific:

    Verify entity references exist in .storage/ files

    line 161
  12. Distinctive:

    Run individual validators to isolate issues

    line 162
  13. Distinctive:

    Check HA logs if official validation fails

    line 163
  14. Very specific:

    Verify SSH key permissions: chmod 600 ~/.ssh/your_key

    line 166
  15. Very specific:

    Check SSH config in ~/.ssh/config

    line 168
  16. Distinctive:

    Clear location identification: - no ambiguity between properties

    line 210
  17. Distinctive:

    All location-based entities follow this convention

    line 216
  18. Distinctive:

    When creating automations, always ask the user for input if there are multiple choices for sensors or devices

    line 222
  19. Distinctive:

    Use the entity explorer tools to discover available entities before writing automations

    line 223
  20. Distinctive:

    Follow the naming convention when suggesting entity names in automations

    line 224

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

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 scripts
  • venv/ - Python virtual environment with dependencies
  • temp/ - Temporary directory for Claude to write and test code before moving to final locations
  • Makefile - Commands for pulling/pushing configuration
  • .claude-code/ - Project-specific Claude Code settings and hooks
    • hooks/ - Validation hooks that run automatically
    • settings.json - Project configuration

Rsync Architecture

This project uses two separate exclude files for different sync operations:

FileUsed ByPurpose
.rsync-excludes-pullmake pullLess restrictive
.rsync-excludes-pushmake pushMore restrictive

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/)

What This Repo Can and Cannot Manage

SAFE TO MANAGE (YAML files)

  • automations.yaml - Automation definitions
  • scenes.yaml - Scene definitions
  • scripts.yaml - Script definitions
  • configuration.yaml - Main configuration
  • secrets.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

  1. Run make pull to ensure local files are current
  2. Identify if the change affects YAML files or .storage/ files
  3. YAML files → edit locally, then make push
  4. .storage/ files → use the HA UI only (manual changes)

Before Running make push

  1. Validation runs automatically - do not push if validation fails
  2. Only YAML configuration files will be synced (.storage/ is protected)

After make push

  1. Reload the relevant HA components (automations, scenes, scripts)
  2. Verify changes took effect in HA

Available Commands

Configuration Management

  • make pull - Pull latest config from Home Assistant instance
  • make push - Push local config to Home Assistant (with validation)
  • make backup - Create backup of current config
  • make validate - Run all validation tests

Validation Tools

  • python tools/run_tests.py - Run complete validation suite
  • python tools/yaml_validator.py - YAML syntax validation only
  • python tools/reference_validator.py - Entity/device reference validation
  • python tools/ha_official_validator.py - Official HA configuration validation

Entity Discovery Tools

  • make entities - Explore available Home Assistant entities
  • python 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
  1. YAML Syntax Validation - Ensures proper YAML syntax with HA-specific tags
  2. Entity Reference Validation - Checks that all referenced entities/devices exist
  3. 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_HOST variable
  • 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

  1. Pull Latest: make pull to sync from HA
  2. Edit Locally: Modify files in config/ directory
  3. Auto-Validation: Hooks automatically validate on edits
  4. Test Changes: make validate for full test suite
  5. Deploy: make push to 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 !input tags 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

  1. Check YAML syntax errors first
  2. Verify entity references exist in .storage/ files
  3. Run individual validators to isolate issues
  4. Check HA logs if official validation fails

SSH Issues

  1. Verify SSH key permissions: chmod 600 ~/.ssh/your_key
  2. Test connection: ssh your_homeassistant_host
  3. Check SSH config in ~/.ssh/config

Missing Dependencies

  1. Activate venv: source venv/bin/activate
  2. 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_roborock

Benefits:

  • 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.