mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-08 10:29:37 +00:00
Normalize automation config (#13938)
* Normalize automation config * gen * Update ha-automation-action-choose.ts
This commit is contained in:
@@ -469,15 +469,9 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
) {
|
||||
fetchScriptFileConfig(this.hass, this.scriptId).then(
|
||||
(config) => {
|
||||
// Normalize data: ensure sequence is a list
|
||||
// Happens when people copy paste their scripts into the config
|
||||
const value = config.sequence;
|
||||
if (value && !Array.isArray(value)) {
|
||||
config.sequence = [value];
|
||||
}
|
||||
this._dirty = false;
|
||||
this._readOnly = false;
|
||||
this._config = config;
|
||||
this._config = this._normalizeConfig(config);
|
||||
},
|
||||
(resp) => {
|
||||
const entity = Object.values(this.hass.entities).find(
|
||||
@@ -524,7 +518,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
|
||||
if (changedProps.has("entityId") && this.entityId) {
|
||||
getScriptStateConfig(this.hass, this.entityId).then((c) => {
|
||||
this._config = c.config;
|
||||
this._config = this._normalizeConfig(c.config);
|
||||
});
|
||||
const regEntry = this.hass.entities[this.entityId];
|
||||
if (regEntry?.unique_id) {
|
||||
@@ -536,6 +530,16 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
|
||||
}
|
||||
}
|
||||
|
||||
private _normalizeConfig(config: ScriptConfig): ScriptConfig {
|
||||
// Normalize data: ensure sequence is a list
|
||||
// Happens when people copy paste their scripts into the config
|
||||
const value = config.sequence;
|
||||
if (value && !Array.isArray(value)) {
|
||||
config.sequence = [value];
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private _computeLabelCallback = (
|
||||
schema: SchemaUnion<ReturnType<typeof this._schema>>,
|
||||
data: HaFormDataContainer
|
||||
|
||||
Reference in New Issue
Block a user