Fix: correct evcc units
This commit is contained in:
parent
cb3248117f
commit
587d70e21c
@ -3,7 +3,7 @@ title: EVCC
|
||||
description: EVCC Widget Configuration
|
||||
---
|
||||
|
||||
Learn more about [EVSS](https://github.com/evcc-io/evcc).
|
||||
Learn more about [EVCC](https://github.com/evcc-io/evcc).
|
||||
|
||||
Allowed fields: `["pv_power", "grid_power", "home_power", "charge_power]`.
|
||||
|
||||
|
||||
@ -120,7 +120,7 @@
|
||||
"grid_power": "Grid",
|
||||
"home_power": "Consumption",
|
||||
"charge_power": "Charger",
|
||||
"watt_hour": "Wh"
|
||||
"kilowatt": "kW"
|
||||
},
|
||||
"flood": {
|
||||
"download": "Download",
|
||||
|
||||
@ -4,6 +4,11 @@ import Container from "components/services/widget/container";
|
||||
import Block from "components/services/widget/block";
|
||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||
|
||||
function toKilowatts(value) {
|
||||
const { t } = useTranslation();
|
||||
return value > 0 ? t("common.number", { value: value / 1000, maximumFractionDigits: 1 }) : 0;
|
||||
}
|
||||
|
||||
export default function Component({ service }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
@ -27,21 +32,12 @@ export default function Component({ service }) {
|
||||
|
||||
return (
|
||||
<Container service={service}>
|
||||
<Block
|
||||
label="evcc.pv_power"
|
||||
value={`${t("common.number", { value: stateData.result.pvPower })} ${t("evcc.watt_hour")}`}
|
||||
/>
|
||||
<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 label="evcc.pv_power" value={`${toKilowatts(stateData.result.pvPower)} ${t("evcc.kilowatt")}`} />
|
||||
<Block label="evcc.grid_power" value={`${toKilowatts(stateData.result.gridPower)} ${t("evcc.kilowatt")}`} />
|
||||
<Block label="evcc.home_power" value={`${toKilowatts(stateData.result.homePower)} ${t("evcc.kilowatt")}`} />
|
||||
<Block
|
||||
label="evcc.charge_power"
|
||||
value={`${t("common.number", { value: stateData.result.loadpoints[0].chargePower })} ${t("evcc.watt_hour")}`}
|
||||
value={`${toKilowatts(stateData.result.loadpoints[0].chargePower)} ${t("evcc.kilowatt")}`}
|
||||
/>
|
||||
</Container>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user