Gauge Card: Fix if value is greater than max (#5887)

This commit is contained in:
Zack Arnett 2020-05-15 11:21:53 -04:00 committed by GitHub
parent c88439ba2f
commit 67a3f5d87b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,6 +131,14 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
const sliderBarColor = this._computeSeverity(state);
let value: number | undefined;
if (this._config.max === null || isNaN(this._config.max!)) {
value = undefined;
} else {
value = Math.min(this._config.max!, state);
}
return html`
<ha-card
@click=${this._handleClick}
@ -143,7 +151,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
readonly
arcLength="180"
startAngle="180"
.value=${state}
.value=${value}
.min=${this._config.min}
.max=${this._config.max}
></round-slider>
@ -243,6 +251,10 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
}
private _measureCard() {
if (!this.isConnected) {
return;
}
if (this.offsetWidth < 200) {
this.setAttribute("narrow", "");
} else {
@ -257,6 +269,10 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
static get styles(): CSSResult {
return css`
:host {
display: block;
}
ha-card {
cursor: pointer;
height: 100%;