tesla-fleet-api 0.1.0__tar.gz → 0.1.4__tar.gz

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.
Files changed (23) hide show
  1. {tesla_fleet_api-0.1.0/tesla_fleet_api.egg-info → tesla_fleet_api-0.1.4}/PKG-INFO +5 -4
  2. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/README.md +3 -2
  3. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/setup.py +2 -2
  4. tesla_fleet_api-0.1.4/tesla_fleet_api/__init__.py +9 -0
  5. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/const.py +9 -1
  6. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/energy.py +0 -7
  7. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/partner.py +1 -1
  8. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/teslafleetapi.py +8 -1
  9. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/teslemetry.py +10 -17
  10. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/vehicle.py +5 -2
  11. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4/tesla_fleet_api.egg-info}/PKG-INFO +5 -4
  12. tesla_fleet_api-0.1.0/tesla_fleet_api/__init__.py +0 -3
  13. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/LICENSE +0 -0
  14. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/setup.cfg +0 -0
  15. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/charging.py +0 -0
  16. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/exceptions.py +0 -0
  17. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/teslafleetoauth.py +0 -0
  18. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/user.py +0 -0
  19. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api/vehiclespecific.py +0 -0
  20. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api.egg-info/SOURCES.txt +0 -0
  21. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api.egg-info/dependency_links.txt +0 -0
  22. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api.egg-info/requires.txt +0 -0
  23. {tesla_fleet_api-0.1.0 → tesla_fleet_api-0.1.4}/tesla_fleet_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.1.0
3
+ Version: 0.1.4
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
@@ -9,7 +9,7 @@ Classifier: Development Status :: 3 - Alpha
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: Apache Software License
11
11
  Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.8
12
+ Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: aiohttp
@@ -95,7 +95,8 @@ This extends TeslaFleetApi to send requests through Teslemetry, which manages al
95
95
  import asyncio
96
96
  import aiohttp
97
97
 
98
- from tesla_fleet_api import Teslemetry, TeslaFleetError
98
+ from tesla_fleet_api import Teslemetry
99
+ from tesla_fleet_api.exceptions import TeslaFleetError
99
100
 
100
101
 
101
102
  async def main():
@@ -109,7 +110,7 @@ async def main():
109
110
  try:
110
111
  data = await api.vehicle.list()
111
112
  print(data)
112
- except TeslaFleetError.Base as e:
113
+ except TeslaFleetError as e:
113
114
  print(e.message, e.error)
114
115
 
115
116
  asyncio.run(main())
@@ -79,7 +79,8 @@ This extends TeslaFleetApi to send requests through Teslemetry, which manages al
79
79
  import asyncio
80
80
  import aiohttp
81
81
 
82
- from tesla_fleet_api import Teslemetry, TeslaFleetError
82
+ from tesla_fleet_api import Teslemetry
83
+ from tesla_fleet_api.exceptions import TeslaFleetError
83
84
 
84
85
 
85
86
  async def main():
@@ -93,7 +94,7 @@ async def main():
93
94
  try:
94
95
  data = await api.vehicle.list()
95
96
  print(data)
96
- except TeslaFleetError.Base as e:
97
+ except TeslaFleetError as e:
97
98
  print(e.message, e.error)
98
99
 
99
100
  asyncio.run(main())
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="tesla_fleet_api",
8
- version="0.1.0",
8
+ version="0.1.4",
9
9
  author="Brett Adams",
10
10
  author_email="hello@teslemetry.com",
11
11
  description="Tesla Fleet API library for Python",
@@ -19,6 +19,6 @@ setuptools.setup(
19
19
  "License :: OSI Approved :: Apache Software License",
20
20
  "Operating System :: OS Independent",
21
21
  ],
22
- python_requires=">=3.8",
22
+ python_requires=">=3.10",
23
23
  install_requires=["aiohttp"],
24
24
  )
@@ -0,0 +1,9 @@
1
+ from .teslafleetapi import TeslaFleetApi
2
+ from .teslafleetoauth import TeslaFleetOAuth
3
+ from .teslemetry import Teslemetry
4
+ from .charging import Charging
5
+ from .energy import Energy
6
+ from .partner import Partner
7
+ from .user import User
8
+ from .vehicle import Vehicle
9
+ from .vehiclespecific import VehicleSpecific
@@ -1,5 +1,13 @@
1
1
  """Tesla Fleet API constants."""
2
- from enum import StrEnum, IntEnum
2
+ from enum import Enum
3
+
4
+
5
+ class IntEnum(int, Enum):
6
+ pass
7
+
8
+
9
+ class StrEnum(str, Enum):
10
+ pass
3
11
 
4
12
 
5
13
  class Methods(StrEnum):
@@ -107,13 +107,6 @@ class Energy:
107
107
  data={default_real_mode: default_real_mode},
108
108
  )
109
109
 
110
- async def products(self) -> dict[str, Any]:
111
- """Returns products mapped to user."""
112
- return await self._request(
113
- Methods.GET,
114
- "api/1/products",
115
- )
116
-
117
110
  async def site_info(self, energy_site_id: int) -> dict[str, Any]:
118
111
  """Returns information about the site. Things like assets (has solar, etc), settings (backup reserve, etc), and features (storm_mode_capable, etc)."""
