diff --git a/goodwe_controller/app/chargers.py b/goodwe_controller/app/chargers.py index 45cd67c..0973283 100644 --- a/goodwe_controller/app/chargers.py +++ b/goodwe_controller/app/chargers.py @@ -87,7 +87,9 @@ REQUIRED = ("current", "readback", "state", "power") _SETPOINT_RE = re.compile(r"^number\.(?P.+)_" + SETPOINT_SUFFIX + "$") _ROLE_ORDER = tuple(ROLES) -POWER_UNITS = ("mW", "W", "kW", "MW") # every HA power unit, converted +#: power unit -> W. The probe and the reading both use this one table. +_W_PER = {"mW": 0.001, "W": 1.0, "kW": 1000.0, "MW": 1000000.0} +POWER_UNITS = tuple(_W_PER) def census_key(entity) -> str: @@ -155,9 +157,6 @@ def _amps(obj): return None -_W_PER = {"mW": 0.001, "W": 1.0, "kW": 1000.0, "MW": 1000000.0} - - def _watts(obj): """Power in W, believed only in a power unit (its own copy of the rule: the PV channel's reader stays out of the charger's, test_pv.py part 6)."""