tesla-fleet-api 0.9.8__py3-none-any.whl → 0.9.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tesla_fleet_api/const.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from enum import Enum
4
4
  import logging
5
5
 
6
- VERSION = "0.9.8"
6
+ VERSION = "0.9.10"
7
7
  LOGGER = logging.getLogger(__package__)
8
8
  SERVERS = {
9
9
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
@@ -791,3 +791,90 @@ class Vehicle:
791
791
  return await self._request(
792
792
  Method.DELETE, f"api/1/vehicles/{vehicle_tag}/fleet_telemetry_config"
793
793
  )
794
+
795
+ async def add_charge_schedule(
796
+ self,
797
+ vehicle_tag: str | int,
798
+ days_of_week: str | int,
799
+ enabled: bool,
800
+ lat: float,
801
+ lon: float,
802
+ start_time: int | None = None,
803
+ end_time: int | None = None,
804
+ one_time: bool | None = None,
805
+ id: int | None = None,
806
+ name: str | None = None,
807
+
808
+ ) -> dict[str, Any]:
809
+ """Add a schedule for vehicle charging."""
810
+ if not start_time and not end_time:
811
+ raise ValueError("Either start_time or end_time or both must be provided")
812
+ json_payload = {
813
+ "days_of_week": days_of_week,
814
+ "enabled": enabled,
815
+ "end_enabled": end_time is not None,
816
+ "lat": lat,
817
+ "lon": lon,
818
+ "start_enabled": start_time is not None,
819
+ }
820
+ if start_time is not None:
821
+ json_payload["start_time"] = start_time
822
+ if end_time is not None:
823
+ json_payload["end_time"] = end_time
824
+ if id is not None:
825
+ json_payload["id"] = id
826
+ if one_time is not None:
827
+ json_payload["one_time"] = one_time
828
+
829
+ return await self._request(
830
+ Method.POST,
831
+ f"api/1/vehicles/{vehicle_tag}/command/add_charge_schedule",
832
+ json=json_payload,
833
+ )
834
+
835
+ async def add_precondition_schedule(
836
+ self,
837
+ vehicle_tag: str | int,
838
+ days_of_week: str | int,
839
+ enabled: bool,
840
+ lat: float,
841
+ lon: float,
842
+ precondition_time: int,
843
+ id: int | None = None,
844
+ one_time: bool | None = None,
845
+ name: str | None = None,
846
+ ) -> dict[str, Any]:
847
+ """Add or modify a preconditioning schedule."""
848
+ json_payload = {
849
+ "days_of_week": days_of_week,
850
+ "enabled": enabled,
851
+ "lat": lat,
852
+ "lon": lon,
853
+ "precondition_time": precondition_time,
854
+ }
855
+ if id is not None:
856
+ json_payload["id"] = id
857
+ if one_time is not None:
858
+ json_payload["one_time"] = one_time
859
+
860
+ return await self._request(
861
+ Method.POST,
862
+ f"api/1/vehicles/{vehicle_tag}/command/add_precondition_schedule",
863
+ json=json_payload,
864
+ )
865
+
866
+ async def remove_charge_schedule(
867
+ self, vehicle_tag: str | int, id: int
868
+ ) -> dict[str, Any]:
869
+ """Removes the scheduled charging settings."""
870
+ return await self._request(
871
+ Method.POST, f"api/1/vehicles/{vehicle_tag}/command/remove_charge_schedule", json={"id": id}
872
+ )
873
+
874
+ async def remove_precondition_schedule(
875
+ self, vehicle_tag: str | int, id: int
876
+ ) -> dict[str, Any]:
877
+ """Removes the scheduled precondition settings."""
878
+ return await self._request(
879
+ Method.POST, f"api/1/vehicles/{vehicle_tag}/command/remove_precondition_schedule", json={"id": id}
880
+ )
@@ -127,24 +127,26 @@ class Session:
127
127
 
128
128
  def __init__(self):
129
129
  self.lock = Lock()
130
+ self.counter = 0
130
131
 
131
132
  def update(self, sessionInfo: SessionInfo, privateKey: ec.EllipticCurvePrivateKey):
132
133
  """Update the session with new information"""
133
134
  self.counter = sessionInfo.counter
134
135
  self.epoch = sessionInfo.epoch
135
136
  self.delta = int(time.time()) - sessionInfo.clock_time
136
- self.publicKey = sessionInfo.publicKey
137
- self.key = hashlib.sha1(
138
- privateKey.exchange(
139
- ec.ECDH(),
140
- ec.EllipticCurvePublicKey.from_encoded_point(
141
- ec.SECP256R1(), self.publicKey
137
+ if (self.publicKey != sessionInfo.publicKey):
138
+ self.publicKey = sessionInfo.publicKey
139
+ self.key = hashlib.sha1(
140
+ privateKey.exchange(
141
+ ec.ECDH(),
142
+ ec.EllipticCurvePublicKey.from_encoded_point(
143
+ ec.SECP256R1(), self.publicKey
144
+ ),
142
145
  ),
143
- )
144
- ).digest()[:16]
145
- self.hmac = hmac.new(
146
- self.key, "authenticated command".encode(), hashlib.sha256
147
- ).digest()
146
+ ).digest()[:16]
147
+ self.hmac = hmac.new(
148
+ self.key, "authenticated command".encode(), hashlib.sha256
149
+ ).digest()
148
150
 
149
151
  def get(self) -> HMAC_Personalized_Signature_Data:
150
152
  """Sign a command and return session metadata"""
@@ -449,3 +449,61 @@ class VehicleSpecific:
449
449
  async def fleet_telemetry_config_delete(self) -> dict[str, Any]:
450
450
  """Configures fleet telemetry."""
451
451
  return await self._parent.fleet_telemetry_config_delete(self.vin)
452
+
453
+ async def add_charge_schedule(
454
+ self,
455
+ days_of_week: str | int,
456
+ enabled: bool,
457
+ lat: float,
458
+ lon: float,
459
+ start_time: int | None = None,
460
+ end_time: int | None = None,
461
+ one_time: bool | None = None,
462
+ id: int | None = None,
463
+ name: str | None = None,
464
+ ) -> dict[str, Any]:
465
+ """Adds a scheduled charging setting."""
466
+ return await self._parent.add_charge_schedule(
467
+ self.vin,
468
+ days_of_week,
469
+ enabled,
470
+ lat,
471
+ lon,
472
+ start_time,
473
+ end_time,
474
+ one_time,
475
+ id,
476
+ name,
477
+ )
478
+
479
+ async def add_precondition_schedule(
480
+ self,
481
+ days_of_week: str | int,
482
+ enabled: bool,
483
+ lat: float,
484
+ lon: float,
485
+ precondition_time: int,
486
+ id: int | None = None,
487
+ one_time: bool | None = None,
488
+ name: str | None = None,
489
+ ) -> dict[str, Any]:
490
+ """Adds a scheduled precondition setting."""
491
+ return await self._parent.add_precondition_schedule(
492
+ self.vin,
493
+ days_of_week,
494
+ enabled,
495
+ lat,
496
+ lon,
497
+ precondition_time,
498
+ id,
499
+ one_time,
500
+ name,
501
+ )
502
+
503
+ async def remove_charge_schedule(self, id: int) -> dict[str, Any]:
504
+ """Removes the scheduled charging settings."""
505
+ return await self._parent.remove_charge_schedule(self.vin, id)
506
+
507
+ async def remove_precondition_schedule(self, id: int) -> dict[str, Any]:
508
+ """Removes the scheduled precondition settings."""
509
+ return await self._parent.remove_precondition_schedule(self.vin, id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tesla_fleet_api
3
- Version: 0.9.8
3
+ Version: 0.9.10
4
4
  Summary: Tesla Fleet API library for Python
5
5
  Home-page: https://github.com/Teslemetry/python-tesla-fleet-api
6
6
  Author: Brett Adams
@@ -1,6 +1,6 @@
1
1
  tesla_fleet_api/__init__.py,sha256=BVZUDsfaxT05tAfcMHHWiyFyXwmDOx_wP_IHZBscgho,729
2
2
  tesla_fleet_api/charging.py,sha256=N_mc8axrXj3iduqLj_jCt4Vx86tHqe3xqQT4R1R7HvU,1689
3
- tesla_fleet_api/const.py,sha256=zQXR2XN7Y66UkbYcJyhCLXfdYEma8tLKPWsk_SR-LAE,12888
3
+ tesla_fleet_api/const.py,sha256=-kIlqAmzs9ZsSl5ra47y3EcGlvCCXQtBbMjbtl7pyUo,12889
4
4
  tesla_fleet_api/energy.py,sha256=S7D75MPuMVsHgkyUcFfMqjGCLZBM5YVFlWLEHbaX-zw,5957
5
5
  tesla_fleet_api/energyspecific.py,sha256=UfeaGE59aoAa8UhpQCXUi0sOrNCA40xZlqwF73BXTVY,4254
6
6
  tesla_fleet_api/exceptions.py,sha256=qnRWqPJ_5gia4-j3o4mP5OwUuBRtC3SAbZKo-_XSRiI,29729
@@ -12,9 +12,9 @@ tesla_fleet_api/teslafleetopensource.py,sha256=TJfVPcqJlA1b3kMoGuLr-g5Gn8UDyYsTZ
12
12
  tesla_fleet_api/teslemetry.py,sha256=_n59RQvJKl82ylLe09bLY_8iyfjz_DHqCdRVsWeif4s,3308
13
13
  tesla_fleet_api/tessie.py,sha256=4dBYxe1G2v9JvJGRbb01wXrAmvWT4jOfV4f_VQE_vkE,2302
14
14
  tesla_fleet_api/user.py,sha256=TZE2oh-n5zrhKXmGRuiNL9voKVODD7rBhGE_IObYVGA,1179
15
- tesla_fleet_api/vehicle.py,sha256=mSFJG-bLBNh_iSJnruk9EZSypZUxMpKwMgKA9_8CPDc,32146
16
- tesla_fleet_api/vehiclesigned.py,sha256=uwfX3MwPAtn5Otf5jUwSGuKWDVbswd3dDnNjPoxoYrM,41863
17
- tesla_fleet_api/vehiclespecific.py,sha256=P7KI8MqUbAyM2cfDC8NqbJXzGL2ZsOIx3IBeqB8xYQY,20656
15
+ tesla_fleet_api/vehicle.py,sha256=U1FNWfVut_mqdkkKlcfUlFSiaQ_l1bDABd1NTJJd_aw,35039
16
+ tesla_fleet_api/vehiclesigned.py,sha256=SaLPHA361x0-Q7PSfGTtN_e3tCJmJpVhWUfPSovSrLY,41991
17
+ tesla_fleet_api/vehiclespecific.py,sha256=IwLoQMmWQrLJPcVBsrvCWvc6Iz4DEjhrKZxtV6QZnTk,22361
18
18
  tesla_fleet_api/pb2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  tesla_fleet_api/pb2/__init__.pyi,sha256=qFXWNIgl71wB260u-XPzaAwWAHL6krw21q-aXnBtop0,252
20
20
  tesla_fleet_api/pb2/car_server_pb2.py,sha256=v_eb4NDIkx_ZYPYW29_EFRky5vQ4b2q14gwuQSbouYw,29202
@@ -35,8 +35,8 @@ tesla_fleet_api/pb2/vcsec_pb2.py,sha256=PDv9TfiXnNs6sQ0D5vBrsSSPinSqu3eBUwvTcG8x
35
35
  tesla_fleet_api/pb2/vcsec_pb2.pyi,sha256=cyK1uyRtDjRVqVlyl5uRQYY1RhFlWSJheLg3PGfs-_s,28524
36
36
  tesla_fleet_api/pb2/vehicle_pb2.py,sha256=bqyFJM-1qZ7W9XKREINhYZx8yXAudmq6W8_Pdfkhbkk,44711
37
37
  tesla_fleet_api/pb2/vehicle_pb2.pyi,sha256=sAUW_9aVB8NqJCnhZjXMLfqfePLVZv_7PfSKZKEBaQA,74251
38
- tesla_fleet_api-0.9.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
39
- tesla_fleet_api-0.9.8.dist-info/METADATA,sha256=Y7yIGeP9Pb5EidzrtwxIfdxQXFe_5YMyR0zxRkQ_DcQ,4022
40
- tesla_fleet_api-0.9.8.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
41
- tesla_fleet_api-0.9.8.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
42
- tesla_fleet_api-0.9.8.dist-info/RECORD,,
38
+ tesla_fleet_api-0.9.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
39
+ tesla_fleet_api-0.9.10.dist-info/METADATA,sha256=o0-Bo8vQoI9IyhaM6M0DC2XvxHUowcsZLvFYj7jgEns,4023
40
+ tesla_fleet_api-0.9.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
41
+ tesla_fleet_api-0.9.10.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
42
+ tesla_fleet_api-0.9.10.dist-info/RECORD,,