From cd06b931a9e9504bb247ef3d3499398ac9e9c4d4 Mon Sep 17 00:00:00 2001 From: Philip Allgaier Date: Thu, 14 Jan 2021 12:25:06 +0100 Subject: [PATCH] Allow empty/undefined for counter min & max (#8154) --- src/panels/config/helpers/forms/ha-counter-form.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/panels/config/helpers/forms/ha-counter-form.ts b/src/panels/config/helpers/forms/ha-counter-form.ts index 723d9f134e..278d33edd3 100644 --- a/src/panels/config/helpers/forms/ha-counter-form.ts +++ b/src/panels/config/helpers/forms/ha-counter-form.ts @@ -44,8 +44,8 @@ class HaCounterForm extends LitElement { if (item) { this._name = item.name || ""; this._icon = item.icon || ""; - this._maximum = item.maximum; - this._minimum = item.minimum; + this._maximum = item.maximum ?? undefined; + this._minimum = item.minimum ?? undefined; this._restore = item.restore ?? true; this._step = item.step ?? 1; this._initial = item.initial ?? 0; @@ -163,7 +163,9 @@ class HaCounterForm extends LitElement { const configValue = target.configValue; const value = target.type === "number" - ? Number(ev.detail.value) + ? ev.detail.value !== "" + ? Number(ev.detail.value) + : undefined : target.localName === "ha-switch" ? (ev.target as HaSwitch).checked : ev.detail.value;