Write ESPHome device YAML config
esphome_write_configValidate YAML syntax and write a complete ESPHome device configuration to /config/esphome/, replacing any existing file only if validation succeeds.
Instructions
Write a full ESPHome device YAML config to /config/esphome/, overwriting any existing file.
Validates YAML syntax first (HA custom tags !secret/!include/
!lambda/!extend/!remove pass through unchanged) and only writes if
that succeeds. This replaces the whole file — there is no merge with
the previous content and, unlike git_safe_write_with_checkpoint, no
checkpoint commit is made first, so the previous content is not
recoverable through this tool.
Use when: saving a complete device config you already have in full,
e.g. after fetching and editing it with esphome_get_config.
Not for: a git-checkpointed config write — use
git_safe_write_with_checkpoint; for a generic /config file write use
files_write_config_file; for a single LVGL widget edit use
esphome_lvgl_add_widget/esphome_lvgl_delete_widget instead of
hand-editing the whole YAML text.
Returns: {"success": True, "name": ..., "path": ..., "bytes": ...} on
success; a remote external_components:/packages: source
(github:///gitlab:///codeberg:///git:///http(s)://, or a dict
with a url) adds "warning" (review before esphome_compile_device,
which fetches and runs it) and "external_sources": [...]; a config
with none, or only local (type: local, bare-path, !include) ones,
gets neither key.
Errors: {"success": False, "error": "YAML validation failed: ..."} for
invalid YAML; {"success": False, "error": "Invalid device name: ..."}
for a path-escaping name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Device name, with or without the '.yaml' suffix, e.g. 'kitchen_sensor'. If the file already exists, its entire content is replaced. | |
| content | Yes | Full YAML document to write, replacing the file's current content. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||