Skip to main content
Glama

Wait for a HA trigger to fire

ws_subscribe_trigger
Read-onlyIdempotent

Wait for a Home Assistant trigger condition to fire once, avoiding polling. Blocks up to a specified timeout, returning the event context or None if it doesn't fire.

Instructions

Passively wait for a Home Assistant trigger definition to fire once.

Sends subscribe_trigger with the given trigger and waits up to timeout seconds for the matching event.

Use when: waiting for a specific trigger condition (state, time, numeric state, ...) rather than polling. Not for: raw state_changed events on one entity — use ws_listen_state_changes. Returns: the trigger's event context dict when it fires, or None if timeout elapses first. Errors: raises RuntimeError when the WebSocket handshake does not complete within timeout. Limits: blocks for up to timeout seconds, including the initial handshake.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeoutNoMaximum seconds to wait for the trigger to fire before returning None; must be between 1 and 300.
triggerYesHA trigger definition dict, e.g. {'platform': 'state', 'entity_id': 'binary_sensor.motion', 'to': 'on'}.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed4 schema fields changedv0.25.1
    • addedInput schema / properties / timeout / description
      Added value: +"Maximum seconds to wait for the trigger to fire before returning None; must be between 1 and 300."
    • addedInput schema / properties / timeout / maximum
      Added value: +300
    • addedInput schema / properties / timeout / minimum
      Added value: +1
    • addedInput schema / properties / trigger / description
      Added value: +"HA trigger definition dict, e.g. {'platform': 'state', 'entity_id': 'binary_sensor.motion', 'to': 'on'}."
  2. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already cover the safety profile (readOnly, idempotent, non-destructive, not open-world), and the description adds substantial non-obvious behavior: it blocks up to `timeout` seconds including the handshake, returns the event context dict or None on timeout, and raises RuntimeError on a failed handshake.

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

Conciseness5/5

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

Front-loaded first line states the action, then labeled blocks (Use when / Not for / Returns / Errors / Limits) make it scannable with no filler sentences.

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 blocking wait tool with an output schema, the description covers return value, failure mode, and the blocking time budget, leaving no gap an agent needs before invoking it.

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

Parameters3/5

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

Schema description coverage is 100% — the schema already documents the trigger dict example and the timeout bounds (1-300, default 30) — so the description's mention of `trigger` and `timeout` adds little. The only marginal extra is that the blocking window includes the handshake, which is behavioral rather than parametric.

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 specific verb and resource ('passively wait for a Home Assistant trigger definition to fire once') and names the sibling it is not, ws_listen_state_changes, so an agent can route correctly without opening either schema.

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?

Explicit 'Use when' clause (waiting for a specific trigger condition rather than polling) and explicit 'Not for' clause pointing to ws_listen_state_changes for raw state_changed events. Both the positive and negative routing conditions are given.

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