Set State
home_assistant.set_state
ActionBusiness appsconnection required
Calls the Home Assistant API with the connection's credentials.
Write a state and attributes into the state machine for an entity.
Connection
- Required
- Yes — the node will not save without one
- Auth type
- Bearer token
- Providers
- Home Assistant
- Secret shape
- the long-lived access token, or {"access_token": "…"}
- Config it needs
- base_url
- Resolved by
- config.connection_id, else node.connection_id
Configuration
3 fields, 2 required. A dotted path is a nested object and name[] an array of objects — the editor renders the same tree.
| Field | Type | Required | Default | Constraints | Example |
|---|---|---|---|---|---|
entity_id The entity to write, as '<domain>.<object_id>'. It is created if it does not exist. | string | Yes | — | — | sensor.mantle_last_run |
state The new state. Home Assistant stores every state as a string. | string | Yes | — | — | ok |
attributes Attributes to store alongside the state, as a JSON object. | object | No | — | — | {"friendly_name":"Mantle last run"} |
Example configuration
Every value below is the contract’s own example or default — nothing invented.
{
"attributes": {
"friendly_name": "Mantle last run"
},
"entity_id": "sensor.mantle_last_run",
"state": "ok"
}Output
One shape.
result
| Field | Type | Example |
|---|---|---|
entity_id The entity this state belongs to. | string | light.kitchen |
state The state itself, always a string. | string | on |
attributes The entity's attributes, including friendly_name. | object | — |
last_changed When the state last changed, ISO-8601. | string | — |
last_updated When the state object was last written, ISO-8601. | string | — |
context Who or what caused the change (id, user_id, parent_id). | object | — |
{
"attributes": {},
"context": {},
"entity_id": "light.kitchen",
"last_changed": "",
"last_updated": "",
"state": "on"
}Notes
- This only changes what Home Assistant believes about the entity; it does not talk to a device. Use Call Service to actually switch something.
- Home Assistant answers 201 when it created the entity and 200 when it updated one; the node reports the state object either way.
- Home Assistant requires an admin token for this call; a non-admin long-lived token fails with 401 even though the connection tests green.
Related Home Assistant nodes
See Set State run in a workflow.
In a technical demo we add the Home Assistant connection, drop the node on the canvas and let Workflow Health pre-flight it before the first real run.