Skip to content

Commit

Permalink
Apply initial values to forms of device trigger extra fields (#20555)
Browse files Browse the repository at this point in the history
* Apply default values of device trigger extra fields

* use computeInitialHaFormData
  • Loading branch information
farmio authored Apr 22, 2024
1 parent b5277de commit 141107f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fireEvent } from "../../../../../common/dom/fire_event";
import "../../../../../components/device/ha-device-picker";
import "../../../../../components/device/ha-device-trigger-picker";
import "../../../../../components/ha-form/ha-form";
import { computeInitialHaFormData } from "../../../../../components/ha-form/compute-initial-ha-form-data";
import { fullEntitiesContext } from "../../../../../data/context";
import {
deviceAutomationsEqual,
Expand Down Expand Up @@ -44,7 +45,9 @@ export class HaDeviceTrigger extends LitElement {

private _extraFieldsData = memoizeOne(
(trigger: DeviceTrigger, capabilities: DeviceCapabilities) => {
const extraFieldsData: Record<string, any> = {};
const extraFieldsData = computeInitialHaFormData(
capabilities.extra_fields
);
capabilities.extra_fields.forEach((item) => {
if (trigger[item.name] !== undefined) {
extraFieldsData![item.name] = trigger[item.name];
Expand Down

0 comments on commit 141107f

Please sign in to comment.