Ensure consistent number display for gauge (#8080)

This commit is contained in:
Philip Allgaier 2021-01-04 09:24:51 +01:00 committed by GitHub
parent 7f840e75df
commit 775e93d54b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,12 +122,14 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
`; `;
} }
// Use `stateObj.state` as value to keep formatting (e.g trailing zeros)
// for consistent value display across gauge, entity, entity-row, etc.
return html` return html`
<ha-card @click=${this._handleClick} tabindex="0"> <ha-card @click=${this._handleClick} tabindex="0">
<ha-gauge <ha-gauge
.min=${this._config.min!} .min=${this._config.min!}
.max=${this._config.max!} .max=${this._config.max!}
.value=${state} .value=${stateObj.state}
.language=${this.hass!.language} .language=${this.hass!.language}
.label=${this._config!.unit || .label=${this._config!.unit ||
this.hass?.states[this._config!.entity].attributes this.hass?.states[this._config!.entity].attributes