From aae5cf7626eb98122f433f15c81dbc92e82d988a Mon Sep 17 00:00:00 2001 From: Brett Date: Wed, 9 Oct 2024 20:44:15 +1000 Subject: [PATCH] Add reason --- tesla_fleet_api/vehiclesigned.py | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/tesla_fleet_api/vehiclesigned.py b/tesla_fleet_api/vehiclesigned.py index 2d32f9a..63512d2 100644 --- a/tesla_fleet_api/vehiclesigned.py +++ b/tesla_fleet_api/vehiclesigned.py @@ -279,33 +279,11 @@ async def _send(self, domain: int, command: bytes) -> dict[str, Any]: return {"response": {"result": False}} LOGGER.debug(resp) + reason = resp.protobuf_message_as_bytes[8:].decode() - if domain == DOMAIN_INFOTAINMENT: - resp_msg = Action() - resp_msg.ParseFromString(resp.protobuf_message_as_bytes) - print("INFOTAINMENT RESPONSE", resp_msg) - elif domain == DOMAIN_VEHICLE_SECURITY: - resp_msg = UnsignedMessage() - resp_msg.ParseFromString(resp.protobuf_message_as_bytes) - print("VCSEC RESPONSE", resp_msg) - - - if resp.protobuf_message_as_bytes and ( - text := resp.protobuf_message_as_bytes.decode() - ): - LOGGER.warning(text) - - # if domain == DOMAIN_INFOTAINMENT: - # resp_msg = Action() - # resp_msg.ParseFromString(resp.protobuf_message_as_bytes) - # print("INFOTAINMENT RESPONSE", resp_msg) - # #return {"response": {"result": False, "reason": resp_msg}} - # elif domain == DOMAIN_VEHICLE_SECURITY: - # resp_msg = UnsignedMessage() - # resp_msg.ParseFromString(resp.protobuf_message_as_bytes) - # print("VCSEC RESPONSE", resp_msg) - # print(resp.protobuf_message_as_bytes.encode()) - # #return {"response": {"result": False, "reason": resp_msg}} + if reason: + LOGGER.error(reason) + return {"response": {"result": False, "reason": reason}} return {"response": {"result": True, "reason": ""}}