3636 Response ,
3737 Action ,
3838 MediaPlayAction ,
39- ResultReason ,
4039 VehicleAction ,
4140 VehicleControlFlashLightsAction ,
4241 ChargingStartStopAction ,
9594 SIGNATURE_TYPE_HMAC_PERSONALIZED ,
9695 TAG_DOMAIN ,
9796 TAG_SIGNATURE_TYPE ,
98- KeyIdentity ,
99- SignatureData ,
10097 SessionInfo ,
10198 HMAC_Personalized_Signature_Data ,
10299 TAG_PERSONALIZATION ,
107104)
108105from .pb2 .common_pb2 import (
109106 Void ,
110- LatLong ,
111107 PreconditioningTimes ,
112108 OffPeakChargingTimes ,
113109 # ChargeSchedule,
@@ -152,7 +148,7 @@ def update(self, sessionInfo: SessionInfo, privateKey: ec.EllipticCurvePrivateKe
152148
153149 def get (self ) -> HMAC_Personalized_Signature_Data :
154150 """Sign a command and return session metadata"""
155- self .counter += 1
151+ self .counter = self . counter + 1
156152 return HMAC_Personalized_Signature_Data (
157153 epoch = self .epoch ,
158154 counter = self .counter ,
@@ -300,18 +296,18 @@ async def _sign(
300296 await sleep (2 )
301297 return await self ._sign (domain , command , attempt )
302298
303- if resp .HasField ("signedMessageStatus " ):
299+ if resp .HasField ("protobuf_message_as_bytes " ):
304300 if (resp .from_destination .domain == DOMAIN_VEHICLE_SECURITY ):
305301 vcsec = FromVCSECMessage .FromString (resp .protobuf_message_as_bytes )
306302 LOGGER .debug ("VCSEC Response: %s" , vcsec )
307303 if vcsec .HasField ("nominalError" ):
308304 LOGGER .error ("Command failed with reason: %s" , vcsec .nominalError .genericError )
309305 return {
310306 "response" : {
311- "result" : False ,
312- "reason" : GenericError_E .Name (vcsec .nominalError .genericError )
307+ "result" : False ,
308+ "reason" : GenericError_E .Name (vcsec .nominalError .genericError )
309+ }
313310 }
314- }
315311 elif vcsec .commandStatus .operationStatus == OPERATIONSTATUS_OK :
316312 return {"response" : {"result" : True , "reason" : "" }}
317313 elif vcsec .commandStatus .operationStatus == OPERATIONSTATUS_WAIT :
@@ -323,7 +319,7 @@ async def _sign(
323319 await sleep (2 )
324320 return await self ._sign (domain , command , attempt )
325321 elif vcsec .commandStatus .operationStatus == OPERATIONSTATUS_ERROR :
326- if (vcsec . commandStatus . signedMessageStatus ):
322+ if (resp . HasField ( " signedMessageStatus" ) ):
327323 raise SIGNED_MESSAGE_INFORMATION_FAULTS [vcsec .commandStatus .signedMessageStatus .signedMessageInformation ]
328324
329325 elif (resp .from_destination .domain == DOMAIN_INFOTAINMENT ):
@@ -345,7 +341,7 @@ async def _sign(
345341 }
346342 }
347343
348- return {"response" : {"result" : None , "reason" : "No Response " }}
344+ return {"response" : {"result" : True , "reason" : "" }}
349345
350346 async def actuate_trunk (self , which_trunk : Trunk | str ) -> dict [str , Any ]:
351347 """Controls the front or rear trunk."""
@@ -1023,6 +1019,7 @@ async def sun_roof_control(self, state: str | SunRoofCommand) -> dict[str, Any]:
10231019 """Controls the panoramic sunroof on the Model S."""
10241020 if isinstance (state , SunRoofCommand ):
10251021 state = state .value
1022+ action = VehicleControlSunroofOpenCloseAction ()
10261023 match state :
10271024 case "vent" :
10281025 action = VehicleControlSunroofOpenCloseAction (vent = Void ())
@@ -1034,9 +1031,7 @@ async def sun_roof_control(self, state: str | SunRoofCommand) -> dict[str, Any]:
10341031 return await self ._sendInfotainment (
10351032 Action (
10361033 vehicleAction = VehicleAction (
1037- vehicleControlSunroofOpenCloseAction = VehicleControlSunroofOpenCloseAction (
1038- state = state
1039- )
1034+ vehicleControlSunroofOpenCloseAction = action
10401035 )
10411036 )
10421037 )
@@ -1052,10 +1047,8 @@ async def trigger_homelink(
10521047 """Turns on HomeLink (used to open and close garage doors)."""
10531048 action = VehicleControlTriggerHomelinkAction ()
10541049 if lat is not None and lon is not None :
1055- location = LatLong ()
1056- location .latitude = lat
1057- location .longitude = lon
1058- action .location = location
1050+ action .location .latitude = lat
1051+ action .location .longitude = lon
10591052 if token is not None :
10601053 action .token = token
10611054
0 commit comments