diff --git a/public/locales/de/common.json b/public/locales/de/common.json index 82164d8b..c4042cba 100644 --- a/public/locales/de/common.json +++ b/public/locales/de/common.json @@ -448,8 +448,9 @@ "streams_xepg": "XEPG Kanäle" }, "opendtu": { - "absoluteGeneration": "Gesamterzeugung", - "relativeGeneration": "Gesamterzeugung %", + "yieldDay": "Heute", + "absolutePower": "Produktion", + "relativePower": "Produktion %", "limit": "Limit" }, "opnsense": { diff --git a/public/locales/en/common.json b/public/locales/en/common.json index b0ce60d7..16648977 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -530,9 +530,10 @@ "streams_xepg": "XEPG Channels" }, "opendtu": { - "relativeGeneration": "Power Generation %", - "absoluteGeneration": "Power Generation", - "limit": "Power Limit" + "yieldDay": "Today", + "absolutePower": "Power", + "relativePower": "Power %", + "limit": "Limit" }, "opnsense": { "cpu": "CPU Load", diff --git a/src/widgets/opendtu/component.jsx b/src/widgets/opendtu/component.jsx index d9cad1a2..bd7c9fd8 100644 --- a/src/widgets/opendtu/component.jsx +++ b/src/widgets/opendtu/component.jsx @@ -9,37 +9,40 @@ export default function Component({ service }) { const { widget } = service; - const { data: opendtuLiveData, error: opendtuError } = useWidgetAPI(widget); + const { data: opendtuData, error: opendtuError } = useWidgetAPI(widget); if (opendtuError) { return ; } - if (!opendtuLiveData) { + if (!opendtuData) { return ( - - + + + ); } - const totalGeneration = opendtuLiveData.inverters.map(inverter => - Object.values(inverter.AC).map( - AC => AC.Power.v - ).reduce((a,b) => a+b)) - .reduce((a,b) => a+b); - - const totalLimit = opendtuLiveData.inverters.map(inverter => inverter.limit_absolute).reduce((a,b) => a+b); + const yieldDay = opendtuData.total.YieldDay.v + const yieldDayUnit = opendtuData.total.YieldDay.u - const usagePercentage = (totalGeneration / totalLimit) * 100 + const power = opendtuData.total.Power.v + const powerUnit = opendtuData.total.Power.u + + const totalLimit = opendtuData.inverters.map(inverter => inverter.limit_absolute).reduce((a,b) => a+b); + const totalLimitUnit = "W" + + const powerPercentage = (power / totalLimit) * 100 return ( - - - + + + + ); }