Don't show fractions in energy percentage gauges (#17140)

This commit is contained in:
Bram Kragten 2023-07-03 10:56:40 +02:00 committed by GitHub
parent 0735b6475a
commit 21caac4240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View File

@ -21,6 +21,10 @@ import type { LovelaceCard } from "../../types";
import { severityMap } from "../hui-gauge-card";
import type { EnergyCarbonGaugeCardConfig } from "../types";
const FORMAT_OPTIONS = {
maximumFractionDigits: 0,
};
@customElement("hui-energy-carbon-consumed-gauge-card")
class HuiEnergyCarbonGaugeCard
extends SubscribeMixin(LitElement)
@ -129,6 +133,7 @@ class HuiEnergyCarbonGaugeCard
min="0"
max="100"
.value=${value}
.formatOptions=${FORMAT_OPTIONS}
.locale=${this.hass.locale}
label="%"
style=${styleMap({

View File

@ -19,6 +19,10 @@ import type { LovelaceCard } from "../../types";
import { severityMap } from "../hui-gauge-card";
import type { EnergySelfSufficiencyGaugeCardConfig } from "../types";
const FORMAT_OPTIONS = {
maximumFractionDigits: 0,
};
@customElement("hui-energy-self-sufficiency-gauge-card")
class HuiEnergySelfSufficiencyGaugeCard
extends SubscribeMixin(LitElement)
@ -174,8 +178,9 @@ class HuiEnergySelfSufficiencyGaugeCard
min="0"
max="100"
.value=${value}
.locale=${this.hass.locale}
label="%"
.formatOptions=${FORMAT_OPTIONS}
.locale=${this.hass.locale}
style=${styleMap({
"--gauge-color": this._computeSeverity(value),
})}

View File

@ -19,6 +19,10 @@ import type { LovelaceCard } from "../../types";
import { severityMap } from "../hui-gauge-card";
import type { EnergySolarGaugeCardConfig } from "../types";
const FORMAT_OPTIONS = {
maximumFractionDigits: 0,
};
@customElement("hui-energy-solar-consumed-gauge-card")
class HuiEnergySolarGaugeCard
extends SubscribeMixin(LitElement)
@ -109,8 +113,9 @@ class HuiEnergySolarGaugeCard
min="0"
max="100"
.value=${value}
.locale=${this.hass.locale}
label="%"
.formatOptions=${FORMAT_OPTIONS}
.locale=${this.hass.locale}
style=${styleMap({
"--gauge-color": this._computeSeverity(value),
})}