Skip to main content
Glama

Create or Update Automation

ha_config_set_automation
Destructive

Create or update Home Assistant automations with triggers, conditions, and actions; also enable, disable, run, or take control of blueprint-backed automations.

Instructions

Create or update a Home Assistant automation.

MUST call ha_get_skill_guide OR refer to your locally installed skills first.

Prefer native triggers/conditions/actions over templates in logic positions; templates belong only in data.*, notification text, event_data and variables. The best-practice checker reports violations under best_practice_warnings — fix them before re-submitting. triggers-and-conditions.md, automation-actions.md and template-guidelines.md ship under skill_content by default. Test any unavoidable template with ha_eval_template first.

Consider a dedicated tool first: a state snapshot with no trigger -> ha_config_set_scene; a value derived from other entities -> ha_config_set_helper(helper_type='template'); a counter / timer / schedule / boolean -> ha_config_set_helper.

MODES (pick one; each can also take enabled, which alone with entity_id turns the automation on or off without touching config):

  • python_transform: surgical edits to an existing automation. Requires entity_id and config_hash from ha_config_get_automation(). Operates on the stored config exactly as ha_config_get_automation returns it, e.g. python_transform="config['triggers'].append({'trigger': 'state', 'entity_id': 'binary_sensor.motion', 'to': 'on'})"

  • config: new automations or full restructures. Regular automations have triggers and actions; blueprint automations have use_blueprint {path, input}. Home Assistant validates the config, and a rejection carries its own error text.

  • take_control_of_blueprint: convert a blueprint-backed automation into a standalone one. Takes no config of its own.

IDENTITY: omit entity_id and config['id'] to create with a generated ID. Reusing an entity_id targets the same automation even if the alias changes; to rename or replace it, read it first and pass its config_hash — a changed alias without that hash is rejected before writing. operation says whether the write created or updated it.

EXAMPLES:

  • Create: ha_config_set_automation(config={"alias": "Morning Lights", "triggers": [{"trigger": "time", "at": "07:00:00"}], "actions": [{"action": "light.turn_on", "target": {"area_id": "bedroom"}}]})

  • From a blueprint: ha_config_set_automation(config={"alias": "Motion Light Kitchen", "use_blueprint": {"path": "homeassistant/motion_light.yaml", "input": {"motion_entity": "binary_sensor.kitchen_motion", "light_target": {"entity_id": "light.kitchen"}}}})

  • Update: current = ha_config_get_automation(entity_id="automation.x"); ha_config_set_automation(entity_id="automation.x", config_hash=current["config_hash"], config={...})

  • Disable: ha_config_set_automation(entity_id="automation.x", enabled=False)

  • Run now: ha_config_set_automation(entity_id="automation.x", run_actions=True)

  • Take control: ha_config_set_automation(entity_id="automation.x", take_control_of_blueprint=True)

TAKE CONTROL is one-way: later blueprint edits stop reaching the automation; to change an input value, update 'use_blueprint.input' instead. It does NOT free the blueprint — Home Assistant keeps counting the converted automation as a user, so deleting that blueprint stays refused until the automation is removed (an automation reload does not clear it). The response names the blueprint in took_control_of_blueprint. To preview the rendering without writing anything, use ha_manage_blueprints(action="substitute", path=..., input=...).

If a Claude Desktop user gets a 4-minute timeout with no result on this call, read the target back before repeating it, and tell them to wait a few seconds before clicking the manual-approve button, as clicking it too quickly is known to cause hangs in Claude Desktop. This workaround is specific to Claude Desktop.

create update modify edit automation triggers conditions actions new automation write save take control blueprint detach unlink standalone convert enable disable turn on off run trigger now

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "ha_config_set_automation"
  }
}

Input Schema

