Skip to main content
Home Assistant Core uses YAML files for configuration, with configuration.yaml as the main configuration file. This guide covers configuration structure, options, and best practices.

Configuration Directory

Home Assistant stores all configuration in a dedicated directory:
  • Default: ~/.homeassistant (Linux/macOS)
  • Custom: Specify with hass --config /path/to/config

Configuration Files

Home Assistant automatically creates default configuration files on first run using the template in homeassistant/config.py.

Main Configuration File

The configuration.yaml file is the entry point for all configuration.

Default Configuration

When Home Assistant starts for the first time, it creates this default configuration:
configuration.yaml
The default_config integration loads a curated set of integrations that provide a great out-of-the-box experience. See the default_config documentation for details.

Core Configuration

The homeassistant: section configures core settings.

Basic Configuration

configuration.yaml

URLs Configuration

configuration.yaml
The external_url should use HTTPS for security. Never expose Home Assistant over HTTP to the internet.

Allowlist Configuration

configuration.yaml

Media Directories

configuration.yaml

Configuration Constants

Home Assistant defines configuration constants in homeassistant/const.py. These provide consistent keys for configuration:

Common Configuration Keys

Entity Configuration Keys

Using Constants in Integrations

Secrets Management

Store sensitive data in secrets.yaml to keep it separate from configuration.

secrets.yaml

secrets.yaml

Using Secrets

Reference secrets with the !secret tag:
configuration.yaml
Never commit secrets.yaml to version control! Add it to .gitignore.

Splitting Configuration

For large configurations, split files using !include directives.

Include Single File

configuration.yaml

Include Directory (List)

Load all YAML files from a directory as a list:
configuration.yaml

Include Directory (Merge List)

Merge lists from multiple files:
configuration.yaml

Include Directory (Merge Named)

Create a dictionary from files (filename becomes key):
configuration.yaml

Integration Configuration

YAML-Based Integrations

Some integrations are configured via YAML:
configuration.yaml

UI-Based Integrations

Many modern integrations use the UI for configuration (Config Entries):
  1. Navigate to SettingsDevices & Services
  2. Click Add Integration
  3. Search for and select the integration
  4. Follow the configuration flow
Config Entry integrations are stored in .storage/core.config_entries (do not edit manually).

Customization

Customize entity attributes using the customize: section.

Basic Customization

configuration.yaml

Customize by Domain

configuration.yaml

Customize by Pattern

configuration.yaml

Packages

Packages allow you to bundle related configuration:
configuration.yaml
packages/pack_1.yaml

Configuration Validation

Home Assistant validates configuration using Voluptuous schemas.

Schema Example

Common Validators

From homeassistant.helpers.config_validation:

Checking Configuration

Validate configuration before restarting:
1

Command Line Check

2

Developer Tools

Navigate to Developer ToolsYAMLCheck Configuration
3

Review Output

Look for errors or warnings in the output. Fix any issues before restarting.
Always check your configuration after making changes to avoid startup failures.

Safe Mode

If Home Assistant fails to start due to configuration errors, it can enter safe mode:
In safe mode:
  • Minimal integrations are loaded
  • Web UI is accessible
  • You can fix configuration issues
  • No automations run

Configuration File Locations

Finding Config Directory

  • CONFIG_DIR_NAME = .homeassistant
  • YAML_CONFIG_FILE = configuration.yaml
  • VERSION_FILE = .HA_VERSION

Alternative Locations

Environment-Specific Configuration

Use environment variables for deployment-specific settings:
configuration.yaml

Best Practices

Use Secrets

Always store passwords, API keys, and tokens in secrets.yaml, never in configuration.yaml.

Version Control

Keep configuration.yaml in Git, but exclude secrets.yaml and .storage/ directories.

Split Large Configs

Use !include directives to split large configurations into manageable files.

Check Before Restart

Always validate configuration with hass --script check_config before restarting.

Document Customizations

Add comments to explain complex configurations for future reference.

Backup Regularly

Back up your configuration directory regularly, especially before major changes.

Common Configuration Patterns

Template Sensors

configuration.yaml

Input Helpers

configuration.yaml

Groups

configuration.yaml

Troubleshooting

Configuration Errors

Error: “Invalid config for [domain]: …”Solution: Check the error message for details. Common issues include:
  • Missing required fields
  • Incorrect data types
  • Invalid entity IDs
  • Malformed YAML syntax

YAML Syntax Errors

Use 2 spaces for indentation in YAML files. Never use tabs.

Secrets Not Found

Error: “Secret [secret_name] not found”Solution: Ensure the secret exists in secrets.yaml and the name matches exactly (case-sensitive).

Next Steps

Developer Docs

Explore the full developer documentation

Integration Development

Learn to create custom integrations

Configuration Reference

Complete configuration reference

Community Forum

Get help from the community

Additional Resources