| name | ha-frontend-contexts |
| description | Home Assistant frontend Lit context and hass migration guidance. Use when adding or changing component state access, replacing hass reads, consuming entity or registry contexts, or reviewing rerender behavior. |
HA Frontend Contexts
Use this skill when a component reads Home Assistant state, registries, localization, services, config, UI data, connection state, or API helpers.
Goal
Move leaf components away from the broad hass: HomeAssistant object. Broad hass access rerenders components for unrelated changes, hides the data a component depends on, and makes tests harder to mock.
Container components may keep hass when they own it and feed providers. Leaf components should consume the narrowest context that covers their reads.
Core Files
- Context definitions:
src/data/context/index.ts
- Entity-scoped consume helpers:
src/common/decorators/consume-context-entry.ts
- Transform decorator:
src/common/decorators/transform.ts
- Canonical migration example:
src/panels/lovelace/cards/hui-button-card.ts
- Providers are wired by
contextMixin on HassBaseEl; consumers do not wire providers manually.
Context Selection
| Context | Replaces |
|---|
statesContext | hass.states |
entitiesContext, devicesContext, areasContext, floorsContext | hass.entities, , , |