77from modules .common .component_type import ComponentDescriptor
88from modules .common .modbus import ModbusDataType
99from modules .common .fault_state import ComponentInfo , FaultState
10+ from modules .common .simcount import SimCounter
1011from modules .common .store import get_bat_value_store
1112from modules .devices .good_we .good_we .config import GoodWeBatSetup
1213from modules .devices .good_we .good_we .version import GoodWeVersion
@@ -29,20 +30,29 @@ def initialize(self) -> None:
2930 self .version : GoodWeVersion = self .kwargs ['version' ]
3031 self .firmware : int = self .kwargs ['firmware' ]
3132 self .__tcp_client : modbus .ModbusTcpClient_ = self .kwargs ['client' ]
33+ self .sim_counter = SimCounter (self .__device_id , self .component_config .id , prefix = "speicher" )
3234 self .store = get_bat_value_store (self .component_config .id )
3335 self .fault_state = FaultState (ComponentInfo .from_component_config (self .component_config ))
3436
3537 def update (self ) -> None :
38+ battery_index = getattr (self .component_config .configuration , "battery_index" , 1 )
3639 with self .__tcp_client :
37- if self .version == GoodWeVersion .V_1_7 :
38- power = self .__tcp_client .read_holding_registers (35183 , ModbusDataType .INT_16 , unit = self .__modbus_id )* - 1
40+ if battery_index == 1 :
41+ if self .version == GoodWeVersion .V_1_7 :
42+ power = self .__tcp_client .read_holding_registers (
43+ 35183 , ModbusDataType .INT_16 , unit = self .__modbus_id )* - 1
44+ else :
45+ power = self .__tcp_client .read_holding_registers (
46+ 35182 , ModbusDataType .INT_32 , unit = self .__modbus_id )* - 1
47+ soc = self .__tcp_client .read_holding_registers (37007 , ModbusDataType .UINT_16 , unit = self .__modbus_id )
48+ imported = self .__tcp_client .read_holding_registers (
49+ 35206 , ModbusDataType .UINT_32 , unit = self .__modbus_id ) * 100
50+ exported = self .__tcp_client .read_holding_registers (
51+ 35209 , ModbusDataType .UINT_32 , unit = self .__modbus_id ) * 100
3952 else :
4053 power = self .__tcp_client .read_holding_registers (35182 , ModbusDataType .INT_32 , unit = self .__modbus_id )* - 1
41- soc = self .__tcp_client .read_holding_registers (37007 , ModbusDataType .UINT_16 , unit = self .__modbus_id )
42- imported = self .__tcp_client .read_holding_registers (
43- 35206 , ModbusDataType .UINT_32 , unit = self .__modbus_id ) * 100
44- exported = self .__tcp_client .read_holding_registers (
45- 35209 , ModbusDataType .UINT_32 , unit = self .__modbus_id ) * 100
54+ soc = self .__tcp_client .read_holding_registers (37007 , ModbusDataType .UINT_16 , unit = self .__modbus_id )
55+ imported , exported = self .sim_counter .sim_count (power )
4656
4757 bat_state = BatState (
4858 power = power ,
0 commit comments