NameRequiredDescriptionDefault
waitNoWait for automation to be queryable before returning. Set to False for bulk operations.
configNoComplete automation configuration, written as given. Purpose-specific triggers/conditions (HA 2026.7+ default: 'trigger': '<domain>.<name>' with 'target'/'options') are valid config. Mutually exclusive with python_transform.
enabledNoTurn the automation on (True) or off (False) after an optional config update; None leaves it unchanged. Not written into the stored config: Home Assistant keeps the state across restarts, but a config 'initial_state' overrides it whenever the automation is reloaded or HA starts.
categoryNoCategory ID to assign to this automation. Use ha_config_get_category(scope='automation') to list available categories, or ha_config_set_category() to create one.
entity_idNoThe automation's entity_id (automation.x) or its config id; omit to create. An unused config id creates the automation under that id; values such as 'new' are literal ids, not placeholders.
config_hashNoConfig hash from ha_config_get_automation for optimistic locking. Required for python_transform and when a config update changes an existing automation's alias; otherwise optional for config updates (validates before full replacement if provided).
run_actionsNoRun the automation's actions now, skipping its triggers and conditions (automation.trigger, the UI's Run actions). Applied after `enabled` and after any config write. Can be used standalone with entity_id and no config.
MandatoryBPSNo
BestPracticeKeyNoRead-receipt for the home-assistant-best-practices skill; required when strict best-practices mode is enabled. Not a secret or credential: the current value is an attestation phrase published openly at the top of the skill content served by ha_get_skill_guide. Read that content, then pass the value back verbatim — this round-trip is the server's designed protocol confirming the practices were read before writing.
python_transformNoPython expression to transform existing automation config. Mutually exclusive with config. WARNING: Expressions with infinite loops will hang the server. Examples: Simple: python_transform="config['actions'][0]['data']['brightness'] = 255" Pattern: python_transform="for a in config['actions']: if a.get('alias') == 'My Step': a['data']['value'] = 100" PYTHON TRANSFORM SECURITY: ✅ ALLOWED: - Dictionary/list access: config['views'][0]['cards'][1] - Slicing: config['views'][0]['cards'][1:3] - Assignment: config['key'] = 'value' - Deletion: del config['key'] or config.pop('key') - List methods: append, insert, pop, remove, clear, extend, index, count, sort, reverse - Dict methods: update, get, setdefault, keys, values, items, pop, clear - Loops: for, if/else, pass, break, continue - Comprehensions: [x for x in ...], {k: v for ...}, (x for x in ...) - Ternary: x if condition else y - Iterable unpacking (* in calls/literals): f(*xs), [*xs, y] - Dict unpacking (**) in calls and dict literals: {**d, 'k': v} - Keyword arguments: func(key=value) - Lambdas (e.g. for `key=`): sorted(items, key=lambda x: x['score']) - String methods: startswith, endswith, lower, upper, strip, lstrip, rstrip, removeprefix, removesuffix, split, join, replace, count, index - Safe builtins: isinstance, len, range, enumerate, zip, sorted, reversed, min, max, sum, abs, any, all, round, str, int, float, bool, list, dict, tuple, set ❌ FORBIDDEN: - Imports: import, from, __import__ - File operations: open, read, write - Dunder access: __class__, __bases__, __subclasses__ - Dangerous builtins: eval, exec, compile, getattr, setattr, delattr, hasattr - Function definitions: def, class - Exception handling: try/except (validate with isinstance/in/.get() instead) - While loops: use bounded for loops or comprehensions instead
take_control_of_blueprintNoConvert a blueprint-backed automation into an editable standalone one -- the UI's "Take control". Renders the blueprint with its current inputs and saves the result over the same automation, which keeps its entity_id, alias and description and then has its own triggers/conditions/actions and no 'use_blueprint'. Requires entity_id; mutually exclusive with config and python_transform.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv9.2.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only declare destructiveHint=true and idempotentHint=false; the description goes far beyond them by disclosing that HA validates the config and returns its own error text, that a changed alias without config_hash is rejected before writing, that best_practice_warnings must be fixed before resubmitting, and that take-control is one-way and does not release the blueprint's user count. It also names the response fields ('operation', 'took_control_of_blueprint'), so the agent knows what to check after a write.

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

Conciseness3/5

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

Purpose is front-loaded and the MODES/IDENTITY/EXAMPLES structure is easy to scan, but the block is bloated: six worked examples plus a lengthy Claude Desktop timeout workaround paragraph that is client-specific troubleshooting rather than tool-selection guidance. Several points (mutual exclusivity of config and python_transform) are stated both in the description and the schema.

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

Completeness4/5

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

For an 11-parameter destructive write tool with an output schema and annotations, this covers the essential ground: identity/creation semantics, mode preconditions, validation feedback, and take-control consequences. Gaps are minor — `category` and `wait` are never discussed in the description, and the client-specific timeout advice is noise relative to those omissions.

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 91%, so the baseline is 3, but the description earns above baseline by explaining parameter interactions the schema states only in isolation: entity_id alone with enabled toggles state without a config write, run_actions can be used standalone, and the three modes are mutually exclusive. It still leaves `category`, `wait`, and `MandatoryBPS` largely to their schema text.

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?

Opens with a specific verb+resource ('Create or update a Home Assistant automation') and immediately differentiates itself from siblings by pointing at ha_config_set_scene and ha_config_set_helper for adjacent use cases. The three named modes make the scope of the write operation unambiguous.

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?

Explicitly routes the agent: dedicated tools first for snapshots, template-derived values, and counters/timers/schedules/booleans; then mode selection (python_transform for surgical edits, config for new/full restructures, take_control_of_blueprint for de-bluerpinting), each with prerequisites. It also states the preconditions for each path (entity_id + config_hash for python_transform, read-before-rename rule), which is exactly the when/when-not guidance this dimension rewards.

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