Fix: correct evcc units (#4396)

This commit is contained in:
shamoon 2024-12-10 08:36:32 -08:00 committed by GitHub
parent 27f536c267
commit 01252c6193
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 14 deletions

View File

@ -120,7 +120,7 @@
"grid_power": "Grid", "grid_power": "Grid",
"home_power": "Consumption", "home_power": "Consumption",
"charge_power": "Charger", "charge_power": "Charger",
"watt_hour": "Wh" "kilowatt": "kW"
}, },
"flood": { "flood": {
"download": "Download", "download": "Download",

View File

@ -4,6 +4,10 @@ import Container from "components/services/widget/container";
import Block from "components/services/widget/block"; import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api"; import useWidgetAPI from "utils/proxy/use-widget-api";
function toKilowatts(t, value) {
return value > 0 ? t("common.number", { value: value / 1000, maximumFractionDigits: 1 }) : 0;
}
export default function Component({ service }) { export default function Component({ service }) {
const { t } = useTranslation(); const { t } = useTranslation();
@ -27,21 +31,12 @@ export default function Component({ service }) {
return ( return (
<Container service={service}> <Container service={service}>
<Block <Block label="evcc.pv_power" value={`${toKilowatts(t, stateData.result.pvPower)} ${t("evcc.kilowatt")}`} />
label="evcc.pv_power" <Block label="evcc.grid_power" value={`${toKilowatts(t, stateData.result.gridPower)} ${t("evcc.kilowatt")}`} />
value={`${t("common.number", { value: stateData.result.pvPower })} ${t("evcc.watt_hour")}`} <Block label="evcc.home_power" value={`${toKilowatts(t, stateData.result.homePower)} ${t("evcc.kilowatt")}`} />
/>
<Block
label="evcc.grid_power"
value={`${t("common.number", { value: stateData.result.gridPower })} ${t("evcc.watt_hour")}`}
/>
<Block
label="evcc.home_power"
value={`${t("common.number", { value: stateData.result.homePower })} ${t("evcc.watt_hour")}`}
/>
<Block <Block
label="evcc.charge_power" label="evcc.charge_power"
value={`${t("common.number", { value: stateData.result.loadpoints[0].chargePower })} ${t("evcc.watt_hour")}`} value={`${toKilowatts(t, stateData.result.loadpoints[0].chargePower)} ${t("evcc.kilowatt")}`}
/> />
</Container> </Container>
); );