Add evcc widget (#1473)

* added all evcc related files

* changed units

* bugfix changed first value to pvPower insted of homePower

* deleted proxy.js

* delted battary label and german translation

* Code style changes to evcc widget

---------

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
pull/1511/head v0.6.18
emre-54 2 years ago committed by GitHub
parent a0665c17b8
commit 03eb1b1112
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -91,6 +91,14 @@
"series": "Series",
"episodes": "Episodes",
"songs": "Songs"
},
"evcc": {
"pv_power": "Production",
"battery_soc": "Battery",
"grid_power": "Grid",
"home_power": "Consumption",
"charge_power": "Charger",
"watt_hour": "Wh"
},
"flood": {
"download": "Download",

@ -17,6 +17,7 @@ const components = {
docker: dynamic(() => import("./docker/component")),
kubernetes: dynamic(() => import("./kubernetes/component")),
emby: dynamic(() => import("./emby/component")),
evcc: dynamic(() => import("./evcc/component")),
fileflows: dynamic(() => import("./fileflows/component")),
flood: dynamic(() => import("./flood/component")),
freshrss: dynamic(() => import("./freshrss/component")),

@ -0,0 +1,36 @@
import { useTranslation } from "next-i18next";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
const { widget } = service;
const { data: stateData, error: stateError } = useWidgetAPI(widget, "state");
if (stateError) {
return <Container service={service} error={stateError} />;
}
if (!stateData) {
return (
<Container service={service}>,
<Block label="evcc.pv_power" />
<Block label="evcc.grid_power" />
<Block label="evcc.home_power" />
<Block label="evcc.charge_power"/>
</Container>
);
}
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.charge_power" value={`${t("common.number", { value: stateData.result.loadpoints[0].chargePower })} ${t("evcc.watt_hour")}`} />
</Container>
);
}

@ -0,0 +1,14 @@
import genericProxyHandler from "utils/proxy/handlers/generic";
const widget = {
api: "{url}/api/{endpoint}",
proxyHandler: genericProxyHandler,
mappings: {
state: {
endpoint: "state",
}
},
};
export default widget;

@ -12,6 +12,7 @@ import deluge from "./deluge/widget";
import diskstation from "./diskstation/widget";
import downloadstation from "./downloadstation/widget";
import emby from "./emby/widget";
import evcc from "./evcc/widget";
import fileflows from "./fileflows/widget";
import flood from "./flood/widget";
import freshrss from "./freshrss/widget";
@ -97,6 +98,7 @@ const widgets = {
diskstation,
downloadstation,
emby,
evcc,
fileflows,
flood,
freshrss,

Loading…
Cancel
Save