mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-13 04:16:34 +00:00
Fix costs in energy csv download (#23322)
This commit is contained in:
parent
88d0247217
commit
ba3d37b550
@ -204,32 +204,43 @@ class PanelEnergy extends LitElement {
|
|||||||
type: string,
|
type: string,
|
||||||
statIds: string[],
|
statIds: string[],
|
||||||
unit: string,
|
unit: string,
|
||||||
costType?: string
|
costType?: string,
|
||||||
|
costStatIds?: string[]
|
||||||
) {
|
) {
|
||||||
if (statIds.length) {
|
if (statIds.length) {
|
||||||
statIds.forEach((stat) => processStat(stat, type, unit));
|
statIds.forEach((stat) => processStat(stat, type, unit));
|
||||||
if (costType) {
|
if (costType && costStatIds) {
|
||||||
statIds.forEach((stat) => {
|
costStatIds.forEach((stat) => processStat(stat, costType, currency));
|
||||||
const costStat = energyData.state.info.cost_sensors[stat];
|
|
||||||
if (energyData.state.info.cost_sensors[stat]) {
|
|
||||||
processStat(costStat, costType, currency);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const grid_consumptions: string[] = [];
|
const grid_consumptions: string[] = [];
|
||||||
const grid_productions: string[] = [];
|
const grid_productions: string[] = [];
|
||||||
|
const grid_consumptions_cost: string[] = [];
|
||||||
|
const grid_productions_cost: string[] = [];
|
||||||
energy_sources
|
energy_sources
|
||||||
.filter((s) => s.type === "grid")
|
.filter((s) => s.type === "grid")
|
||||||
.forEach((source) => {
|
.forEach((source) => {
|
||||||
source = source as GridSourceTypeEnergyPreference;
|
source = source as GridSourceTypeEnergyPreference;
|
||||||
source.flow_from.forEach((flowFrom) => {
|
source.flow_from.forEach((flowFrom) => {
|
||||||
grid_consumptions.push(flowFrom.stat_energy_from);
|
const statId = flowFrom.stat_energy_from;
|
||||||
|
grid_consumptions.push(statId);
|
||||||
|
const costId =
|
||||||
|
flowFrom.stat_cost || energyData.state.info.cost_sensors[statId];
|
||||||
|
if (costId) {
|
||||||
|
grid_consumptions_cost.push(costId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
source.flow_to.forEach((flowTo) => {
|
source.flow_to.forEach((flowTo) => {
|
||||||
grid_productions.push(flowTo.stat_energy_to);
|
const statId = flowTo.stat_energy_to;
|
||||||
|
grid_productions.push(statId);
|
||||||
|
const costId =
|
||||||
|
flowTo.stat_compensation ||
|
||||||
|
energyData.state.info.cost_sensors[statId];
|
||||||
|
if (costId) {
|
||||||
|
grid_productions_cost.push(costId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -237,13 +248,15 @@ class PanelEnergy extends LitElement {
|
|||||||
"grid_consumption",
|
"grid_consumption",
|
||||||
grid_consumptions,
|
grid_consumptions,
|
||||||
electricUnit,
|
electricUnit,
|
||||||
"grid_consumption_cost"
|
"grid_consumption_cost",
|
||||||
|
grid_consumptions_cost
|
||||||
);
|
);
|
||||||
printCategory(
|
printCategory(
|
||||||
"grid_return",
|
"grid_return",
|
||||||
grid_productions,
|
grid_productions,
|
||||||
electricUnit,
|
electricUnit,
|
||||||
"grid_return_compensation"
|
"grid_return_compensation",
|
||||||
|
grid_productions_cost
|
||||||
);
|
);
|
||||||
|
|
||||||
const battery_ins: string[] = [];
|
const battery_ins: string[] = [];
|
||||||
@ -270,33 +283,49 @@ class PanelEnergy extends LitElement {
|
|||||||
printCategory("solar_production", solar_productions, electricUnit);
|
printCategory("solar_production", solar_productions, electricUnit);
|
||||||
|
|
||||||
const gas_consumptions: string[] = [];
|
const gas_consumptions: string[] = [];
|
||||||
|
const gas_consumptions_cost: string[] = [];
|
||||||
energy_sources
|
energy_sources
|
||||||
.filter((s) => s.type === "gas")
|
.filter((s) => s.type === "gas")
|
||||||
.forEach((source) => {
|
.forEach((source) => {
|
||||||
source = source as GasSourceTypeEnergyPreference;
|
source = source as GasSourceTypeEnergyPreference;
|
||||||
gas_consumptions.push(source.stat_energy_from);
|
const statId = source.stat_energy_from;
|
||||||
|
gas_consumptions.push(statId);
|
||||||
|
const costId =
|
||||||
|
source.stat_cost || energyData.state.info.cost_sensors[statId];
|
||||||
|
if (costId) {
|
||||||
|
gas_consumptions_cost.push(costId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
printCategory(
|
printCategory(
|
||||||
"gas_consumption",
|
"gas_consumption",
|
||||||
gas_consumptions,
|
gas_consumptions,
|
||||||
gasUnit,
|
gasUnit,
|
||||||
"gas_consumption_cost"
|
"gas_consumption_cost",
|
||||||
|
gas_consumptions_cost
|
||||||
);
|
);
|
||||||
|
|
||||||
const water_consumptions: string[] = [];
|
const water_consumptions: string[] = [];
|
||||||
|
const water_consumptions_cost: string[] = [];
|
||||||
energy_sources
|
energy_sources
|
||||||
.filter((s) => s.type === "water")
|
.filter((s) => s.type === "water")
|
||||||
.forEach((source) => {
|
.forEach((source) => {
|
||||||
source = source as WaterSourceTypeEnergyPreference;
|
source = source as WaterSourceTypeEnergyPreference;
|
||||||
water_consumptions.push(source.stat_energy_from);
|
const statId = source.stat_energy_from;
|
||||||
|
water_consumptions.push(statId);
|
||||||
|
const costId =
|
||||||
|
source.stat_cost || energyData.state.info.cost_sensors[statId];
|
||||||
|
if (costId) {
|
||||||
|
water_consumptions_cost.push(costId);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
printCategory(
|
printCategory(
|
||||||
"water_consumption",
|
"water_consumption",
|
||||||
water_consumptions,
|
water_consumptions,
|
||||||
waterUnit,
|
waterUnit,
|
||||||
"water_consumption_cost"
|
"water_consumption_cost",
|
||||||
|
water_consumptions_cost
|
||||||
);
|
);
|
||||||
|
|
||||||
const devices: string[] = [];
|
const devices: string[] = [];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user