Skip to main content
Entities are the building blocks of Home Assistant. They represent devices, sensors, switches, and other controllable or monitorable objects. This guide covers how to create entity components for your integration.

Entity Basics

What is an Entity?

An entity represents a single piece of functionality from a device or service. Examples:
  • A temperature sensor
  • A light bulb
  • A media player
  • A switch
Each entity has:
  • A unique ID for identification
  • A state (on/off, temperature value, etc.)
  • attributes with additional information
  • An entity ID like sensor.living_room_temperature

Entity Platforms

Home Assistant has different entity platforms for different types of entities:
  • sensor - Read-only measurements
  • binary_sensor - On/off sensors
  • switch - On/off switches
  • light - Lights with brightness, color, etc.
  • climate - Thermostats and climate control
  • cover - Blinds, garage doors, etc.
  • And many more…

Creating an Entity Platform

Each entity platform is a separate Python file in your integration directory.

Platform Setup Function

Every platform must have an async_setup_entry function:
sensor.py

Creating an Entity Class

Entity classes inherit from a base entity class specific to their platform.

Basic Entity Example

Entity Properties

The Entity base class provides many properties you can override:

Essential Properties

Modern Entity Naming

Use the modern naming pattern with device info:
This creates an entity named “My Device Temperature” and groups it with other entities from the same device.

State Updates

There are several ways to update entity state:

Method 1: async_update (Polling)

Method 3: DataUpdateCoordinator (Best Practice)

See the DataUpdateCoordinator documentation for setup details.

Platform-Specific Features

Sensor Platform

Switch Platform

Light Platform

Entity Attributes

You can add extra attributes to entities:

Entity Categories

Use entity categories to organize entities:
Categories:
  • EntityCategory.CONFIG - Configuration entities
  • EntityCategory.DIAGNOSTIC - Diagnostic information
  • None - Primary entities (default)

Entity Registry

When you set a unique_id, entities are automatically registered:
Benefits of entity registry:
  • Users can customize entity names and icons
  • Users can disable entities they don’t need
  • Entity IDs are stable across restarts
  • Entities can be tracked across config changes

Dynamic Entity Addition

For devices that support dynamic entities:

Entity Availability

Indicate when an entity is unavailable:

Best Practices

Always Use Unique IDs

Provide unique IDs for all entities to enable customization:

Use Device Info

Group related entities under a single device:

Use DataUpdateCoordinator

For polling integrations, use DataUpdateCoordinator to efficiently manage updates.

Disable Polling When Possible

If your API supports push updates, disable polling:

Handle Exceptions

Gracefully handle API errors:

Use Modern Naming

Set _attr_has_entity_name = True and provide device info for better entity naming.

Common Patterns

Entity Descriptions

For multiple similar entities, use entity descriptions:

Next Steps