Script ID update with Alias (#12008)

This commit is contained in:
Zack Barett 2022-03-11 23:25:09 -06:00 committed by Zack
parent affa6a92e7
commit 307aa161a6

View File

@ -569,9 +569,13 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
}
private _aliasChanged(alias: string) {
if (this.scriptEntityId || this._entityId) {
if (
this.scriptEntityId ||
(this._entityId && this._entityId !== slugify(this._config!.alias))
) {
return;
}
const aliasSlugify = slugify(alias);
let id = aliasSlugify;
let i = 2;
@ -595,6 +599,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
private _valueChanged(ev: CustomEvent) {
ev.stopPropagation();
const values = ev.detail.value as any;
const currentId = this._entityId;
for (const key of Object.keys(values)) {
if (key === "sequence") {
@ -603,7 +608,10 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
const value = values[key];
if (value === this._config![key]) {
if (
value === this._config![key] ||
(key === "id" && currentId === value)
) {
continue;
}