Some fixes for low carbon display (#14020)

This commit is contained in:
Paul Bottein 2022-10-10 16:21:02 +02:00 committed by GitHub
parent 3a41b4e65b
commit 05f2ef8a37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 15 deletions

View File

@ -85,10 +85,6 @@ class HuiEnergyCarbonGaugeCard
let value: number | undefined; let value: number | undefined;
if (totalGridConsumption === 0) {
value = 100;
}
if (this._data.fossilEnergyConsumption && totalGridConsumption) { if (this._data.fossilEnergyConsumption && totalGridConsumption) {
const highCarbonEnergy = this._data.fossilEnergyConsumption const highCarbonEnergy = this._data.fossilEnergyConsumption
? Object.values(this._data.fossilEnergyConsumption).reduce( ? Object.values(this._data.fossilEnergyConsumption).reduce(
@ -141,12 +137,12 @@ class HuiEnergyCarbonGaugeCard
></ha-gauge> ></ha-gauge>
<div class="name"> <div class="name">
${this.hass.localize( ${this.hass.localize(
"ui.panel.lovelace.cards.energy.carbon_consumed_gauge.non_fossil_energy_consumed" "ui.panel.lovelace.cards.energy.carbon_consumed_gauge.low_carbon_energy_consumed"
)} )}
</div> </div>
` `
: html`${this.hass.localize( : html`${this.hass.localize(
"ui.panel.lovelace.cards.energy.carbon_consumed_gauge.non_fossil_energy_not_calculated" "ui.panel.lovelace.cards.energy.carbon_consumed_gauge.low_carbon_energy_not_calculated"
)}`} )}`}
</ha-card> </ha-card>
`; `;

View File

@ -262,7 +262,7 @@ class HuiEnergyDistrubutionCard
: html`<div class="circle-container low-carbon"> : html`<div class="circle-container low-carbon">
<span class="label" <span class="label"
>${this.hass.localize( >${this.hass.localize(
"ui.panel.lovelace.cards.energy.energy_distribution.non_fossil" "ui.panel.lovelace.cards.energy.energy_distribution.low_carbon"
)}</span )}</span
> >
<a <a
@ -272,11 +272,9 @@ class HuiEnergyDistrubutionCard
rel="noopener no referrer" rel="noopener no referrer"
> >
<ha-svg-icon .path=${mdiLeaf}></ha-svg-icon> <ha-svg-icon .path=${mdiLeaf}></ha-svg-icon>
${lowCarbonEnergy ${formatNumber(lowCarbonEnergy || 0, this.hass.locale, {
? formatNumber(lowCarbonEnergy, this.hass.locale, { maximumFractionDigits: 1,
maximumFractionDigits: 1, })}
})
: "—"}
kWh kWh
</a> </a>
<svg width="80" height="30"> <svg width="80" height="30">

View File

@ -3691,7 +3691,7 @@
"grid": "Grid", "grid": "Grid",
"gas": "Gas", "gas": "Gas",
"solar": "Solar", "solar": "Solar",
"non_fossil": "Non-fossil", "low_carbon": "Low-carbon",
"home": "Home", "home": "Home",
"battery": "Battery", "battery": "Battery",
"go_to_energy_dashboard": "Go to the energy dashboard" "go_to_energy_dashboard": "Go to the energy dashboard"
@ -3702,8 +3702,8 @@
}, },
"carbon_consumed_gauge": { "carbon_consumed_gauge": {
"card_indicates_energy_used": "This card indicates how much of the energy consumed by your home was generated using non-fossil fuels like solar, wind and nuclear. The higher, the better!", "card_indicates_energy_used": "This card indicates how much of the energy consumed by your home was generated using non-fossil fuels like solar, wind and nuclear. The higher, the better!",
"non_fossil_energy_consumed": "Non-fossil energy consumed", "low_carbon_energy_consumed": "Low-carbon energy consumed",
"non_fossil_energy_not_calculated": "Consumed non-fossil energy couldn't be calculated" "low_carbon_energy_not_calculated": "Consumed low-carbon energy couldn't be calculated"
} }
} }
}, },