From 4a622f9424cccfcd412a10ac64d8219409e4f840 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 1 Aug 2022 11:25:33 +0200 Subject: [PATCH] Tweak suggested_value in HA-form (#13316) --- src/components/ha-form/compute-initial-ha-form-data.ts | 5 ++++- src/components/ha-form/ha-form-integer.ts | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/ha-form/compute-initial-ha-form-data.ts b/src/components/ha-form/compute-initial-ha-form-data.ts index b83835ad70..6d24bbe531 100644 --- a/src/components/ha-form/compute-initial-ha-form-data.ts +++ b/src/components/ha-form/compute-initial-ha-form-data.ts @@ -6,7 +6,10 @@ export const computeInitialHaFormData = ( ): Record => { const data = {}; schema.forEach((field) => { - if (field.description?.suggested_value !== undefined) { + if ( + field.description?.suggested_value !== undefined && + field.description?.suggested_value !== null + ) { data[field.name] = field.description.suggested_value; } else if ("default" in field) { data[field.name] = field.default; diff --git a/src/components/ha-form/ha-form-integer.ts b/src/components/ha-form/ha-form-integer.ts index e71425ba27..3fe7389ab6 100644 --- a/src/components/ha-form/ha-form-integer.ts +++ b/src/components/ha-form/ha-form-integer.ts @@ -105,7 +105,8 @@ export class HaFormInteger extends LitElement implements HaFormElement { } return ( - this.schema.description?.suggested_value !== undefined || + (this.schema.description?.suggested_value !== undefined && + this.schema.description?.suggested_value !== null) || this.schema.default || this.schema.valueMin || 0