Skip to main content

Entity Platforms

Entity platforms are the core building blocks that represent controllable or observable elements in Home Assistant. This guide covers implementing different entity types for your integration.

Platform Architecture

Platforms are separate Python modules within your integration, one for each entity type you support:

Available Platforms

From homeassistant.const.Platform:
  • light - Lights
  • switch - Switches
  • sensor - Sensors
  • binary_sensor - Binary sensors
  • climate - Climate devices (thermostats)
  • cover - Covers (blinds, garage doors)
  • fan - Fans
  • lock - Locks
  • media_player - Media players
  • camera - Cameras
  • vacuum - Vacuum cleaners
  • water_heater - Water heaters
  • And many more…

Basic Platform Structure

Every platform follows the same pattern:

Entity Base Class

All entities inherit from Entity (from homeassistant/helpers/entity.py):
Using _attr_* attributes is the modern approach. They’re automatically exposed as properties.

Light Platform

Basic Light Implementation

light.py

Color Support

For RGB/RGBW lights:
Real example from Demo integration (homeassistant/components/demo/light.py:94):

Sensor Platform

Basic Sensor

sensor.py
Device Class: Indicates the type of sensor (temperature, humidity, etc.)State Class: For statistics and long-term data (measurement, total, total_increasing)Native Value: The sensor’s value in its native unit

Statistics and Units

Home Assistant automatically handles:
  • Unit conversion
  • Statistics collection
  • Long-term storage
  • Graphing

Switch Platform

switch.py

Binary Sensor Platform

binary_sensor.py

Climate Platform

climate.py

Entity Features

Unique ID

Every entity should have a unique ID:
Unique IDs must be stable across restarts and unique across all integrations.

Device Info

Group entities under devices:

Availability

Indicate when entities are unavailable:

Entity Category

Categorize entities:
Categories:
  • CONFIG - Configuration entities
  • DIAGNOSTIC - Diagnostic information
  • None - Regular entities (default)

State Updates

Platform Setup Methods

From homeassistant/helpers/entity_platform.py:96:
Use async_setup_entry for modern config-entry-based integrations.Use async_setup_platform only for legacy YAML-based platforms.

Best Practices

Use Async Methods

Batch Entity Creation

Handle Missing Data

Next Steps

Integration Overview

Understand the full integration architecture

Config Flow

Add UI configuration to your integration