mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
parent
1bd6392a4c
commit
d4cbdab4a3
@ -102,10 +102,9 @@ class HuiEnergyCarbonGaugeCard extends LitElement implements LovelaceCard {
|
|||||||
|
|
||||||
const totalEnergyConsumed =
|
const totalEnergyConsumed =
|
||||||
totalGridConsumption +
|
totalGridConsumption +
|
||||||
(totalSolarProduction || 0) -
|
Math.max(0, (totalSolarProduction || 0) - (totalGridReturned || 0));
|
||||||
(totalGridReturned || 0);
|
|
||||||
|
|
||||||
value = round((highCarbonEnergy / totalEnergyConsumed) * 100);
|
value = round((1 - highCarbonEnergy / totalEnergyConsumed) * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
@ -104,17 +104,17 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
|
|||||||
) || 0;
|
) || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalConsumption =
|
const solarConsumption = Math.max(
|
||||||
totalGridConsumption +
|
0,
|
||||||
(totalSolarProduction || 0) -
|
(totalSolarProduction || 0) - (productionReturnedToGrid || 0)
|
||||||
(productionReturnedToGrid || 0);
|
);
|
||||||
|
|
||||||
|
const totalHomeConsumption = totalGridConsumption + solarConsumption;
|
||||||
|
|
||||||
let homeSolarCircumference: number | undefined;
|
let homeSolarCircumference: number | undefined;
|
||||||
if (hasSolarProduction) {
|
if (hasSolarProduction) {
|
||||||
const homePctSolar =
|
homeSolarCircumference =
|
||||||
((totalSolarProduction || 0) - (productionReturnedToGrid || 0)) /
|
CIRCLE_CIRCUMFERENCE * (solarConsumption / totalHomeConsumption);
|
||||||
totalConsumption;
|
|
||||||
homeSolarCircumference = CIRCLE_CIRCUMFERENCE * homePctSolar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let lowCarbonConsumption: number | undefined;
|
let lowCarbonConsumption: number | undefined;
|
||||||
@ -142,10 +142,8 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
|
|||||||
if (highCarbonConsumption !== null) {
|
if (highCarbonConsumption !== null) {
|
||||||
lowCarbonConsumption = totalGridConsumption - highCarbonConsumption;
|
lowCarbonConsumption = totalGridConsumption - highCarbonConsumption;
|
||||||
|
|
||||||
const homePctGridHighCarbon = highCarbonConsumption / totalConsumption;
|
|
||||||
|
|
||||||
homeHighCarbonCircumference =
|
homeHighCarbonCircumference =
|
||||||
CIRCLE_CIRCUMFERENCE * homePctGridHighCarbon;
|
CIRCLE_CIRCUMFERENCE * (highCarbonConsumption / totalHomeConsumption);
|
||||||
|
|
||||||
homeLowCarbonCircumference =
|
homeLowCarbonCircumference =
|
||||||
CIRCLE_CIRCUMFERENCE -
|
CIRCLE_CIRCUMFERENCE -
|
||||||
@ -154,15 +152,6 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
homeSolarCircumference = CIRCLE_CIRCUMFERENCE * 0.1;
|
|
||||||
|
|
||||||
homeHighCarbonCircumference = CIRCLE_CIRCUMFERENCE * 0.8;
|
|
||||||
|
|
||||||
homeLowCarbonCircumference =
|
|
||||||
CIRCLE_CIRCUMFERENCE -
|
|
||||||
(homeSolarCircumference || 0) -
|
|
||||||
homeHighCarbonCircumference;
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-card .header=${this._config.title}>
|
<ha-card .header=${this._config.title}>
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
@ -252,7 +241,7 @@ class HuiEnergyDistrubutionCard extends LitElement implements LovelaceCard {
|
|||||||
})}"
|
})}"
|
||||||
>
|
>
|
||||||
<ha-svg-icon .path="${mdiHome}"></ha-svg-icon>
|
<ha-svg-icon .path="${mdiHome}"></ha-svg-icon>
|
||||||
${formatNumber(totalConsumption, this.hass.locale, {
|
${formatNumber(totalHomeConsumption, this.hass.locale, {
|
||||||
maximumFractionDigits: 1,
|
maximumFractionDigits: 1,
|
||||||
})}
|
})}
|
||||||
kWh
|
kWh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user