Allow empty/undefined for counter min & max (#8154)

This commit is contained in:
Philip Allgaier 2021-01-14 12:25:06 +01:00 committed by GitHub
parent fd2df92000
commit cd06b931a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;