diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 167cbacaf..d6c2ae238 100755 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -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", diff --git a/src/widgets/components.js b/src/widgets/components.js index 8181321d0..66b4d4a03 100644 --- a/src/widgets/components.js +++ b/src/widgets/components.js @@ -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")), diff --git a/src/widgets/evcc/component.jsx b/src/widgets/evcc/component.jsx new file mode 100644 index 000000000..fad37f03d --- /dev/null +++ b/src/widgets/evcc/component.jsx @@ -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 ; + } + + if (!stateData) { + return ( + , + + + + + + ); + } + + return ( + + + + + + + ); +} \ No newline at end of file diff --git a/src/widgets/evcc/widget.js b/src/widgets/evcc/widget.js new file mode 100644 index 000000000..0c4a31ae5 --- /dev/null +++ b/src/widgets/evcc/widget.js @@ -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; \ No newline at end of file diff --git a/src/widgets/widgets.js b/src/widgets/widgets.js index cf0868f53..49e701248 100644 --- a/src/widgets/widgets.js +++ b/src/widgets/widgets.js @@ -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,