88
99import requests as requests
1010
11- from saic_ismart_client .common_model import AbstractMessage , AbstractMessageBody , Header , MessageBodyV2 , MessageV2
11+ from saic_ismart_client .common_model import AbstractMessage , AbstractMessageBody , Header , MessageBodyV2 , MessageV2 , \
12+ TargetBatteryCode
1213from saic_ismart_client .ota_v1_1 .Message import MessageCoderV11
1314from saic_ismart_client .ota_v1_1 .data_model import AbortSendMessageReq , AlarmSwitch , AlarmSwitchReq , Message , \
1415 MessageBodyV11 , MessageListReq , MessageListResp , MessageV11 , MpAlarmSettingType , MpUserLoggingInReq , \
@@ -31,55 +32,6 @@ class ScheduledChargingMode(Enum):
3132 UNTIL_CONFIGURED_TIME = 1
3233
3334
34- class TargetBatteryCode (Enum ):
35- P_40 = 1
36- P_50 = 2
37- P_60 = 3
38- P_70 = 4
39- P_80 = 5
40- P_90 = 6
41- P_100 = 7
42-
43- def get_percentage (self ) -> int :
44- match self :
45- case TargetBatteryCode .P_40 :
46- return 40
47- case TargetBatteryCode .P_50 :
48- return 50
49- case TargetBatteryCode .P_60 :
50- return 60
51- case TargetBatteryCode .P_70 :
52- return 70
53- case TargetBatteryCode .P_80 :
54- return 80
55- case TargetBatteryCode .P_90 :
56- return 90
57- case TargetBatteryCode .P_100 :
58- return 100
59- case _:
60- raise ValueError (f'Unknown target battery code: { self } ' )
61-
62- @staticmethod
63- def from_percentage (percentage : int ):
64- match percentage :
65- case 40 :
66- return TargetBatteryCode .P_40
67- case 50 :
68- return TargetBatteryCode .P_50
69- case 60 :
70- return TargetBatteryCode .P_60
71- case 70 :
72- return TargetBatteryCode .P_70
73- case 80 :
74- return TargetBatteryCode .P_80
75- case 90 :
76- return TargetBatteryCode .P_90
77- case 100 :
78- return TargetBatteryCode .P_100
79- case _: # default
80- raise ValueError (f'Unknown target battery percentage: { percentage } ' )
81-
82-
8335class SaicMessage :
8436 def __init__ (self , message_id : int , message_type : str , title : str , message_time : datetime , sender : str ,
8537 content : str , read_status : int , vin : str ):
@@ -679,7 +631,7 @@ def control_charging_port_lock(self, unlock: bool, vin_info: VinInfo, event_id:
679631 self .publish_json_response (application_id , application_data_protocol_version , chrg_ctrl_rsp_msg .get_data ())
680632 return chrg_ctrl_rsp_msg
681633
682- def control_charging (self , stop_charging : bool , vin_info : VinInfo , event_id : str = None ):
634+ def control_charging (self , stop_charging : bool , vin_info : VinInfo , event_id : str = None ) -> MessageV30 :
683635 chrg_ctrl_req = OtaChrgCtrlReq ()
684636 chrg_ctrl_req .chrgCtrlReq = 2 if stop_charging else 1
685637 chrg_ctrl_req .tboxV2XReq = 0
@@ -702,6 +654,12 @@ def control_charging(self, stop_charging: bool, vin_info: VinInfo, event_id: str
702654 self .publish_json_response (application_id , application_data_protocol_version , chrg_ctrl_rsp_msg .get_data ())
703655 return chrg_ctrl_rsp_msg
704656
657+ def start_charging (self , vin_info : VinInfo , event_id : str = None ) -> MessageV30 :
658+ return self .control_charging (False , vin_info , event_id )
659+
660+ def start_charging_with_retry (self , vin_info : VinInfo ) -> MessageV30 :
661+ return self .handle_retry (self .start_charging , vin_info )
662+
705663 def set_target_battery_soc (self , target_soc : TargetBatteryCode , vin_info : VinInfo , event_id : str = None ):
706664 chrg_setng_req = OtaChrgSetngReq ()
707665 chrg_setng_req .onBdChrgTrgtSOCReq = target_soc .value
0 commit comments