Bulk write virtual entity states
entities_bulk_set_stateWrite virtual states for many entities in one call via the states API, for seeding or overriding state in tests, templates, or entities with no backing device.
Instructions
Write states for many entities directly via the states API, one call per entity.
Calls ha.set_state(entity_id, state, attributes) per item in
updates, which posts to /api/states/<entity_id>; this sets a virtual
state that a real device driver overwrites on its next update, unlike a
real service call.
Use when: seeding or overriding state for testing, template sensors, or
entities with no backing device.
Not for: actually controlling a device — use entities_bulk_control.
Returns: list of per-update dicts ({entity_id, ok, error?, error_type?});
a missing entity_id/state or a failed write is reported per item, not
raised.
Errors: per-item {"ok": false, "error": "...", "error_type": "..."};
error_type is "validation" for a missing entity_id/state (no
write attempted), "http" for an httpx.HTTPError from the write call
(bad response or network failure talking to Home Assistant), or
"unexpected" for any other exception. An "unexpected" error is still
caught per item and does not abort the rest of the batch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updates | Yes | List of {entity_id, state, attributes?} dicts describing the virtual state to write per entity. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |