@@ -123,16 +123,16 @@ def __init__(self, ip_address: str, port: int = 8080) -> None:
123
123
# Request 2
124
124
'read_battery_info' : bytes .fromhex ("010300100003040e" ),
125
125
# Request 3 and 10
126
- 'start_measurement ' : bytes .fromhex ("0110055000020400018100f853" ),
126
+ 'start_measure_box_1 ' : bytes .fromhex ("0110055000020400018100f853" ),
127
127
# Request 4 and 11
128
128
'read_measurement_status' : bytes .fromhex ("010305510001d517" ),
129
129
# Requests 5-8 and 12-15
130
130
'read_cell_volt_temp' : bytes .fromhex ("01030558004104e5" ),
131
131
# Request 9
132
132
'switch_pass' : bytes .fromhex ("01100100000306444542554700176f" ),
133
133
# Request 16
134
- 'switch_to_box_2 ' : bytes .fromhex ("01100550000204000281000853" ),
135
- 'switch_to_box_3 ' : bytes .fromhex ("01100550000204000381005993" ),
134
+ 'start_measure_box_2 ' : bytes .fromhex ("01100550000204000281000853" ),
135
+ 'start_measure_box_3 ' : bytes .fromhex ("01100550000204000381005993" ),
136
136
# BMU
137
137
'EVT_MSG_0_0' : bytes .fromhex ("011005a000020400008100A6D7" ),
138
138
# BMS tower 1
@@ -526,7 +526,6 @@ async def poll(self) -> None:
526
526
13 : self .state13_send_request11 ,
527
527
14 : self .state14_send_request12 ,
528
528
15 : self .state15_send_request13 ,
529
- 16 : self .state16_switch_tower ,
530
529
}
531
530
532
531
while self .my_state != 0 :
@@ -586,7 +585,12 @@ async def state4_send_request2(self) -> None:
586
585
587
586
async def state5_start_measurement (self ) -> None :
588
587
"""State 5: Start measurement and proceed with detailed queries."""
589
- await self .send_request (self .my_requests ['start_measurement' ])
588
+ if self .current_tower == 0 :
589
+ await self .send_request (self .my_requests ['start_measure_box_1' ])
590
+ elif self .current_tower == 1 :
591
+ await self .send_request (self .my_requests ['start_measure_box_2' ])
592
+ elif self .current_tower == 2 :
593
+ await self .send_request (self .my_requests ['start_measure_box_3' ])
590
594
data = await self .receive_response ()
591
595
if data and self .check_packet (data ):
592
596
# Wait time as per original code (e.g., 8 seconds)
@@ -656,9 +660,6 @@ async def state10_send_request8(self) -> None:
656
660
# Check if we have more than 128 cells
657
661
if self .hvs_num_cells > 128 :
658
662
self .my_state = 11
659
- # if x towerconfig has less than 5 modules
660
- elif self .hvs_towers - 1 > self .current_tower :
661
- self .my_state = 16 # Proceed to second tower
662
663
else :
663
664
self .my_state = 0 # Polling completed
664
665
else :
@@ -670,10 +671,12 @@ async def state10_send_request8(self) -> None:
670
671
async def state11_send_request9 (self ) -> None :
671
672
"""Handle additional cells for more than 128 cells (e.g., 5 modules)"""
672
673
# State 11: Send request 9 - Switch to second pass
673
- if self .current_tower > 1 :
674
- await self .send_request (self .my_requests ['switch_to_box_2' ])
675
- else :
676
- await self .send_request (self .my_requests ['switch_pass' ])
674
+ if self .current_tower == 0 :
675
+ await self .send_request (self .my_requests ['start_measure_box_1' ])
676
+ elif self .current_tower == 1 :
677
+ await self .send_request (self .my_requests ['start_measure_box_2' ])
678
+ elif self .current_tower == 2 :
679
+ await self .send_request (self .my_requests ['start_measure_box_3' ])
677
680
data = await self .receive_response ()
678
681
if data and self .check_packet (data ):
679
682
self .my_state = 12
@@ -724,27 +727,15 @@ async def state15_send_request13(self) -> None:
724
727
data = await self .receive_response ()
725
728
if data and self .check_packet (data ):
726
729
self .parse_packet13 (data , self .current_tower )
727
- if self .hvs_towers - 1 > self .current_tower :
728
- self .my_state = 16
730
+ if self .current_tower + 1 < self .hvs_towers :
729
731
self .current_tower += 1
732
+ self .my_state = 5
730
733
else :
731
- self .my_state = 0 # Polling completed
734
+ self .my_state = 0 # Letzter Turm erreicht
732
735
else :
733
736
_LOGGER .error ("Invalid or no data received in state 15" )
734
737
self .my_state = 0
735
738
736
- async def state16_switch_tower (self ) -> None :
737
- """Handle second tower"""
738
- await self .send_request (self .my_requests ['switch_to_box_2' ])
739
- data = await self .receive_response ()
740
- if data and self .check_packet (data ):
741
- # Wait time as per original code (e.g., 8 seconds)
742
- await asyncio .sleep (self .SLEEP_TIME )
743
- self .my_state = 4
744
- else :
745
- _LOGGER .error ("Invalid or no data received in state 16" )
746
- self .my_state = 0
747
-
748
739
def get_data (self ) -> dict :
749
740
"""Retrieve the collected data."""
750
741
return {
0 commit comments