ESPHome exposes all platform components — sensors, switches, lights, climate units, covers, and more — as entities. Each entity has a stable numeric key, a name, an object ID, and a domain that identifies its type. The client maintains anDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/richard87/esphome-apiclient/llms.txt
Use this file to discover all available pages before exploring further.
EntityRegistry that caches entity metadata and the most recent state for each entity.
Listing entities
CallListEntities() after connecting to fetch all entity definitions from the device. The registry is populated automatically as responses arrive.
ListEntities returns, the registry is available through client.Entities():
Accessing entities by type
The registry provides typed accessor methods that return slices of entity structs for each domain.- Sensors
- Binary sensors
- Switches
- Lights
- Climate
Looking up an entity by key
ByKey performs a unified lookup across all domains and returns the Entity interface, or nil if not found.
The Entity interface
Every entity type implements theEntity interface:
GetDomain() returns an EntityDomain constant whose String() method produces the ESPHome domain name (e.g. "sensor", "binary_sensor").
SensorEntity fields
SensorEntity exposes both metadata from ListEntities and cached state from the most recent SensorStateResponse:
| Field | Type | Description |
|---|---|---|
Key | uint32 | Stable entity identifier |
Name | string | Human-readable name |
ObjectID | string | Entity object ID |
UnitOfMeasurement | string | e.g. "°C", "%", "hPa" |
DeviceClass | string | e.g. "temperature", "humidity" |
StateClass | pb.SensorStateClass | Measurement, total, or total increasing |
AccuracyDecimals | int32 | Display precision |
State | float32 | Latest received value |
MissingState | bool | True until the first state is received |
Entity domains
The library defines 16 entity domains:| Constant | Domain string | Registry accessor | List response type |
|---|---|---|---|
DomainSensor | sensor | Sensors() | *pb.ListEntitiesSensorResponse |
DomainBinarySensor | binary_sensor | BinarySensors() | *pb.ListEntitiesBinarySensorResponse |
DomainCover | cover | Covers() | *pb.ListEntitiesCoverResponse |
DomainFan | fan | Fans() | *pb.ListEntitiesFanResponse |
DomainLight | light | Lights() | *pb.ListEntitiesLightResponse |
DomainSwitch | switch | Switches() | *pb.ListEntitiesSwitchResponse |
DomainTextSensor | text_sensor | TextSensors() | *pb.ListEntitiesTextSensorResponse |
DomainCamera | camera | Cameras() | *pb.ListEntitiesCameraResponse |
DomainClimate | climate | Climates() | *pb.ListEntitiesClimateResponse |
DomainNumber | number | Numbers() | *pb.ListEntitiesNumberResponse |
DomainSelect | select | Selects() | *pb.ListEntitiesSelectResponse |
DomainSiren | siren | Sirens() | *pb.ListEntitiesSirenResponse |
DomainLock | lock | Locks() | *pb.ListEntitiesLockResponse |
DomainButton | button | Buttons() | *pb.ListEntitiesButtonResponse |
DomainMediaPlayer | media_player | MediaPlayers() | *pb.ListEntitiesMediaPlayerResponse |
DomainWaterHeater | water_heater | WaterHeaters() | *pb.ListEntitiesWaterHeaterResponse |