119
112
  return await self._request(
@@ -11,7 +11,7 @@ class Partner:
11
11
  async def public_key(self, domain: str | None = None) -> dict[str, Any]:
12
12
  """Returns the public key associated with a domain. It can be used to ensure the registration was successful."""
13
13
  return await self._request(
14
- Methods.GET, "api/1/partner_accounts/public_key", data={domain: domain}
14
+ Methods.GET, "api/1/partner_accounts/public_key", {domain: domain}
15
15
  )
16
16
 
17
17
  async def register(self, domain: str) -> dict[str, Any]:
@@ -41,7 +41,7 @@ class TeslaFleetApi:
41
41
  self.use_command_protocol = use_command_protocol
42
42
 
43
43
  if region and not server and region not in SERVERS:
44
- raise ValueError(f"Region must be one of {", ".join(SERVERS.keys())}")
44
+ raise ValueError(f"Region must be one of {', '.join(SERVERS.keys())}")
45
45
  self.server = server or SERVERS.get(region)
46
46
  self.raise_for_status = raise_for_status
47
47
 
@@ -120,3 +120,10 @@ class TeslaFleetApi:
120
120
  raise ValueError("Server was not set at init. Call find_server() first.")
121
121
  async with self.session.get(f"{self.server}/status") as resp:
122
122
  return await resp.text()
123
+
124
+ async def products(self) -> dict[str, Any]:
125
+ """Returns products mapped to user."""
126
+ return await self._request(
127
+ Methods.GET,
128
+ "api/1/products",
129
+ )
@@ -1,20 +1,8 @@
1
1
  import aiohttp
2
2
  from .teslafleetapi import TeslaFleetApi
3
- from .vehicle import Vehicle
4
- from .vehiclespecific import VehicleSpecific
5
3
  from .const import Methods
6
4
 
7
5
 
8
- class TeslemetryVehicle(Vehicle):
9
- """Tesla Fleet API Vehicle."""
10
-
11
- async def create(self, only_subscribed=True) -> [VehicleSpecific]:
12
- """Creates a class for each vehicle."""
13
- if only_subscribed:
14
- return [VehicleSpecific(self, vin) for vin in await self._parent.vehicles()]
15
- return await super().create()
16
-
17
-
18
6
  class Teslemetry(TeslaFleetApi):
19
7
  def __init__(
20
8
  self,
@@ -31,15 +19,20 @@ class Teslemetry(TeslaFleetApi):
31
19
  raise_for_status=raise_for_status,
32
20
  partner_scope=False,
33
21
  user_scope=False,
34
- vehicle_scope=False,
35
22
  )
36
- self.vehicle = TeslemetryVehicle(self)
37
23
 
38
- async def vehicles(self):
39
- """Get the subscribed vehicles."""
24
+ async def ping(self) -> bool:
25
+ """Send a ping."""
26
+ return await self._request(
27
+ Methods.GET,
28
+ "/api/ping",
29
+ )
30
+
31
+ async def test(self) -> bool:
32
+ """Test API Authentication."""
40
33
  return await self._request(
41
34
  Methods.GET,
42
- "/meta/vehicles",
35
+ "/api/test",
43
36
  )
44
37
 
45
38
  async def find_server(self):
@@ -1,4 +1,4 @@
1
- from typing import Any
1
+ from typing import Any, List
2
2
  from .const import (
3
3
  Methods,
4
4
  Trunks,
@@ -10,6 +10,7 @@ from .const import (
10
10
  DeviceTypes,
11
11
  )
12
12
  from .vehiclespecific import VehicleSpecific
13
+ from urllib.parse import quote
13
14
 
14
15
 
15
16
  class Vehicle:
@@ -787,9 +788,11 @@ class Vehicle:
787
788
  async def vehicle_data(
788
789
  self,
789
790
  vehicle_tag: str | int,
790
- endpoints: VehicleDataEndpoints | str | None = None,
791
+ endpoints: List[VehicleDataEndpoints] | List[str] | None = None,
791
792
  ) -> dict[str, Any]:
792
793
  """Makes a live call to the vehicle. This may return cached data if the vehicle is offline. For vehicles running firmware versions 2023.38+, location_data is required to fetch vehicle location. This will result in a location sharing icon to show on the vehicle UI."""
794
+ if isinstance(endpoints, list):
795
+ endpoints = quote(";".join(endpoints))
793
796
  return await self._request(
794
797
  Methods.GET,
795
798
  f"api/1/vehicles/{vehicle_tag}/vehicle_data",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.1.0
3
+ Version: 0.1.4
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
@@ -9,7 +9,7 @@ Classifier: Development Status :: 3 - Alpha
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: Apache Software License
11
11
  Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.8
12
+ Requires-Python: >=3.10
13
13
  Description-Content-Type: text/markdown
14
14
  License-File: LICENSE
15
15
  Requires-Dist: aiohttp
@@ -95,7 +95,8 @@ This extends TeslaFleetApi to send requests through Teslemetry, which manages al
95
95
  import asyncio
96
96
  import aiohttp
97
97
 
98
- from tesla_fleet_api import Teslemetry, TeslaFleetError
98
+ from tesla_fleet_api import Teslemetry
99
+ from tesla_fleet_api.exceptions import TeslaFleetError
99
100
 
100
101
 
101
102
  async def main():
@@ -109,7 +110,7 @@ async def main():
109
110
  try:
110
111
  data = await api.vehicle.list()
111
112
  print(data)
112
- except TeslaFleetError.Base as e:
113
+ except TeslaFleetError as e:
113
114
  print(e.message, e.error)
114
115
 
115
116
  asyncio.run(main())
@@ -1,3 +0,0 @@
1
- from .teslafleetapi import TeslaFleetApi
2
- from .teslafleetoauth import TeslaFleetOAuth
3
- from .teslemetry import Teslemetry
File without changes