mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-18 23:06:40 +00:00
Gauge Card: Fix if value is greater than max (#5887)
This commit is contained in:
parent
c88439ba2f
commit
67a3f5d87b
@ -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%;
|
||||
|
Loading…
x
Reference in New Issue
Block a user