Correctly parse number state for numeric input card feature (#24453)

This commit is contained in:
Paul Bottein 2025-02-28 16:46:53 +01:00 committed by Bram Kragten
parent 7120200fd4
commit 76b03d3a40

View File

@ -83,13 +83,16 @@ class HuiNumericInputCardFeature
const stateObj = this.stateObj;
const parsedState = Number(stateObj.state);
const value = !isNaN(parsedState) ? parsedState : undefined;
if (this._config.style === "buttons") {
return html`
<ha-control-number-buttons
value=${stateObj.state}
min=${stateObj.attributes.min}
max=${stateObj.attributes.max}
step=${stateObj.attributes.step}
.value=${value}
.min=${stateObj.attributes.min}
.max=${stateObj.attributes.max}
.step=${stateObj.attributes.step}
@value-changed=${this._setValue}
.disabled=${isUnavailableState(stateObj.state)}
.unit=${stateObj.attributes.unit_of_measurement}
@ -99,10 +102,10 @@ class HuiNumericInputCardFeature
}
return html`
<ha-control-slider
value=${stateObj.state}
min=${stateObj.attributes.min}
max=${stateObj.attributes.max}
step=${stateObj.attributes.step}
.value=${value}
.min=${stateObj.attributes.min}
.max=${stateObj.attributes.max}
.step=${stateObj.attributes.step}
@value-changed=${this._setValue}
.disabled=${isUnavailableState(stateObj.state)}
.unit=${stateObj.attributes.unit_of_measurement}