Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions packages/modules/devices/sma/sma_sunny_boy/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ 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)
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
Expand All @@ -79,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(
Expand All @@ -95,10 +95,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

Expand Down