Warn that only automations in automations.yaml are editable (#3200)

This commit is contained in:
Paulus Schoutsen 2019-05-23 12:28:17 -07:00 committed by GitHub
parent 9309c5a1b6
commit fe80c7fe0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View File

@ -147,18 +147,34 @@ class HaAutomationEditor extends LitElement {
"GET",
`config/automation/config/${this.automation.attributes.id}`
)
.then((config) => {
// Normalize data: ensure trigger, action and condition are lists
// Happens when people copy paste their automations into the config
for (const key of ["trigger", "condition", "action"]) {
const value = config[key];
if (value && !Array.isArray(value)) {
config[key] = [value];
.then(
(config) => {
// Normalize data: ensure trigger, action and condition are lists
// Happens when people copy paste their automations into the config
for (const key of ["trigger", "condition", "action"]) {
const value = config[key];
if (value && !Array.isArray(value)) {
config[key] = [value];
}
}
this._dirty = false;
this._config = config;
},
(resp) => {
alert(
resp.status_code === 404
? this.hass.localize(
"ui.panel.config.automation.editor.load_error_not_editable"
)
: this.hass.localize(
"ui.panel.config.automation.editor.load_error_unknown",
"err_no",
resp.status_code
)
);
history.back();
}
this._dirty = false;
this._config = config;
});
);
}
if (changedProps.has("creatingNew") && this.creatingNew && this.hass) {

View File

@ -642,6 +642,8 @@
"editor": {
"introduction": "Use automations to bring your home alive",
"default_name": "New Automation",
"load_error_not_editable": "Only automations in automations.yaml are editable.",
"load_error_unknown": "Error loading automation ({err_no}).",
"save": "Save",
"unsaved_confirm": "You have unsaved changes. Are you sure you want to leave?",
"alias": "Name",