From 5d93ed6d1c0a50acebfebbd33a6b1fa984b4f4b7 Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:23:49 +0200 Subject: [PATCH 1/7] New Module for Solax Gen5 Added new Module vor Solax GEN5 Inverters with up to 3 PV Strings and up to 2 Batteries --- .../devices/solax/solax_gen5/__init__.py | 0 .../modules/devices/solax/solax_gen5/bat.py | 54 ++++++++++++++ .../devices/solax/solax_gen5/config.py | 66 +++++++++++++++++ .../devices/solax/solax_gen5/counter.py | 70 +++++++++++++++++++ .../devices/solax/solax_gen5/device.py | 48 +++++++++++++ .../devices/solax/solax_gen5/inverter.py | 44 ++++++++++++ 6 files changed, 282 insertions(+) create mode 100644 packages/modules/devices/solax/solax_gen5/__init__.py create mode 100644 packages/modules/devices/solax/solax_gen5/bat.py create mode 100644 packages/modules/devices/solax/solax_gen5/config.py create mode 100644 packages/modules/devices/solax/solax_gen5/counter.py create mode 100644 packages/modules/devices/solax/solax_gen5/device.py create mode 100644 packages/modules/devices/solax/solax_gen5/inverter.py diff --git a/packages/modules/devices/solax/solax_gen5/__init__.py b/packages/modules/devices/solax/solax_gen5/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/modules/devices/solax/solax_gen5/bat.py b/packages/modules/devices/solax/solax_gen5/bat.py new file mode 100644 index 0000000000..7039569d54 --- /dev/null +++ b/packages/modules/devices/solax/solax_gen5/bat.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +from typing import Dict, Union + +from dataclass_utils import dataclass_from_dict +from modules.common import modbus +from modules.common.abstract_device import AbstractBat +from modules.common.component_state import BatState +from modules.common.component_type import ComponentDescriptor +from modules.common.fault_state import ComponentInfo, FaultState +from modules.common.modbus import ModbusDataType +from modules.common.simcount import SimCounter +from modules.common.store import get_bat_value_store +from modules.devices.solax.solax_gen5.config import SolaxGen5BatSetup + + +class SolaxGen5Bat(AbstractBat): + def __init__(self, + device_id: int, + component_config: Union[Dict, SolaxGen5BatSetup], + tcp_client: modbus.ModbusTcpClient_, + modbus_id: int) -> None: + self.__device_id = device_id + self.__modbus_id = modbus_id + self.component_config = dataclass_from_dict(SolaxGen5BatSetup, component_config) + self.__tcp_client = tcp_client + self.sim_counter = SimCounter(self.__device_id, self.component_config.id, prefix="speicher") + self.store = get_bat_value_store(self.component_config.id) + self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config)) + + def update(self) -> None: + with self.__tcp_client: + power_bat1 = self.__tcp_client.read_input_registers(22, ModbusDataType.INT_16, unit=self.__modbus_id) + power_bat2 = self.__tcp_client.read_input_registers(297, ModbusDataType.INT_16, unit=self.__modbus_id) + power = power_bat1 + power_bat2 + try: + soc = self.__tcp_client.read_input_registers(302, ModbusDataType.UINT_16, unit=self.__modbus_id) + except Exception: + soc = self.__tcp_client.read_input_registers(28, ModbusDataType.UINT_16, unit=self.__modbus_id) + + try: + imported = self.__tcp_client.read_input_registers(35, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + exported = self.__tcp_client.read_input_registers(32, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + except Exception: + imported, exported = self.sim_counter.sim_count(power) + + bat_state = BatState( + power=power, + soc=soc, + imported=imported, + exported=exported + ) + self.store.set(bat_state) + +component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5BatSetup) diff --git a/packages/modules/devices/solax/solax_gen5/config.py b/packages/modules/devices/solax/solax_gen5/config.py new file mode 100644 index 0000000000..c698718216 --- /dev/null +++ b/packages/modules/devices/solax/solax_gen5/config.py @@ -0,0 +1,66 @@ +from typing import Optional + +from modules.common.component_setup import ComponentSetup +from ..vendor import vendor_descriptor + + +class SolaxGen5Configuration: + def __init__(self, modbus_id: int = 1, ip_address: Optional[str] = None, port: int = 502): + self.modbus_id = modbus_id + self.ip_address = ip_address + self.port = port + + +class SolaxGen5: + def __init__(self, + name: str = "Solax Gen5", + type: str = "solax_gen5", + id: int = 0, + configuration: SolaxGen5Configuration = None) -> None: + self.name = name + self.type = type + self.vendor = vendor_descriptor.configuration_factory().type + self.id = id + self.configuration = configuration or SolaxGen5Configuration() + + +class SolaxGen5BatConfiguration: + def __init__(self): + pass + + +class SolaxGen5BatSetup(ComponentSetup[SolaxGen5BatConfiguration]): + def __init__(self, + name: str = "Solax Speicher", + type: str = "bat", + id: int = 0, + configuration: SolaxGen5BatConfiguration = None) -> None: + super().__init__(name, type, id, configuration or SolaxGen5BatConfiguration()) + + +class SolaxGen5CounterConfiguration: + def __init__(self): + pass + + +class SolaxGen5CounterSetup(ComponentSetup[SolaxGen5CounterConfiguration]): + def __init__(self, + name: str = "Solax Zähler", + type: str = "counter", + id: int = 0, + configuration: SolaxGen5CounterConfiguration = None) -> None: + super().__init__(name, type, id, configuration or SolaxGen5CounterConfiguration()) + + +class SolaxGen5InverterConfiguration: + def __init__(self): + pass + + +class SolaxGen5InverterSetup(ComponentSetup[SolaxGen5InverterConfiguration]): + def __init__(self, + name: str = "Solax Wechselrichter", + type: str = "inverter", + id: int = 0, + configuration: SolaxGen5InverterConfiguration = None) -> None: + super().__init__(name, type, id, configuration or SolaxGen5InverterConfiguration()) diff --git a/packages/modules/devices/solax/solax_gen5/counter.py b/packages/modules/devices/solax/solax_gen5/counter.py new file mode 100644 index 0000000000..cc52449dd9 --- /dev/null +++ b/packages/modules/devices/solax/solax_gen5/counter.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python3 +from typing import Dict, Union +from pymodbus.constants import Endian + +from dataclass_utils import dataclass_from_dict +from modules.common import modbus +from modules.common.abstract_device import AbstractCounter +from modules.common.component_state import CounterState +from modules.common.component_type import ComponentDescriptor +from modules.common.fault_state import ComponentInfo, FaultState +from modules.common.modbus import ModbusDataType +from modules.common.store import get_counter_value_store +from modules.devices.solax.solax_gen5.config import SolaxGen5CounterSetup + + +class SolaxGen5Counter(AbstractCounter): + def __init__(self, + device_id: int, + component_config: Union[Dict, SolaxGen5CounterSetup], + tcp_client: modbus.ModbusTcpClient_, + modbus_id: int) -> None: + + self.component_config = dataclass_from_dict(SolaxGen5CounterSetup, component_config) + self.__modbus_id = modbus_id + self.__tcp_client = tcp_client + self.store = get_counter_value_store(self.component_config.id) + self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config)) + + def update(self): + with self.__tcp_client: + power = self.__tcp_client.read_input_registers(70, ModbusDataType.INT_32, wordorder=Endian.Little, unit=self.__modbus_id) * -1 + frequency = self.__tcp_client.read_input_registers(7, ModbusDataType.UINT_16, unit=self.__modbus_id) / 100 + voltages = [value / 10 + for value in self.__tcp_client.read_input_registers( + 202, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id + )] + + currents = [(65535 - value) / 10 + for value in self.__tcp_client.read_input_registers( + 206, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id + )] + + power_factors = [value / 100 + for value in self.__tcp_client.read_input_registers( + 197, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id + )] + + powers = [-value for value in self.__tcp_client.read_input_registers( + 130, [ModbusDataType.INT_32] * 3, wordorder=Endian.Little, unit=self.__modbus_id + )] + + exported, imported = [value * 10 + for value in self.__tcp_client.read_input_registers( + 72, [ModbusDataType.UINT_32] * 2, wordorder=Endian.Little, unit=self.__modbus_id + )] + + counter_state = CounterState( + imported=imported, + exported=exported, + power=power, + powers=powers, + frequency=frequency, + voltages=voltages, + currents=currents, + power_factors=power_factors + ) + self.store.set(counter_state) + + +component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5CounterSetup) diff --git a/packages/modules/devices/solax/solax_gen5/device.py b/packages/modules/devices/solax/solax_gen5/device.py new file mode 100644 index 0000000000..cb8db1c355 --- /dev/null +++ b/packages/modules/devices/solax/solax_gen5/device.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +import logging +from typing import Iterable, Union + +from modules.common.abstract_device import DeviceDescriptor +from modules.common.component_context import SingleComponentUpdateContext +from modules.common.configurable_device import ComponentFactoryByType, ConfigurableDevice, MultiComponentUpdater +from modules.common.modbus import ModbusTcpClient_ +from modules.devices.solax.solax_gen5.bat import SolaxGen5Bat +from modules.devices.solax.solax_gen5.config import SolaxGen5, SolaxGen5BatSetup, SolaxGen5CounterSetup, SolaxGen5InverterSetup +from modules.devices.solax.solax_gen5.counter import SolaxGen5Counter +from modules.devices.solax.solax_gen5.inverter import SolaxGen5Inverter + +log = logging.getLogger(__name__) + + +def create_device(device_config: SolaxGen5): + def create_bat_component(component_config: SolaxGen5BatSetup): + return SolaxGen5Bat(device_config.id, component_config, client, device_config.configuration.modbus_id) + + def create_counter_component(component_config: SolaxGen5CounterSetup): + return SolaxGen5Counter(device_config.id, component_config, client, device_config.configuration.modbus_id) + + def create_inverter_component(component_config: SolaxGen5InverterSetup): + return SolaxGen5Inverter(device_config.id, component_config, client, device_config.configuration.modbus_id) + + def update_components(components: Iterable[Union[SolaxGen5Bat, SolaxGen5Counter, SolaxGen5Inverter]]): + with client: + for component in components: + with SingleComponentUpdateContext(component.fault_state): + component.update() + + try: + client = ModbusTcpClient_(device_config.configuration.ip_address, device_config.configuration.port) + except Exception: + log.exception("Fehler in create_device") + return ConfigurableDevice( + device_config=device_config, + component_factory=ComponentFactoryByType( + bat=create_bat_component, + counter=create_counter_component, + inverter=create_inverter_component, + ), + component_updater=MultiComponentUpdater(update_components) + ) + + +device_descriptor = DeviceDescriptor(configuration_factory=SolaxGen5) diff --git a/packages/modules/devices/solax/solax_gen5/inverter.py b/packages/modules/devices/solax/solax_gen5/inverter.py new file mode 100644 index 0000000000..152e33e481 --- /dev/null +++ b/packages/modules/devices/solax/solax_gen5/inverter.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +from typing import Dict, Union +from pymodbus.constants import Endian + +from dataclass_utils import dataclass_from_dict +from modules.common import modbus +from modules.common.abstract_device import AbstractInverter +from modules.common.component_state import InverterState +from modules.common.component_type import ComponentDescriptor +from modules.common.fault_state import ComponentInfo, FaultState +from modules.common.modbus import ModbusDataType +from modules.common.store import get_inverter_value_store +from modules.devices.solax.solax_gen5.config import SolaxGen5InverterSetup + + +class SolaxGen5Inverter(AbstractInverter): + def __init__(self, + device_id: int, + component_config: Union[Dict, SolaxGen5InverterSetup], + tcp_client: modbus.ModbusTcpClient_, + modbus_id: int) -> None: + self.component_config = dataclass_from_dict(SolaxGen5InverterSetup, component_config) + self.__modbus_id = modbus_id + self.__tcp_client = tcp_client + self.store = get_inverter_value_store(self.component_config.id) + self.fault_state = FaultState(ComponentInfo.from_component_config(self.component_config)) + + def update(self) -> None: + with self.__tcp_client: + power_pv1 = self.__tcp_client.read_input_registers(10, ModbusDataType.UINT_16, unit=self.__modbus_id) * -1 + power_pv2 = self.__tcp_client.read_input_registers(11, ModbusDataType.UINT_16, unit=self.__modbus_id) * -1 + power_pv3 = self.__tcp_client.read_input_registers(292, ModbusDataType.UINT_16, unit=self.__modbus_id) * -1 + power_temp = (power_pv1, power_pv2, power_pv3) + power = sum(power_temp) + exported = self.__tcp_client.read_input_registers(80, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + + inverter_state = InverterState( + power=power, + exported=exported + ) + self.store.set(inverter_state) + + +component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5InverterSetup) From 2152ab23c806fbfceabc13b9560c1eebf5422975 Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Fri, 1 Nov 2024 06:18:00 +0100 Subject: [PATCH 2/7] Update inverter.py Error: packages/modules/devices/solax/solax_gen5/inverter.py:3:1: F401 'pymodbus.constants.Endian' imported but unused --- packages/modules/devices/solax/solax_gen5/inverter.py | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/modules/devices/solax/solax_gen5/inverter.py b/packages/modules/devices/solax/solax_gen5/inverter.py index 152e33e481..b48651a59d 100644 --- a/packages/modules/devices/solax/solax_gen5/inverter.py +++ b/packages/modules/devices/solax/solax_gen5/inverter.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 from typing import Dict, Union -from pymodbus.constants import Endian from dataclass_utils import dataclass_from_dict from modules.common import modbus From def46f8c837bd52ac2330e77b38b9b9bcd7a3c2c Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Fri, 1 Nov 2024 06:20:27 +0100 Subject: [PATCH 3/7] Update bat.py Error: packages/modules/devices/solax/solax_gen5/bat.py:36:15: E111 indentation is not a multiple of 4 Error: packages/modules/devices/solax/solax_gen5/bat.py:38:15: E111 indentation is not a multiple of 4 Error: packages/modules/devices/solax/solax_gen5/bat.py:41:15: E111 indentation is not a multiple of 4 Error: packages/modules/devices/solax/solax_gen5/bat.py:42:15: E111 indentation is not a multiple of 4 Error: packages/modules/devices/solax/solax_gen5/bat.py:44:15: E111 indentation is not a multiple of 4 Error: packages/modules/devices/solax/solax_gen5/bat.py:54:1: E305 expected 2 blank lines after class or function definition, found 1 --- packages/modules/devices/solax/solax_gen5/bat.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/modules/devices/solax/solax_gen5/bat.py b/packages/modules/devices/solax/solax_gen5/bat.py index 7039569d54..1ce4d5734b 100644 --- a/packages/modules/devices/solax/solax_gen5/bat.py +++ b/packages/modules/devices/solax/solax_gen5/bat.py @@ -33,15 +33,15 @@ def update(self) -> None: power_bat2 = self.__tcp_client.read_input_registers(297, ModbusDataType.INT_16, unit=self.__modbus_id) power = power_bat1 + power_bat2 try: - soc = self.__tcp_client.read_input_registers(302, ModbusDataType.UINT_16, unit=self.__modbus_id) + soc = self.__tcp_client.read_input_registers(302, ModbusDataType.UINT_16, unit=self.__modbus_id) except Exception: - soc = self.__tcp_client.read_input_registers(28, ModbusDataType.UINT_16, unit=self.__modbus_id) + soc = self.__tcp_client.read_input_registers(28, ModbusDataType.UINT_16, unit=self.__modbus_id) try: - imported = self.__tcp_client.read_input_registers(35, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 - exported = self.__tcp_client.read_input_registers(32, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + imported = self.__tcp_client.read_input_registers(35, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + exported = self.__tcp_client.read_input_registers(32, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 except Exception: - imported, exported = self.sim_counter.sim_count(power) + imported, exported = self.sim_counter.sim_count(power) bat_state = BatState( power=power, @@ -52,3 +52,4 @@ def update(self) -> None: self.store.set(bat_state) component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5BatSetup) + From bd7f2e1f90a73403c52ea59905bebc25a8083317 Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Fri, 1 Nov 2024 06:31:06 +0100 Subject: [PATCH 4/7] Update counter.py Error: packages/modules/devices/solax/solax_gen5/counter.py:31:121: E501 line too long (138 > 120 characters) Error: packages/modules/devices/solax/solax_gen5/counter.py:46:29: E122 continuation line missing indentation or outdented Error: packages/modules/devices/solax/solax_gen5/counter.py:50:22: E124 closing bracket does not match visual indentation Warning: packages/modules/devices/solax/solax_gen5/counter.py:51:1: W293 blank line contains whitespace --- .../modules/devices/solax/solax_gen5/counter.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/modules/devices/solax/solax_gen5/counter.py b/packages/modules/devices/solax/solax_gen5/counter.py index cc52449dd9..3c222fcc36 100644 --- a/packages/modules/devices/solax/solax_gen5/counter.py +++ b/packages/modules/devices/solax/solax_gen5/counter.py @@ -28,27 +28,28 @@ def __init__(self, def update(self): with self.__tcp_client: - power = self.__tcp_client.read_input_registers(70, ModbusDataType.INT_32, wordorder=Endian.Little, unit=self.__modbus_id) * -1 + power = self.__tcp_client.read_input_registers(70, ModbusDataType.INT_32, wordorder=Endian.Little, + unit=self.__modbus_id) * -1 frequency = self.__tcp_client.read_input_registers(7, ModbusDataType.UINT_16, unit=self.__modbus_id) / 100 voltages = [value / 10 for value in self.__tcp_client.read_input_registers( 202, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id - )] + )] currents = [(65535 - value) / 10 for value in self.__tcp_client.read_input_registers( 206, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id - )] + )] power_factors = [value / 100 - for value in self.__tcp_client.read_input_registers( - 197, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id + for value in self.__tcp_client.read_input_registers( + 197, [ModbusDataType.UINT_16] * 3, unit=self.__modbus_id )] powers = [-value for value in self.__tcp_client.read_input_registers( - 130, [ModbusDataType.INT_32] * 3, wordorder=Endian.Little, unit=self.__modbus_id + 130, [ModbusDataType.INT_32] * 3, wordorder=Endian.Little, unit=self.__modbus_id )] - + exported, imported = [value * 10 for value in self.__tcp_client.read_input_registers( 72, [ModbusDataType.UINT_32] * 2, wordorder=Endian.Little, unit=self.__modbus_id From 34d86dbc7830a26644390e7f08e45b40cbf86be9 Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Fri, 1 Nov 2024 06:33:30 +0100 Subject: [PATCH 5/7] Update device.py Error: packages/modules/devices/solax/solax_gen5/device.py:10:121: E501 line too long (127 > 120 characters) --- packages/modules/devices/solax/solax_gen5/device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/modules/devices/solax/solax_gen5/device.py b/packages/modules/devices/solax/solax_gen5/device.py index cb8db1c355..5937be40d7 100644 --- a/packages/modules/devices/solax/solax_gen5/device.py +++ b/packages/modules/devices/solax/solax_gen5/device.py @@ -7,7 +7,8 @@ from modules.common.configurable_device import ComponentFactoryByType, ConfigurableDevice, MultiComponentUpdater from modules.common.modbus import ModbusTcpClient_ from modules.devices.solax.solax_gen5.bat import SolaxGen5Bat -from modules.devices.solax.solax_gen5.config import SolaxGen5, SolaxGen5BatSetup, SolaxGen5CounterSetup, SolaxGen5InverterSetup +from modules.devices.solax.solax_gen5.config import SolaxGen5, SolaxGen5BatSetup, SolaxGen5CounterSetup +from modules.devices.solax.solax_gen5.config import SolaxGen5InverterSetup from modules.devices.solax.solax_gen5.counter import SolaxGen5Counter from modules.devices.solax.solax_gen5.inverter import SolaxGen5Inverter From caa28ea5980d1c9d8f88d251dcb6b5da1ae2ccc4 Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Wed, 13 Nov 2024 06:21:23 +0100 Subject: [PATCH 6/7] Update inverter.py Changed exported from daily register to total register --- packages/modules/devices/solax/solax_gen5/inverter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/modules/devices/solax/solax_gen5/inverter.py b/packages/modules/devices/solax/solax_gen5/inverter.py index b48651a59d..e4157d947e 100644 --- a/packages/modules/devices/solax/solax_gen5/inverter.py +++ b/packages/modules/devices/solax/solax_gen5/inverter.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 from typing import Dict, Union +from pymodbus.constants import Endian from dataclass_utils import dataclass_from_dict from modules.common import modbus @@ -31,7 +32,8 @@ def update(self) -> None: power_pv3 = self.__tcp_client.read_input_registers(292, ModbusDataType.UINT_16, unit=self.__modbus_id) * -1 power_temp = (power_pv1, power_pv2, power_pv3) power = sum(power_temp) - exported = self.__tcp_client.read_input_registers(80, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + exported = self.__tcp_client.read_input_registers(82, ModbusDataType.UINT_32, wordorder=Endian.Little, + unit=self.__modbus_id) * 100 inverter_state = InverterState( power=power, From 57111dd9b4a8c04cb7b319cf69e5fc591492e68e Mon Sep 17 00:00:00 2001 From: rgrae81 <36889990+rgrae81@users.noreply.github.com> Date: Tue, 19 Nov 2024 06:49:41 +0100 Subject: [PATCH 7/7] Update bat.py Error: packages/modules/devices/solax/solax_gen5/bat.py:41:121: E501 line too long (122 > 120 characters) Error: packages/modules/devices/solax/solax_gen5/bat.py:42:121: E501 line too long (122 > 120 characters) Error: packages/modules/devices/solax/solax_gen5/bat.py:54:1: E305 expected 2 blank lines after class or function definition, found 1 Warning: packages/modules/devices/solax/solax_gen5/bat.py:55:1: W391 blank line at end of file --- packages/modules/devices/solax/solax_gen5/bat.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/modules/devices/solax/solax_gen5/bat.py b/packages/modules/devices/solax/solax_gen5/bat.py index 1ce4d5734b..209c499c69 100644 --- a/packages/modules/devices/solax/solax_gen5/bat.py +++ b/packages/modules/devices/solax/solax_gen5/bat.py @@ -38,8 +38,10 @@ def update(self) -> None: soc = self.__tcp_client.read_input_registers(28, ModbusDataType.UINT_16, unit=self.__modbus_id) try: - imported = self.__tcp_client.read_input_registers(35, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 - exported = self.__tcp_client.read_input_registers(32, ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + imported = self.__tcp_client.read_input_registers(35, + ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 + exported = self.__tcp_client.read_input_registers(32, + ModbusDataType.UINT_16, unit=self.__modbus_id) * 100 except Exception: imported, exported = self.sim_counter.sim_count(power) @@ -51,5 +53,5 @@ def update(self) -> None: ) self.store.set(bat_state) -component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5BatSetup) +component_descriptor = ComponentDescriptor(configuration_factory=SolaxGen5BatSetup)