From f0a1ab831c3d3bdc90cf7874bd76070f56b323d5 Mon Sep 17 00:00:00 2001 From: TonyMathiesen <95135900+TonyMathiesen@users.noreply.github.com> Date: Tue, 15 Oct 2024 21:08:55 +0200 Subject: [PATCH] Scale battery voltage depending on battery system --- .../solax_modbus/plugin_growatt.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/custom_components/solax_modbus/plugin_growatt.py b/custom_components/solax_modbus/plugin_growatt.py index 15c911ca..76f9ac2c 100644 --- a/custom_components/solax_modbus/plugin_growatt.py +++ b/custom_components/solax_modbus/plugin_growatt.py @@ -113,6 +113,14 @@ def value_function_today_s_solar_energy(initval, descr, datadict): def value_function_combined_battery_power(initval, descr, datadict): return datadict.get('battery_charge_power', 0) - datadict.get('battery_discharge_power',0) +def value_function_battery_voltage(initval, descr, datadict): + bms = datadict.get('bms_monitoring_version', 0) + if bms == "ZECA": #Battery system APX HV (ZECA) uses 0.1 scaling factor for battery voltage + initval = initval / 10 + else: + initval = initval / 100 + return initval + # ================================= Button Declarations ============================================================ BUTTON_TYPES = [ @@ -4536,6 +4544,14 @@ def value_function_combined_battery_power(initval, descr, datadict): allowedtypes = GEN4, entity_category = EntityCategory.DIAGNOSTIC, ), + GrowattModbusSensorEntityDescription( + key = "bms_monitoring_version", + register = 3096, #used for battery voltage scaling + unit = REGISTER_STR, + wordcount=2, + allowedtypes = GEN4 | HYBRID, + internal = True, + ), GrowattModbusSensorEntityDescription( name = "Today's Battery Output Energy", key = "today_s_battery_output_energy", @@ -4773,7 +4789,7 @@ def value_function_combined_battery_power(initval, descr, datadict): device_class = SensorDeviceClass.VOLTAGE, register = 3169, register_type = REG_INPUT, - scale = 0.1, #doc says 0.01, but datasheet of APX HV system module for MOD / MID TL-XH (BP) inverters have operating voltage range 600-980V. + scale = value_function_battery_voltage, #due to different scaling factor depending on battery system, default scale 0.01 rounding = 2, allowedtypes = GEN4 | HYBRID, ),