diff --git a/src/panels/config/automation/action/types/ha-automation-action-choose.ts b/src/panels/config/automation/action/types/ha-automation-action-choose.ts index 1b4bebb273..5add402d20 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-choose.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-choose.ts @@ -468,13 +468,16 @@ export class HaChooseAction extends LitElement implements ActionElement { private _defaultChanged(ev: CustomEvent) { ev.stopPropagation(); - const value = ev.detail.value as Action[]; - fireEvent(this, "value-changed", { - value: { - ...this.action, - default: value, - }, - }); + this._showDefault = true; + const defaultAction = ev.detail.value as Action[]; + const newValue: ChooseAction = { + ...this.action, + default: defaultAction, + }; + if (defaultAction.length === 0) { + delete newValue.default; + } + fireEvent(this, "value-changed", { value: newValue }); } static get styles(): CSSResultGroup { diff --git a/src/panels/config/automation/action/types/ha-automation-action-if.ts b/src/panels/config/automation/action/types/ha-automation-action-if.ts index 195590a689..a14fe2725d 100644 --- a/src/panels/config/automation/action/types/ha-automation-action-if.ts +++ b/src/panels/config/automation/action/types/ha-automation-action-if.ts @@ -117,14 +117,16 @@ export class HaIfAction extends LitElement implements ActionElement { private _elseChanged(ev: CustomEvent) { ev.stopPropagation(); - const value = ev.detail.value as Action[]; - - fireEvent(this, "value-changed", { - value: { - ...this.action, - else: value, - }, - }); + this._showElse = true; + const elseAction = ev.detail.value as Action[]; + const newValue: IfAction = { + ...this.action, + else: elseAction, + }; + if (elseAction.length === 0) { + delete newValue.else; + } + fireEvent(this, "value-changed", { value: newValue }); } static get styles(): CSSResultGroup {