Integration Overview
Integrations in Home Assistant are the building blocks that connect your home automation system with external devices, services, and platforms. This guide explains the architecture and core concepts behind Home Assistant integrations.What is an Integration?
An integration is a Python package that enables Home Assistant to communicate with a specific device, service, or protocol. Each integration lives in thehomeassistant/components/ directory and contains all the code needed to interact with that particular system.
Example: The MQTT integration (
homeassistant/components/mqtt/) enables Home Assistant to communicate with devices using the MQTT protocol.Integration Types
Home Assistant defines several integration types in the manifest, each serving a different purpose:Available Integration Types
- entity - Provides entity platforms for controlling devices
- device - Represents physical devices with multiple entities
- hardware - Interfaces with hardware (USB, GPIO, etc.)
- helper - Provides utility functions or services
- hub - Connects to a central hub that manages multiple devices
- service - Provides connectivity to external services
- system - Core Home Assistant functionality
- virtual - Provides virtual/computed entities
Integration Architecture
Home Assistant uses a sophisticated loader system to discover and load integrations. Here’s how it works:# From loader.py
PACKAGE_CUSTOM_COMPONENTS = "custom_components"
PACKAGE_BUILTIN = "homeassistant.components"
class Integration:
"""An integration in Home Assistant."""
def __init__(
self,
hass: HomeAssistant,
pkg_path: str,
file_path: pathlib.Path,
manifest: Manifest,
) -> None:
self.hass = hass
self.pkg_path = pkg_path
self.file_path = file_path
self.manifest = manifest
Core Concepts
Platforms
Platforms are specific entity types that an integration can provide. Common platforms include:light- Light entitiesswitch- Switch entitiessensor- Sensor entitiesclimate- Climate control entitiesbinary_sensor- Binary sensor entities
Dependencies
Integrations can depend on other integrations to function:dependencies: Must be loaded before this integrationafter_dependencies: Should be loaded before this integration if present, but not required
Quality Scale
Integrations can achieve different quality levels:- platinum - Highest quality, well-tested, excellent code
- gold - High quality, good test coverage
- silver - Good quality, basic tests
- internal - Core Home Assistant integrations
- custom - Custom integrations (default)
IoT Class
The IoT class describes how an integration communicates:local_push- Device pushes updates to Home Assistant locallylocal_polling- Home Assistant polls device locallycloud_push- Device pushes updates via cloudcloud_polling- Home Assistant polls cloud APIcalculated- Values are calculated, not from external sources
Import Executor
For performance, integrations can be loaded in an executor thread:Single Config Entry
Some integrations should only have one configuration entry:Preload Platforms
Certain platforms are automatically preloaded for faster startup:Next Steps
Creating Your First Integration
Learn how to create a basic integration from scratch
Integration Manifest
Understand the manifest.json file structure
Config Flow
Implement UI-based configuration
Entity Platforms
Create entity platforms for your integration