Skip to main content
Glama

Bulk write virtual entity states

entities_bulk_set_state
Idempotent

Write 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

TableJSON Schema
NameRequiredDescriptionDefault
updatesYesList of {entity_id, state, attributes?} dicts describing the virtual state to write per entity.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.25.1
    • addedInput schema / properties / updates / description
      Added value: +"List of {entity_id, state, attributes?} dicts describing the virtual state to write per entity."
  2. First observedv0.3.0

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the annotations: it discloses that this sets a *virtual* state overwritten by a real driver on the next update, that failures are reported per item rather than raised, and it enumerates the error_type taxonomy (validation/http/unexpected) with the condition that triggers each. This is rich operational context the annotations do not carry.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Well-structured with labeled Use when/Not for/Returns/Errors sections and front-loads the core behavior. It is slightly verbose in the Errors paragraph, but every sentence carries operational meaning rather than filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a bulk mutation tool it covers behavior, safety implications (virtual vs real state), usage routing, and granular error semantics. An output schema exists so return values needn't be spelled out, yet the per-item result shape is described anyway, leaving no material gap for correct invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and there is only one parameter, giving a baseline of 3, but the description adds real meaning beyond the schema: it clarifies the per-item required fields (entity_id/state) and specifies that a missing one yields a 'validation' error with no write attempted. That goes beyond the loose '{entity_id, state, attributes?}' schema item.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a precise verb+resource ('write states for many entities... one call per entity') and explains the underlying mechanism (ha.set_state posting to /api/states/<entity_id>). It clearly distinguishes itself from entities_bulk_control and from a real service call, so an agent can differentiate it from siblings immediately.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides an explicit 'Use when' (seeding/overriding state for testing, template sensors, entities with no backing device) and 'Not for' that names the alternative (entities_bulk_control) for actual device control. This is textbook when/when-not/alternative guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools