tesla-fleet-api 0.6.0__py3-none-any.whl → 0.6.2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
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.5.16"
6
+ VERSION = "0.6.2"
7
7
  LOGGER = logging.getLogger(__package__)
8
8
  SERVERS = {
9
9
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
tesla_fleet_api/energy.py CHANGED
@@ -152,3 +152,13 @@ class Energy:
152
152
  f"api/1/energy_sites/{energy_site_id}/storm_mode",
153
153
  json={"enabled": enabled},
154
154
  )
155
+
156
+ async def time_of_use_settings(
157
+ self, energy_site_id: int, settings: dict[str, Any]
158
+ ) -> dict[str, Any]:
159
+ """Update the time of use settings for the energy site."""
160
+ return await self._request(
161
+ Method.POST,
162
+ f"api/1/energy_sites/{energy_site_id}/time_of_use_settings",
163
+ json={"tou_settings": {"tariff_content_v2": settings}},
164
+ )
@@ -117,3 +117,10 @@ class EnergySpecific:
117
117
  self.energy_site_id,
118
118
  enabled,
119
119
  )
120
+
121
+ async def time_of_use_settings(self, settings: dict[str, Any]) -> dict[str, Any]:
122
+ """Update the site's time of use settings."""
123
+ return await self._parent.time_of_use_settings(
124
+ self.energy_site_id,
125
+ settings,
126
+ )
@@ -114,6 +114,8 @@ class TeslaFleetApi:
114
114
  params=params,
115
115
  ) as resp:
116
116
  LOGGER.debug("Response Status: %s", resp.status)
117
+ if "x-txid" in resp.headers:
118
+ LOGGER.debug("Response TXID: %s", resp.headers["x-txid"])
117
119
  if not resp.ok:
118
120
  await raise_for_status(resp)
119
121
  if not resp.content_type.lower().startswith("application/json"):
@@ -2,7 +2,7 @@ import aiohttp
2
2
  from aiolimiter import AsyncLimiter
3
3
  from typing import Any
4
4
  from .teslafleetapi import TeslaFleetApi
5
- from .const import Method, LOGGER
5
+ from .const import Method, LOGGER, Scope
6
6
 
7
7
  # Rate limit should be global, even if multiple instances are created
8
8
  rate_limit = AsyncLimiter(5, 10)
@@ -39,7 +39,7 @@ class Teslemetry(TeslaFleetApi):
39
39
  )
40
40
 
41
41
  async def metadata(self, update_region=True) -> dict[str, Any]:
42
- """Test API Authentication."""
42
+ """Get user metadata including scopes."""
43
43
  resp = await self._request(
44
44
  Method.GET,
45
45
  "api/metadata",
@@ -49,6 +49,11 @@ class Teslemetry(TeslaFleetApi):
49
49
  self.server = f"https://{self.region}.teslemetry.com"
50
50
  LOGGER.debug("Using server %s", self.server)
51
51
  return resp
52
+
53
+ async def scopes(self) -> list[str]:
54
+ """Get user scopes."""
55
+ resp = await self.metadata(False)
56
+ return resp["scopes"]
52
57
 
53
58
  async def find_server(self) -> str:
54
59
  """Find the server URL for the Tesla Fleet API."""
tesla_fleet_api/tessie.py CHANGED
@@ -19,6 +19,14 @@ class Tessie(TeslaFleetApi):
19
19
  user_scope=False,
20
20
  )
21
21
 
22
+ async def scopes(self) -> list[str]:
23
+ """Get user scopes."""
24
+ resp = await self._request(
25
+ Method.GET,
26
+ "auth/tesla_scopes",
27
+ )
28
+ return resp["scopes"]
29
+
22
30
  async def find_server(self) -> str:
23
31
  """Find the server URL for the Tesla Fleet API."""
24
32
  raise NotImplementedError("Do not use this function for Tessie.")
@@ -752,7 +752,7 @@ class Vehicle:
752
752
  async def fleet_status(self, vins: List[str]) -> dict[str, Any]:
753
753
  """Checks whether vehicles can accept Tesla commands protocol for the partner's public key"""
754
754
  return await self._request(
755
- Method.GET, "api/1/vehicles/fleet_status", json={"vins": vins}
755
+ Method.POST, "api/1/vehicles/fleet_status", json={"vins": vins}
756
756
  )
757
757
 
758
758
  async def fleet_telemetry_config_create(
@@ -436,6 +436,14 @@ class VehicleSpecific:
436
436
  """Checks whether vehicles can accept Tesla commands protocol for the partner's public key"""
437
437
  return await self._parent.fleet_status([self.vin])
438
438
 
439
+ async def fleet_telemetry_config_create(
440
+ self, config: dict[str, Any]
441
+ ) -> dict[str, Any]:
442
+ """Configures fleet telemetry."""
443
+ return await self._parent.fleet_telemetry_config_create(
444
+ {"vins": [self.vin], "config": config}
445
+ )
446
+
439
447
  async def fleet_telemetry_config_get(self) -> dict[str, Any]:
440
448
  """Configures fleet telemetry."""
441
449
  return await self._parent.fleet_telemetry_config_get(self.vin)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.6.0
3
+ Version: 0.6.2
4
4
  Summary: Tesla Fleet API library for Python
5
5
  Home-page: https://github.com/Teslemetry/tesla_fleet_api
6
6
  Author: Brett Adams
@@ -0,0 +1,19 @@
1
+ tesla_fleet_api/__init__.py,sha256=0MON9vh3AShIiX16FZ6NU3yZ7kyXFh5GxA0rY8CzVRM,584
2
+ tesla_fleet_api/charging.py,sha256=N_mc8axrXj3iduqLj_jCt4Vx86tHqe3xqQT4R1R7HvU,1689
3
+ tesla_fleet_api/const.py,sha256=rlhGx203VeO4e-P1J-MQ54BUSG1CD_00Kx1ktZmioBY,9277
4
+ tesla_fleet_api/energy.py,sha256=yOKNPyXWKMT7Z9a5RqdNksHokLRo657SWjly1bP2_Qs,5827
5
+ tesla_fleet_api/energyspecific.py,sha256=zggN-q0tf6EH_57bM4EuQ-IdcemKP0o-xv__LArRNnA,4147
6
+ tesla_fleet_api/exceptions.py,sha256=BcvJyjY4qM2-Rf7ZMA94xPIN6ebKit89E7qattMmbr8,11018
7
+ tesla_fleet_api/partner.py,sha256=1vIBUaxKLIfqcC0X6VXZN0dMAzj_CLNPUMjA6QVqZ1k,1223
8
+ tesla_fleet_api/teslafleetapi.py,sha256=jv1_a_xrUUCi26nDBKkxZM57-A7E_nRuJXq-jjtoTb8,4941
9
+ tesla_fleet_api/teslafleetoauth.py,sha256=OC6djQw2ieZR_rWK5HoInLScZOu5T5aMClbg5gqbnDg,3502
10
+ tesla_fleet_api/teslemetry.py,sha256=kcZG7O9tsBt0BoUyCUSU9j9yCbN1qJDL1iUUo4DFESs,2167
11
+ tesla_fleet_api/tessie.py,sha256=4dBYxe1G2v9JvJGRbb01wXrAmvWT4jOfV4f_VQE_vkE,2302
12
+ tesla_fleet_api/user.py,sha256=TZE2oh-n5zrhKXmGRuiNL9voKVODD7rBhGE_IObYVGA,1179
13
+ tesla_fleet_api/vehicle.py,sha256=KFFotHSmzaC4MhIlU8hoG7SVvPiV3_FC__uJf8BG_G0,31412
14
+ tesla_fleet_api/vehiclespecific.py,sha256=Nr4zZzfmIuw3RFYjQEX6c_xtYZgztMsN5ohVn-YEH0I,20600
15
+ tesla_fleet_api-0.6.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
+ tesla_fleet_api-0.6.2.dist-info/METADATA,sha256=f30iqSiNHenTXhh69OQCnasTemS_p3Iht_SWay-BRiU,3821
17
+ tesla_fleet_api-0.6.2.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
18
+ tesla_fleet_api-0.6.2.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
19
+ tesla_fleet_api-0.6.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.1.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,19 +0,0 @@
1
- tesla_fleet_api/__init__.py,sha256=0MON9vh3AShIiX16FZ6NU3yZ7kyXFh5GxA0rY8CzVRM,584
2
- tesla_fleet_api/charging.py,sha256=N_mc8axrXj3iduqLj_jCt4Vx86tHqe3xqQT4R1R7HvU,1689
3
- tesla_fleet_api/const.py,sha256=-MYIW8BaV-B0w7dxx--sZyF7bZQslLsEtxZZ_vIYPy8,9278
4
- tesla_fleet_api/energy.py,sha256=lVcvrU7W2Nbd0L0j4wytzD8uV3wl0oMXN07Zp90K4t8,5426
5
- tesla_fleet_api/energyspecific.py,sha256=KWfCV609r8MvNAcg8d1PbrjVH_mrJDjzdi_WEnFiUGs,3885
6
- tesla_fleet_api/exceptions.py,sha256=BcvJyjY4qM2-Rf7ZMA94xPIN6ebKit89E7qattMmbr8,11018
7
- tesla_fleet_api/partner.py,sha256=1vIBUaxKLIfqcC0X6VXZN0dMAzj_CLNPUMjA6QVqZ1k,1223
8
- tesla_fleet_api/teslafleetapi.py,sha256=-hiZfEEdS8Sfj_yqW-woiD5XD5_Q2IcMubmkh7wdtdE,4826
9
- tesla_fleet_api/teslafleetoauth.py,sha256=OC6djQw2ieZR_rWK5HoInLScZOu5T5aMClbg5gqbnDg,3502
10
- tesla_fleet_api/teslemetry.py,sha256=07vY6y56slUXvyaQDGQSGW_VF98fQUgEh-xXrG_phw8,2000
11
- tesla_fleet_api/tessie.py,sha256=dZs85N2uVlqkjxB3ICRVnPyyJkl4tWDAb3CQqV4MqQc,2096
12
- tesla_fleet_api/user.py,sha256=TZE2oh-n5zrhKXmGRuiNL9voKVODD7rBhGE_IObYVGA,1179
13
- tesla_fleet_api/vehicle.py,sha256=EE8ZgL1QdOVfwPsShGeI9DZtsKcLKG7EcfBCnEugfH0,31411
14
- tesla_fleet_api/vehiclespecific.py,sha256=BhWaQGsNhg06gSLGqNEs2JQgolY3mNGtOWz478lofFE,20324
15
- tesla_fleet_api-0.6.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
- tesla_fleet_api-0.6.0.dist-info/METADATA,sha256=Wmjs_Fx05K2qujHe4Jx_EhS8lVXjqosES1fvsK4TxUI,3821
17
- tesla_fleet_api-0.6.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
18
- tesla_fleet_api-0.6.0.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
19
- tesla_fleet_api-0.6.0.dist-info/RECORD,,