From a10ead22c2f87a5221c4351ef944288816c3cf41 Mon Sep 17 00:00:00 2001 From: ndrsnhs Date: Wed, 22 Oct 2025 08:59:09 +0200 Subject: [PATCH 1/2] support single phase inverters --- packages/modules/devices/sma/sma_sunny_boy/inverter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/modules/devices/sma/sma_sunny_boy/inverter.py b/packages/modules/devices/sma/sma_sunny_boy/inverter.py index 5c3b206d0d..443ebc4ea5 100644 --- a/packages/modules/devices/sma/sma_sunny_boy/inverter.py +++ b/packages/modules/devices/sma/sma_sunny_boy/inverter.py @@ -57,10 +57,9 @@ def read(self) -> InverterState: # Leistung DC an Eingang 1 und 2 dc_power = (self.tcp_client.read_holding_registers(30773, ModbusDataType.INT_32, unit=unit) + self.tcp_client.read_holding_registers(30961, ModbusDataType.INT_32, unit=unit)) - current_L1 = self.tcp_client.read_holding_registers(30977, ModbusDataType.INT_32, unit=unit) * -1 - current_L2 = self.tcp_client.read_holding_registers(30979, ModbusDataType.INT_32, unit=unit) * -1 - current_L3 = self.tcp_client.read_holding_registers(30981, ModbusDataType.INT_32, unit=unit) * -1 - currents = [current_L1 / 1000, current_L2 / 1000, current_L3 / 1000] + + currents = self.tcp_client.read_holding_registers(30977, [ModbusDataType.INT_32]*3, unit=unit) + currents = [current / -1000 if current != self.SMA_INT32_NAN else 0 for current in currents] elif self.component_config.configuration.version == SmaInverterVersion.core2: # AC Wirkleistung über alle Phasen (W) [Pac] power_total = self.tcp_client.read_holding_registers(40084, ModbusDataType.INT_16, unit=unit) * 10 @@ -95,10 +94,11 @@ def read(self) -> InverterState: inverter_state = InverterState( power=power_total * -1, dc_power=dc_power * -1, - currents=currents, exported=energy, imported=imported ) + if 'currents' in locals(): + inverter_state.currents = currents log.debug("WR {}: {}".format(self.tcp_client.address, inverter_state)) return inverter_state From cd3e113ae474a610a13f9c85384f891d8f8a47a9 Mon Sep 17 00:00:00 2001 From: ndrsnhs Date: Mon, 27 Oct 2025 14:01:00 +0100 Subject: [PATCH 2/2] handle power and currents NaN values --- packages/modules/devices/sma/sma_sunny_boy/inverter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/modules/devices/sma/sma_sunny_boy/inverter.py b/packages/modules/devices/sma/sma_sunny_boy/inverter.py index 443ebc4ea5..c0160bfa07 100644 --- a/packages/modules/devices/sma/sma_sunny_boy/inverter.py +++ b/packages/modules/devices/sma/sma_sunny_boy/inverter.py @@ -59,7 +59,10 @@ def read(self) -> InverterState: self.tcp_client.read_holding_registers(30961, ModbusDataType.INT_32, unit=unit)) currents = self.tcp_client.read_holding_registers(30977, [ModbusDataType.INT_32]*3, unit=unit) - currents = [current / -1000 if current != self.SMA_INT32_NAN else 0 for current in currents] + if all(c == self.SMA_INT32_NAN for c in currents): + currents = None + else: + currents = [current / -1000 if current != self.SMA_INT32_NAN else 0 for current in currents] elif self.component_config.configuration.version == SmaInverterVersion.core2: # AC Wirkleistung über alle Phasen (W) [Pac] power_total = self.tcp_client.read_holding_registers(40084, ModbusDataType.INT_16, unit=unit) * 10 @@ -78,9 +81,7 @@ def read(self) -> InverterState: else: raise ValueError("Unbekannte Version "+str(self.component_config.configuration.version)) if power_total == self.SMA_INT32_NAN or power_total == self.SMA_NAN: - power_total = 0 - # Bei keiner AC Wirkleistung müssen auch die Ströme der Phasen 0 sein. - currents = [0, 0, 0] + raise ValueError(f'Wechselrichter lieferte nicht plausiblen Leistungswert: {power_total}.') if energy == self.SMA_UINT32_NAN: raise ValueError(