Edit part of a config file in place
ha_edit_config_fileEdit part of a Home Assistant config file by replacing exact text snippets, avoiding full file rewrites. Validates edits and restores the file if configuration breaks.
Instructions
Change part of a text file under the config directory: each edit replaces one exact piece of text with another, and must match exactly once. Prefer this to ha_write_config_file for any change to an existing file: resending a 70 KB file to change three lines is slow and risks a slip anywhere in it. Nothing is written unless every edit applies. Afterwards the configuration is checked and the file put back if the edit broke it, as with ha_write_config_file. Requires the ha:files scope.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File relative to the config root, e.g. 'automations.yaml'. | |
| edits | Yes | Applied in order, each to the result of the one before. | |
| verify | No | Check the configuration afterwards and restore the file if it fails (default true). | |
| instance_id | Yes | The instance this edit is meant for (as listed by vomehome_list_instances). Required, and checked against the one this session is targeting; refused if they differ. |