@@ -57,10 +57,12 @@ def read(self) -> InverterState:
5757 # Leistung DC an Eingang 1 und 2
5858 dc_power = (self .tcp_client .read_holding_registers (30773 , ModbusDataType .INT_32 , unit = unit ) +
5959 self .tcp_client .read_holding_registers (30961 , ModbusDataType .INT_32 , unit = unit ))
60- current_L1 = self .tcp_client .read_holding_registers (30977 , ModbusDataType .INT_32 , unit = unit ) * - 1
61- current_L2 = self .tcp_client .read_holding_registers (30979 , ModbusDataType .INT_32 , unit = unit ) * - 1
62- current_L3 = self .tcp_client .read_holding_registers (30981 , ModbusDataType .INT_32 , unit = unit ) * - 1
63- currents = [current_L1 / 1000 , current_L2 / 1000 , current_L3 / 1000 ]
60+
61+ currents = self .tcp_client .read_holding_registers (30977 , [ModbusDataType .INT_32 ]* 3 , unit = unit )
62+ if all (c == self .SMA_INT32_NAN for c in currents ):
63+ currents = None
64+ else :
65+ currents = [current / - 1000 if current != self .SMA_INT32_NAN else 0 for current in currents ]
6466 elif self .component_config .configuration .version == SmaInverterVersion .core2 :
6567 # AC Wirkleistung über alle Phasen (W) [Pac]
6668 power_total = self .tcp_client .read_holding_registers (40084 , ModbusDataType .INT_16 , unit = unit ) * 10
@@ -79,9 +81,7 @@ def read(self) -> InverterState:
7981 else :
8082 raise ValueError ("Unbekannte Version " + str (self .component_config .configuration .version ))
8183 if power_total == self .SMA_INT32_NAN or power_total == self .SMA_NAN :
82- power_total = 0
83- # Bei keiner AC Wirkleistung müssen auch die Ströme der Phasen 0 sein.
84- currents = [0 , 0 , 0 ]
84+ raise ValueError (f'Wechselrichter lieferte nicht plausiblen Leistungswert: { power_total } .' )
8585
8686 if energy == self .SMA_UINT32_NAN :
8787 raise ValueError (
@@ -95,10 +95,11 @@ def read(self) -> InverterState:
9595 inverter_state = InverterState (
9696 power = power_total * - 1 ,
9797 dc_power = dc_power * - 1 ,
98- currents = currents ,
9998 exported = energy ,
10099 imported = imported
101100 )
101+ if 'currents' in locals ():
102+ inverter_state .currents = currents
102103 log .debug ("WR {}: {}" .format (self .tcp_client .address , inverter_state ))
103104 return inverter_state
104105
0 commit comments