From 796d3e6f810a98372dbc0d883bee007ad1b1152a Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:45:15 +0200 Subject: [PATCH 01/16] Update main.sh --- modules/bezug_sungrow/main.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/bezug_sungrow/main.sh b/modules/bezug_sungrow/main.sh index 014157688..4a7a632bb 100755 --- a/modules/bezug_sungrow/main.sh +++ b/modules/bezug_sungrow/main.sh @@ -10,8 +10,12 @@ else MYLOGFILE="$RAMDISKDIR/evu.log" fi -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$speicher1_ip" "$sungrowspeicherport" "$sungrowspeicherid" "$sungrowsr" >>"$MYLOGFILE" 2>&1 -ret=$? +if [[ "$pvwattmodul" == "wr_sungrow" ]]; then + echo "value read at pv modul" >/dev/null +else + bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$pv1_ipa" "$pv1_ida" "$sungrowsr" "0" "0">>"$MYLOGFILE" 2>&1 + ret=$? +fi openwbDebugLog $DMOD 2 "EVU RET: $ret" From d13e3058bb268ed51b08506f106baa4bf051f70a Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:46:55 +0200 Subject: [PATCH 02/16] Update main.sh --- modules/speicher_sungrow/main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/speicher_sungrow/main.sh b/modules/speicher_sungrow/main.sh index e73f14ff3..cef18d12a 100755 --- a/modules/speicher_sungrow/main.sh +++ b/modules/speicher_sungrow/main.sh @@ -10,7 +10,7 @@ else MYLOGFILE="$RAMDISKDIR/bat.log" fi -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$speicher1_ip" "$sungrowspeicherport" "$sungrowspeicherid" >>"$MYLOGFILE" 2>&1 +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$pv1_ipa" "$pv1_ida" "0" "0">>"$MYLOGFILE" 2>&1 ret=$? openwbDebugLog $DMOD 2 "BAT RET: $ret" From 77edff503ecea04d82c91b4bd0e43b3804721e87 Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:49:23 +0200 Subject: [PATCH 03/16] Update Moduls --- modules/wr2_sungrow/main.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/wr2_sungrow/main.sh b/modules/wr2_sungrow/main.sh index 4ec64e43c..c12ad3dae 100755 --- a/modules/wr2_sungrow/main.sh +++ b/modules/wr2_sungrow/main.sh @@ -9,7 +9,8 @@ if [ ${DMOD} == "MAIN" ]; then else MYLOGFILE="$RAMDISKDIR/nurpv.log" fi + read_counter=0 -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv2ip" "$pv2port" "$pv2id" "2" >>"$MYLOGFILE" 2>&1 +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv2ip" "$pv2id" "2" "$read_counter" "$sungrow2sr">>"$MYLOGFILE" 2>&1 cat "$RAMDISKDIR/pv2watt" From 20e6fff90a816fb6f910153f44255ecd5851742d Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:50:42 +0200 Subject: [PATCH 04/16] Update Modules --- modules/wr_sungrow/main.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/wr_sungrow/main.sh b/modules/wr_sungrow/main.sh index eeb7ea2a1..ca1414be3 100755 --- a/modules/wr_sungrow/main.sh +++ b/modules/wr_sungrow/main.sh @@ -10,6 +10,11 @@ else MYLOGFILE="$RAMDISKDIR/nurpv.log" fi -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$speicher1_ip" "$sungrowspeicherport" "$sungrowspeicherid" "1" >>"$MYLOGFILE" 2>&1 +if [[ "$wattbezugmodul" == "bezug_sungrow" ]]; then + read_counter=1 +else + read_counter=0 +fi +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv1_ipa" "$pv1_ida" "1" "$read_counter" "$sungrowsr">>"$MYLOGFILE" 2>&1 cat "$RAMDISKDIR/pvwatt" From 697c49f1a256debad3870742cac3f6465f43b42f Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 19:57:33 +0200 Subject: [PATCH 05/16] Update counter.py --- packages/modules/devices/sungrow/counter.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/modules/devices/sungrow/counter.py b/packages/modules/devices/sungrow/counter.py index 01b2aae3a..e0802c43d 100644 --- a/packages/modules/devices/sungrow/counter.py +++ b/packages/modules/devices/sungrow/counter.py @@ -27,7 +27,7 @@ def __init__(self, self.store = get_counter_value_store(self.component_config.id) self.component_info = ComponentInfo.from_component_config(self.component_config) - def update(self): + def update(self, pv_power: float): unit = self.__device_modbus_id if self.component_config.configuration.version == Version.SH: power = self.__tcp_client.read_input_registers(13009, ModbusDataType.INT_32, @@ -38,10 +38,13 @@ def update(self): # powers = [power / 10 for power in powers] # log.info("power: " + str(power) + " powers?: " + str(powers)) else: - power = self.__tcp_client.read_input_registers(5082, ModbusDataType.INT_32, - wordorder=Endian.Little, unit=unit) - if self.component_config.configuration.version == Version.SG_winet_dongle: - power = power * -1 + if pv_power != 0: + power = self.__tcp_client.read_input_registers(5082, ModbusDataType.INT_32, + wordorder=Endian.Little, unit=unit) + else: + power = self.__tcp_client.read_input_registers(5090, ModbusDataType.INT_32, + wordorder=Endian.Little, unit=unit) + # no valid data for powers per phase # powers = self.__tcp_client.read_input_registers(5084, [ModbusDataType.UINT_16] * 3, # wordorder=Endian.Little, unit=unit) From 2a0f1030ce0f5c11514b25fe11565c6d3dca3c94 Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:16:11 +0200 Subject: [PATCH 06/16] Update device.py --- packages/modules/devices/sungrow/device.py | 40 ++++++++++++++-------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 40f69619b..648c28f74 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -6,7 +6,7 @@ from helpermodules.cli import run_using_positional_cli_args from modules.common import modbus from modules.common.abstract_device import AbstractDevice, DeviceDescriptor -from modules.common.component_context import SingleComponentUpdateContext +from modules.common.component_context import MultiComponentUpdateContext from modules.devices.sungrow import bat from modules.devices.sungrow import counter from modules.devices.sungrow import inverter @@ -33,7 +33,7 @@ def __init__(self, device_config: Union[Dict, Sungrow]) -> None: try: self.device_config = dataclass_from_dict(Sungrow, device_config) self.client = modbus.ModbusTcpClient_(self.device_config.configuration.ip_address, - self.device_config.configuration.port) + 502) except Exception: log.exception("Fehler im Modul "+self.device_config.name) @@ -59,10 +59,13 @@ def update(self) -> None: log.debug("Start device reading " + str(self.components)) if self.components: with self.client: - for component in self.components: - # Auch wenn bei einer Komponente ein Fehler auftritt, sollen alle anderen noch ausgelesen werden. - with SingleComponentUpdateContext(self.components[component].component_info): - self.components[component].update() + with MultiComponentUpdateContext(self.components): + for component in self.components: + if isinstance(component, inverter.SungrowInverter): + pv_power = component.update() + for component in self.components: + if isinstance(component, counter.SungrowCounter): + component.update(pv_power) else: log.warning( self.device_config.name + @@ -77,27 +80,36 @@ def update(self) -> None: } -def read_legacy(ip_address: str, port: int, modbus_id: int, component_config: dict): +def read_legacy(ip_address: str, modbus_id: int, component_config: dict): device_config = Sungrow() device_config.configuration.ip_address = ip_address - device_config.configuration.port = port + device_config.configuration.port = 502 device_config.configuration.modbus_id = modbus_id dev = Device(device_config) dev.add_component(component_config) dev.update() -def read_legacy_bat(ip_address: str, port: int, modbus_id: int, num: Optional[int] = None): - read_legacy(ip_address, port, modbus_id, bat.component_descriptor.configuration_factory(id=None)) +def read_legacy_bat(ip_address: str, modbus_id: int, num: Optional[int] = None, read_counter: Optional[int] = None, version: Optional[int] = None): + read_legacy(ip_address, modbus_id, bat.component_descriptor.configuration_factory(id=None)) -def read_legacy_counter(ip_address: str, port: int, modbus_id: int, version: int): - read_legacy(ip_address, port, modbus_id, counter.component_descriptor.configuration_factory( +def read_legacy_counter(ip_address: str, modbus_id: int, version: int, read_counter: int, unused_version: int): + read_legacy(ip_address, modbus_id, counter.component_descriptor.configuration_factory( id=None, configuration=SungrowCounterConfiguration(version=Version(version)))) -def read_legacy_inverter(ip_address: str, port: int, modbus_id: int, num: int): - read_legacy(ip_address, port, modbus_id, inverter.component_descriptor.configuration_factory(id=num)) +def read_legacy_inverter(ip_address: str, modbus_id: int, num: int, read_counter: int, version: int): + device_config = Sungrow() + device_config.configuration.ip_address = ip_address + device_config.configuration.port = 502 + device_config.configuration.modbus_id = modbus_id + dev = Device(device_config) + dev.add_component(inverter.component_descriptor.configuration_factory(id=num)) + if read_counter == 1: + dev.add_component(counter.component_descriptor.configuration_factory( + id=None, configuration=SungrowCounterConfiguration(version=Version(version)))) + dev.update() def main(argv: List[str]): From 52c49404f38a04a9974afa017539d32fe33f7778 Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:18:38 +0200 Subject: [PATCH 07/16] Update inverter.py --- packages/modules/devices/sungrow/inverter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/modules/devices/sungrow/inverter.py b/packages/modules/devices/sungrow/inverter.py index 0be1b1be1..375567a42 100644 --- a/packages/modules/devices/sungrow/inverter.py +++ b/packages/modules/devices/sungrow/inverter.py @@ -26,7 +26,7 @@ def __init__(self, self.store = get_inverter_value_store(self.component_config.id) self.component_info = ComponentInfo.from_component_config(self.component_config) - def update(self) -> None: + def update(self) -> float: unit = self.__device_modbus_id power = self.__tcp_client.read_input_registers(5016, ModbusDataType.UINT_32, @@ -40,6 +40,7 @@ def update(self) -> None: exported=exported ) self.store.set(inverter_state) + return power component_descriptor = ComponentDescriptor(configuration_factory=SungrowInverterSetup) From dd594808c46fd269f7d34c3cce201e2c6a227a2a Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:22:32 +0200 Subject: [PATCH 08/16] Update device.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Längenanpassung --- packages/modules/devices/sungrow/device.py | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 648c28f74..451b20c15 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -10,7 +10,9 @@ from modules.devices.sungrow import bat from modules.devices.sungrow import counter from modules.devices.sungrow import inverter -from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, SungrowCounterConfiguration, SungrowCounterSetup, +from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, + SungrowCounterConfiguration, + SungrowCounterSetup, SungrowInverterSetup) from modules.devices.sungrow.version import Version @@ -18,7 +20,9 @@ log = logging.getLogger(__name__) -sungrow_component_classes = Union[bat.SungrowBat, counter.SungrowCounter, inverter.SungrowInverter] +sungrow_component_classes = Union[bat.SungrowBat, + counter.SungrowCounter, + inverter.SungrowInverter] class Device(AbstractDevice): @@ -39,7 +43,9 @@ def __init__(self, device_config: Union[Dict, Sungrow]) -> None: def add_component(self, component_config: Union[Dict, - SungrowBatSetup, SungrowCounterSetup, SungrowInverterSetup]) -> None: + SungrowBatSetup, + SungrowCounterSetup, + SungrowInverterSetup]) -> None: if isinstance(component_config, Dict): component_type = component_config["type"] else: @@ -90,16 +96,26 @@ def read_legacy(ip_address: str, modbus_id: int, component_config: dict): dev.update() -def read_legacy_bat(ip_address: str, modbus_id: int, num: Optional[int] = None, read_counter: Optional[int] = None, version: Optional[int] = None): +def read_legacy_bat(ip_address: str, modbus_id: int, + num: Optional[int] = None, + read_counter: Optional[int] = None, + version: Optional[int] = None): read_legacy(ip_address, modbus_id, bat.component_descriptor.configuration_factory(id=None)) -def read_legacy_counter(ip_address: str, modbus_id: int, version: int, read_counter: int, unused_version: int): +def read_legacy_counter(ip_address: str, modbus_id: int, + version: int, + read_counter: int, + unused_version: int): read_legacy(ip_address, modbus_id, counter.component_descriptor.configuration_factory( id=None, configuration=SungrowCounterConfiguration(version=Version(version)))) -def read_legacy_inverter(ip_address: str, modbus_id: int, num: int, read_counter: int, version: int): +def read_legacy_inverter(ip_address: str, + modbus_id: int, + num: int, + read_counter: int, + version: int): device_config = Sungrow() device_config.configuration.ip_address = ip_address device_config.configuration.port = 502 From 3b504143091016d0f79a8face0056f6b5052f1ee Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:23:42 +0200 Subject: [PATCH 09/16] Update device.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verbesserung Länge zeilen --- packages/modules/devices/sungrow/device.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 451b20c15..805e023ce 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -86,7 +86,9 @@ def update(self) -> None: } -def read_legacy(ip_address: str, modbus_id: int, component_config: dict): +def read_legacy(ip_address: str, + modbus_id: int, + component_config: dict): device_config = Sungrow() device_config.configuration.ip_address = ip_address device_config.configuration.port = 502 From 9460d2ffc622993c1f90b0522b0a91407c97567f Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:31:00 +0200 Subject: [PATCH 10/16] Update modulconfigbat.php --- web/settings/modulconfigbat.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/web/settings/modulconfigbat.php b/web/settings/modulconfigbat.php index 117b0ac93..724568b7e 100644 --- a/web/settings/modulconfigbat.php +++ b/web/settings/modulconfigbat.php @@ -90,7 +90,7 @@ - + @@ -261,22 +261,11 @@ function visibility_solarwatt_ip2() {
-
- -
- - Hier kann ein abweichender Netzwerk-Port angegeben werden, auf dem die Modbus/TCP Verbindung aufgebaut wird.Standard ist 502. -
-
-
- -
- - Gültige Werte 1-254. Standard ist 1. -
+
+ Bitte halten Sie zur Fehlervermeidung die Firmware des Sungrow Wechselrichters und Wii Net Dongels aktuell.
- Es muss Sungrow als PV und EVU Modul gewählt werden. + Es muss Sungrow Variante SH im Modul PV1 und gegebenenfalls Sungrow als EVU Modul gewählt werden.
@@ -801,7 +790,6 @@ function display_speichermodul() { } if($('#speichermodul').val() == 'speicher_sungrow') { - showSection('#divspeicherip'); showSection('#divspeichersungrow'); } if($('#speichermodul').val() == 'speicher_good_we') { From e023d2cb78d76637b01edfe92c3b495ae8baa1dd Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:32:21 +0200 Subject: [PATCH 11/16] Update modulconfigevu.php --- web/settings/modulconfigevu.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/web/settings/modulconfigevu.php b/web/settings/modulconfigevu.php index 2a60aed7d..caba28113 100644 --- a/web/settings/modulconfigevu.php +++ b/web/settings/modulconfigevu.php @@ -101,7 +101,7 @@ - + @@ -141,17 +141,7 @@
- Konfiguration im zugehörigen Speichermodul des Sungrow erforderlich! -
-
- -
- -
+ Konfiguration im zugehörigen PV-Modul 1 mit Auswahl Sungrow erforderlich!
From 8cceac64bc2233b0478eebc65e3ba45e8f7bf34d Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:33:57 +0200 Subject: [PATCH 12/16] Update modulconfigpv.php --- web/settings/modulconfigpv.php | 35 +++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/web/settings/modulconfigpv.php b/web/settings/modulconfigpv.php index ee11376e2..64332849b 100644 --- a/web/settings/modulconfigpv.php +++ b/web/settings/modulconfigpv.php @@ -162,6 +162,20 @@
+
+ +
+ +
+
+ 1) Die Variante SH mit Batterie nur über die LAN IP mit OPenWB nutzbar (Hierzu hinter dem WiNet den Lan Anschluss nutzen). WiNet zusätzlich ins Heimnetz (per Lan oder Wlan) einbinden um ISolarCloud nutzen zu können. + 2) Bitte halten Sie zur Fehlervermeidung die Firmware des Sungrow Wechselrichters und WiNet-Dongls aktuell. +
+
Konfiguration im zugehörigen Speichermodul des Sungrow erforderlich!
@@ -1118,6 +1132,8 @@ function display_pvwattmodul() { showSection('#pvbatterx'); } if($('#pvwattmodul').val() == 'wr_sungrow') { + showSection('#pvip'); + showSection('#pvid'); showSection('#pvsungrow'); } if($('#pvwattmodul').val() == 'wr_sonneneco') { @@ -1357,6 +1373,22 @@ function display_pvwattmodul() {
+
+
+ +
+ +
+
+ 1) Die Variante SH kann bei PV2 nur ohne Batterie berücksichtigt werden. Mit angeschlossener Batterie und Sungrow EVU nur an PV1 nutzbar. + 2) Bitte halten Sie zur Fehlervermeidung die Firmware des Sungrow Wechselrichters und WiNet-Dongls aktuell. +
+
+
@@ -1439,8 +1471,9 @@ function display_pv2wattmodul() { } if($('#pv2wattmodul').val() == 'wr2_sungrow') { showSection('#pv2ipdiv'); - showSection('#pv2portdiv'); showSection('#pv2iddiv'); + showSection('#pv2sungrow'); + } if($('#pv2wattmodul').val() == 'wr2_kostalpiko') { From 915acb46507a9c2787a1edd230060468c912cc3f Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Thu, 1 Jun 2023 20:44:15 +0200 Subject: [PATCH 13/16] Update modulconfigpv.php --- web/settings/modulconfigpv.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/settings/modulconfigpv.php b/web/settings/modulconfigpv.php index 64332849b..3bf71ce4f 100644 --- a/web/settings/modulconfigpv.php +++ b/web/settings/modulconfigpv.php @@ -172,7 +172,7 @@
- 1) Die Variante SH mit Batterie nur über die LAN IP mit OPenWB nutzbar (Hierzu hinter dem WiNet den Lan Anschluss nutzen). WiNet zusätzlich ins Heimnetz (per Lan oder Wlan) einbinden um ISolarCloud nutzen zu können. + 1) Die Variante SH mit Batterie nur über die LAN IP mit OpenWB nutzbar (Hierzu hinter dem WiNet den Lan Anschluss nutzen). WiNet zusätzlich ins Heimnetz (per Lan oder Wlan) einbinden um ISolarCloud nutzen zu können. 2) Bitte halten Sie zur Fehlervermeidung die Firmware des Sungrow Wechselrichters und WiNet-Dongls aktuell.
From c885c7ebc570d437ce9da31847e19b47716c2f74 Mon Sep 17 00:00:00 2001 From: Maxify23 <95931708+Maxify23@users.noreply.github.com> Date: Fri, 2 Jun 2023 10:40:58 +0200 Subject: [PATCH 14/16] Update device.py remove trailing whitespace --- packages/modules/devices/sungrow/device.py | 34 +++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 805e023ce..82040d915 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -10,8 +10,8 @@ from modules.devices.sungrow import bat from modules.devices.sungrow import counter from modules.devices.sungrow import inverter -from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, - SungrowCounterConfiguration, +from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, + SungrowCounterConfiguration, SungrowCounterSetup, SungrowInverterSetup) from modules.devices.sungrow.version import Version @@ -20,8 +20,8 @@ log = logging.getLogger(__name__) -sungrow_component_classes = Union[bat.SungrowBat, - counter.SungrowCounter, +sungrow_component_classes = Union[bat.SungrowBat, + counter.SungrowCounter, inverter.SungrowInverter] @@ -43,8 +43,8 @@ def __init__(self, device_config: Union[Dict, Sungrow]) -> None: def add_component(self, component_config: Union[Dict, - SungrowBatSetup, - SungrowCounterSetup, + SungrowBatSetup, + SungrowCounterSetup, SungrowInverterSetup]) -> None: if isinstance(component_config, Dict): component_type = component_config["type"] @@ -86,8 +86,8 @@ def update(self) -> None: } -def read_legacy(ip_address: str, - modbus_id: int, +def read_legacy(ip_address: str, + modbus_id: int, component_config: dict): device_config = Sungrow() device_config.configuration.ip_address = ip_address @@ -98,25 +98,25 @@ def read_legacy(ip_address: str, dev.update() -def read_legacy_bat(ip_address: str, modbus_id: int, - num: Optional[int] = None, +def read_legacy_bat(ip_address: str, modbus_id: int, + num: Optional[int] = None, read_counter: Optional[int] = None, version: Optional[int] = None): read_legacy(ip_address, modbus_id, bat.component_descriptor.configuration_factory(id=None)) -def read_legacy_counter(ip_address: str, modbus_id: int, - version: int, - read_counter: int, +def read_legacy_counter(ip_address: str, modbus_id: int, + version: int, + read_counter: int, unused_version: int): read_legacy(ip_address, modbus_id, counter.component_descriptor.configuration_factory( id=None, configuration=SungrowCounterConfiguration(version=Version(version)))) -def read_legacy_inverter(ip_address: str, - modbus_id: int, - num: int, - read_counter: int, +def read_legacy_inverter(ip_address: str, + modbus_id: int, + num: int, + read_counter: int, version: int): device_config = Sungrow() device_config.configuration.ip_address = ip_address From 3733050c6cbfdabaa78c25d9889eecd78529efcf Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 2 Jun 2023 11:30:11 +0200 Subject: [PATCH 15/16] test --- packages/modules/devices/sungrow/device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 82040d915..4b4c7826e 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -10,7 +10,7 @@ from modules.devices.sungrow import bat from modules.devices.sungrow import counter from modules.devices.sungrow import inverter -from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, +from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, SungrowCounterConfiguration, SungrowCounterSetup, SungrowInverterSetup) @@ -114,6 +114,7 @@ def read_legacy_counter(ip_address: str, modbus_id: int, def read_legacy_inverter(ip_address: str, + modbus_id: int, num: int, read_counter: int, From 05392eb10d6e4e0fa1f239679a4aa19111763b2d Mon Sep 17 00:00:00 2001 From: Maxim Date: Fri, 2 Jun 2023 13:03:35 +0200 Subject: [PATCH 16/16] Reformat code to avoid Error: Wrong indentation type(spaces instead of tabs) --- modules/bezug_sungrow/main.sh | 2 +- modules/speicher_sungrow/main.sh | 2 +- modules/wr2_sungrow/main.sh | 4 ++-- modules/wr_sungrow/main.sh | 2 +- packages/modules/devices/sungrow/device.py | 24 ++++++++-------------- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/modules/bezug_sungrow/main.sh b/modules/bezug_sungrow/main.sh index 4a7a632bb..bd14d8cd2 100755 --- a/modules/bezug_sungrow/main.sh +++ b/modules/bezug_sungrow/main.sh @@ -13,7 +13,7 @@ fi if [[ "$pvwattmodul" == "wr_sungrow" ]]; then echo "value read at pv modul" >/dev/null else - bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$pv1_ipa" "$pv1_ida" "$sungrowsr" "0" "0">>"$MYLOGFILE" 2>&1 + bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "counter" "$pv1_ipa" "$pv1_ida" "$sungrowsr" "0" "0" >>"$MYLOGFILE" 2>&1 ret=$? fi diff --git a/modules/speicher_sungrow/main.sh b/modules/speicher_sungrow/main.sh index cef18d12a..e79b20a34 100755 --- a/modules/speicher_sungrow/main.sh +++ b/modules/speicher_sungrow/main.sh @@ -10,7 +10,7 @@ else MYLOGFILE="$RAMDISKDIR/bat.log" fi -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$pv1_ipa" "$pv1_ida" "0" "0">>"$MYLOGFILE" 2>&1 +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "bat" "$pv1_ipa" "$pv1_ida" "0" "0" >>"$MYLOGFILE" 2>&1 ret=$? openwbDebugLog $DMOD 2 "BAT RET: $ret" diff --git a/modules/wr2_sungrow/main.sh b/modules/wr2_sungrow/main.sh index c12ad3dae..4dffde2a6 100755 --- a/modules/wr2_sungrow/main.sh +++ b/modules/wr2_sungrow/main.sh @@ -9,8 +9,8 @@ if [ ${DMOD} == "MAIN" ]; then else MYLOGFILE="$RAMDISKDIR/nurpv.log" fi - read_counter=0 +read_counter=0 -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv2ip" "$pv2id" "2" "$read_counter" "$sungrow2sr">>"$MYLOGFILE" 2>&1 +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv2ip" "$pv2id" "2" "$read_counter" "$sungrow2sr" >>"$MYLOGFILE" 2>&1 cat "$RAMDISKDIR/pv2watt" diff --git a/modules/wr_sungrow/main.sh b/modules/wr_sungrow/main.sh index ca1414be3..1b8d6941a 100755 --- a/modules/wr_sungrow/main.sh +++ b/modules/wr_sungrow/main.sh @@ -15,6 +15,6 @@ if [[ "$wattbezugmodul" == "bezug_sungrow" ]]; then else read_counter=0 fi -bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv1_ipa" "$pv1_ida" "1" "$read_counter" "$sungrowsr">>"$MYLOGFILE" 2>&1 +bash "$OPENWBBASEDIR/packages/legacy_run.sh" "modules.devices.sungrow.device" "inverter" "$pv1_ipa" "$pv1_ida" "1" "$read_counter" "$sungrowsr" >>"$MYLOGFILE" 2>&1 cat "$RAMDISKDIR/pvwatt" diff --git a/packages/modules/devices/sungrow/device.py b/packages/modules/devices/sungrow/device.py index 4b4c7826e..147f65326 100644 --- a/packages/modules/devices/sungrow/device.py +++ b/packages/modules/devices/sungrow/device.py @@ -10,19 +10,13 @@ from modules.devices.sungrow import bat from modules.devices.sungrow import counter from modules.devices.sungrow import inverter -from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, - SungrowCounterConfiguration, - SungrowCounterSetup, +from modules.devices.sungrow.config import (Sungrow, SungrowBatSetup, SungrowCounterConfiguration, SungrowCounterSetup, SungrowInverterSetup) from modules.devices.sungrow.version import Version - log = logging.getLogger(__name__) - -sungrow_component_classes = Union[bat.SungrowBat, - counter.SungrowCounter, - inverter.SungrowInverter] +sungrow_component_classes = Union[bat.SungrowBat, counter.SungrowCounter, inverter.SungrowInverter] class Device(AbstractDevice): @@ -39,21 +33,19 @@ def __init__(self, device_config: Union[Dict, Sungrow]) -> None: self.client = modbus.ModbusTcpClient_(self.device_config.configuration.ip_address, 502) except Exception: - log.exception("Fehler im Modul "+self.device_config.name) + log.exception("Fehler im Modul " + self.device_config.name) def add_component(self, - component_config: Union[Dict, - SungrowBatSetup, - SungrowCounterSetup, - SungrowInverterSetup]) -> None: + component_config: Union[ + Dict, SungrowBatSetup, SungrowCounterSetup, SungrowInverterSetup]) -> None: if isinstance(component_config, Dict): component_type = component_config["type"] else: component_type = component_config.type - component_config = dataclass_from_dict(COMPONENT_TYPE_TO_MODULE[ - component_type].component_descriptor.configuration_factory, component_config) + component_config = dataclass_from_dict( + COMPONENT_TYPE_TO_MODULE[component_type].component_descriptor.configuration_factory, component_config) if component_type in self.COMPONENT_TYPE_TO_CLASS: - self.components["component"+str(component_config.id)] = (self.COMPONENT_TYPE_TO_CLASS[component_type]( + self.components["component" + str(component_config.id)] = (self.COMPONENT_TYPE_TO_CLASS[component_type]( self.device_config.id, self.device_config.configuration.modbus_id, component_config, self.client)) else: raise Exception(