From d52641b49516822e644bf26eb6232122f347810f Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Fri, 24 May 2024 06:06:40 -0700 Subject: [PATCH] Device trigger - sync value with initialHaFormData (#20810) Device trigger - sync yaml with initialHaFormData --- .../trigger/types/ha-automation-trigger-device.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts b/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts index fdd239e0115c..ad3b9877b0dc 100644 --- a/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts +++ b/src/panels/config/automation/trigger/types/ha-automation-trigger-device.ts @@ -3,6 +3,7 @@ import { css, html, LitElement } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoizeOne from "memoize-one"; import { fireEvent } from "../../../../../common/dom/fire_event"; +import { deepEqual } from "../../../../../common/util/deep-equal"; import "../../../../../components/device/ha-device-picker"; import "../../../../../components/device/ha-device-trigger-picker"; import "../../../../../components/ha-form/ha-form"; @@ -125,6 +126,20 @@ export class HaDeviceTrigger extends LitElement { this._capabilities = trigger.domain ? await fetchDeviceTriggerCapabilities(this.hass, trigger) : undefined; + + if (this._capabilities) { + // Match yaml to what is displayed in the form from computeInitialHaFormData + const newTrigger = { + ...this.trigger, + ...this._extraFieldsData(this.trigger, this._capabilities), + }; + + if (!deepEqual(this.trigger, newTrigger)) { + fireEvent(this, "value-changed", { + value: newTrigger, + }); + } + } } private _devicePicked(ev) {