From 3299be920a2a1ee29966cebafe23827690a20ffa Mon Sep 17 00:00:00 2001 From: Marco Giordani Date: Sun, 17 Dec 2023 20:50:57 +0000 Subject: [PATCH] Small changes to handle battery heating - added is_battery_heating to OtaChrgMangDataResp - set ptcHeatReq to 2 to turn off battery heating (tested on MG4 2022) --- src/saic_ismart_client/ota_v3_0/data_model.py | 3 +++ src/saic_ismart_client/saic_api.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/saic_ismart_client/ota_v3_0/data_model.py b/src/saic_ismart_client/ota_v3_0/data_model.py index 6d06227..56ad6b6 100644 --- a/src/saic_ismart_client/ota_v3_0/data_model.py +++ b/src/saic_ismart_client/ota_v3_0/data_model.py @@ -154,6 +154,9 @@ def get_current(self) -> float: def get_voltage(self) -> float: return self.bmsPackVol * 0.25 + def is_battery_heating(self) -> bool: + return self.bmsPTCHeatReqDspCmd == 1 + def get_power(self) -> float: return self.get_current() * self.get_voltage() / 1000.0 diff --git a/src/saic_ismart_client/saic_api.py b/src/saic_ismart_client/saic_api.py index 510945d..9fedee2 100644 --- a/src/saic_ismart_client/saic_api.py +++ b/src/saic_ismart_client/saic_api.py @@ -567,7 +567,7 @@ def get_charging_status_with_retry(self, vin_info: VinInfo) -> MessageV30: def control_battery_heating(self, enable: bool, vin_info: VinInfo, event_id: str = None) -> MessageV30: chrg_heat_req = OtaChrgHeatReq() - chrg_heat_req.ptcHeatReq = bool_to_int(enable) + chrg_heat_req.ptcHeatReq = 1 if enable else 2 chrg_heat_req_msg = MessageV30(MessageBodyV30(), chrg_heat_req) application_id = '516' application_data_protocol_version = 768