tesla-fleet-api 1.0.9__tar.gz → 1.0.10__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 (57) hide show
  1. {tesla_fleet_api-1.0.9/tesla_fleet_api.egg-info → tesla_fleet_api-1.0.10}/PKG-INFO +1 -1
  2. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/setup.py +1 -1
  3. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/const.py +1 -1
  4. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/bluetooth.py +35 -0
  5. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/vehicle.py +2 -0
  6. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/vehicles.py +29 -1
  7. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10/tesla_fleet_api.egg-info}/PKG-INFO +1 -1
  8. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/LICENSE +0 -0
  9. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/README.md +0 -0
  10. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/pyproject.toml +0 -0
  11. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/setup.cfg +0 -0
  12. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/__init__.py +0 -0
  13. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/exceptions.py +0 -0
  14. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/ratecalculator.py +0 -0
  15. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/__init__.py +0 -0
  16. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/bluetooth.py +0 -0
  17. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/charging.py +0 -0
  18. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/energysite.py +0 -0
  19. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/fleet.py +0 -0
  20. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/oauth.py +0 -0
  21. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/partner.py +0 -0
  22. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/tesla.py +0 -0
  23. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/user.py +0 -0
  24. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/__init__.py +0 -0
  25. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/commands.py +0 -0
  26. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/fleet.py +0 -0
  27. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/__init__.py +0 -0
  28. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/__init__.pyi +0 -0
  29. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/car_server_pb2.py +0 -0
  30. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/car_server_pb2.pyi +0 -0
  31. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/common_pb2.py +0 -0
  32. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/common_pb2.pyi +0 -0
  33. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/errors_pb2.py +0 -0
  34. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/errors_pb2.pyi +0 -0
  35. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/keys_pb2.py +0 -0
  36. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/keys_pb2.pyi +0 -0
  37. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/managed_charging_pb2.py +0 -0
  38. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/managed_charging_pb2.pyi +0 -0
  39. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/signatures_pb2.py +0 -0
  40. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/signatures_pb2.pyi +0 -0
  41. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/universal_message_pb2.py +0 -0
  42. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/universal_message_pb2.pyi +0 -0
  43. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/vcsec_pb2.py +0 -0
  44. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/vcsec_pb2.pyi +0 -0
  45. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.py +0 -0
  46. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/proto/vehicle_pb2.pyi +0 -0
  47. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tesla/vehicle/signed.py +0 -0
  48. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/teslemetry/__init__.py +0 -0
  49. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/teslemetry/teslemetry.py +0 -0
  50. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/teslemetry/vehicles.py +0 -0
  51. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tessie/__init__.py +0 -0
  52. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tessie/tessie.py +0 -0
  53. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api/tessie/vehicles.py +0 -0
  54. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api.egg-info/SOURCES.txt +0 -0
  55. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api.egg-info/dependency_links.txt +0 -0
  56. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api.egg-info/requires.txt +0 -0
  57. {tesla_fleet_api-1.0.9 → tesla_fleet_api-1.0.10}/tesla_fleet_api.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tesla_fleet_api
3
- Version: 1.0.9
3
+ Version: 1.0.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
@@ -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="1.0.9",
8
+ version="1.0.10",
9
9
  author="Brett Adams",
10
10
  author_email="hello@teslemetry.com",
11
11
  description="Tesla Fleet API library for Python",
@@ -3,7 +3,7 @@
3
3
  from enum import Enum
4
4
  import logging
5
5
 
6
- VERSION = "1.0.9"
6
+ VERSION = "1.0.10"
7
7
  LOGGER = logging.getLogger(__package__)
8
8
  SERVERS = {
9
9
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
@@ -65,6 +65,8 @@ SERVICE_UUID = "00000211-b2d1-43f0-9b88-960cebf8b91e"
65
65
  WRITE_UUID = "00000212-b2d1-43f0-9b88-960cebf8b91e"
66
66
  READ_UUID = "00000213-b2d1-43f0-9b88-960cebf8b91e"
67
67
  VERSION_UUID = "00000214-b2d1-43f0-9b88-960cebf8b91e"
68
+ NAME_UUID = "00002a00-0000-1000-8000-00805f9b34fb"
69
+ APPEARANCE_UUID = "00002a01-0000-1000-8000-00805f9b34fb"
68
70
 
69
71
  if TYPE_CHECKING:
70
72
  from tesla_fleet_api.tesla.tesla import Tesla
@@ -216,6 +218,39 @@ class VehicleBluetooth(Commands):
216
218
  if resp.HasField(requires):
217
219
  return resp
218
220
 
221
+ async def query_display_name(self, max_attempts=5) -> str | None:
222
+ """Read the device name via GATT characteristic if available"""
223
+ for i in range(max_attempts):
224
+ try:
225
+ # Standard GATT Device Name characteristic (0x2A00)
226
+ device_name = (await self.client.read_gatt_char(NAME_UUID)).decode('utf-8')
227
+ if device_name.startswith("🔑 "):
228
+ return device_name.replace("🔑 ","")
229
+ await asyncio.sleep(1)
230
+ LOGGER.debug(f"Attempt {i+1} to query display name failed, {device_name}")
231
+ except Exception as e:
232
+ LOGGER.error(f"Failed to read device name: {e}")
233
+
234
+ async def query_appearance(self) -> bytearray | None:
235
+ """Read the device appearance via GATT characteristic if available"""
236
+ try:
237
+ # Standard GATT Appearance characteristic (0x2A01)
238
+ return await self.client.read_gatt_char(APPEARANCE_UUID)
239
+ except Exception as e:
240
+ LOGGER.error(f"Failed to read device appearance: {e}")
241
+ return None
242
+
243
+ async def query_version(self) -> int | None:
244
+ """Read the device version via GATT characteristic if available"""
245
+ try:
246
+ # Custom GATT Version characteristic (0x2A02)
247
+ device_version = await self.client.read_gatt_char(VERSION_UUID)
248
+ # Convert the bytes to an integer
249
+ if device_version and len(device_version) > 0:
250
+ return int.from_bytes(device_version, byteorder='big')
251
+ except Exception as e:
252
+ LOGGER.error(f"Failed to read device version: {e}")
253
+ return None
219
254
 
220
255
  async def pair(self, role: Role = Role.ROLE_OWNER, form: KeyFormFactor = KeyFormFactor.KEY_FORM_FACTOR_CLOUD_KEY, timeout: int = 60):
221
256
  """Pair the key."""
@@ -18,9 +18,11 @@ class Vehicle:
18
18
  """Base class describing a Tesla vehicle."""
19
19
 
20
20
  vin: str
21
+ parent: Tesla
21
22
 
22
23
  def __init__(self, parent: Tesla, vin: str):
23
24
  self.vin = vin
25
+ self.parent = parent
24
26
 
25
27
  @property
26
28
  def pre2021(self) -> bool:
@@ -1,12 +1,16 @@
1
1
  from __future__ import annotations
2
+ import asyncio
2
3
  from typing import TYPE_CHECKING
4
+ from bleak import BleakClient
3
5
  from bleak.backends.device import BLEDevice
6
+ from bleak_retry_connector import establish_connection
4
7
  from cryptography.hazmat.primitives.asymmetric import ec
5
8
 
6
9
  from tesla_fleet_api.tesla.vehicle.signed import VehicleSigned
7
- from tesla_fleet_api.tesla.vehicle.bluetooth import VehicleBluetooth
10
+ from tesla_fleet_api.tesla.vehicle.bluetooth import NAME_UUID, VehicleBluetooth
8
11
  from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
9
12
  from tesla_fleet_api.tesla.vehicle.vehicle import Vehicle
13
+ from tesla_fleet_api.const import LOGGER
10
14
 
11
15
  if TYPE_CHECKING:
12
16
  from tesla_fleet_api.tesla.fleet import TeslaFleetApi
@@ -69,3 +73,27 @@ class VehiclesBluetooth(dict[str, Vehicle]):
69
73
  vehicle = self.Bluetooth(self._parent, vin, key, device)
70
74
  self[vin] = vehicle
71
75
  return vehicle
76
+
77
+ async def query_display_name(self, device: BLEDevice, max_attempts=5) -> str | None:
78
+ """Queries the name of a bluetooth vehicle."""
79
+ client = await establish_connection(
80
+ BleakClient,
81
+ device,
82
+ device.name or "Unknown",
83
+ max_attempts=max_attempts
84
+ )
85
+ name: str | None = None
86
+ for i in range(max_attempts):
87
+ try:
88
+ # Standard GATT Device Name characteristic (0x2A00)
89
+ device_name = (await client.read_gatt_char(NAME_UUID)).decode('utf-8')
90
+ if device_name.startswith("🔑 "):
91
+ name = device_name.replace("🔑 ","")
92
+ break
93
+ await asyncio.sleep(1)
94
+ LOGGER.debug(f"Attempt {i+1} to query display name failed, {device_name}")
95
+ except Exception as e:
96
+ LOGGER.error(f"Failed to read device name: {e}")
97
+
98
+ await client.disconnect()
99
+ return name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: tesla_fleet_api
3
- Version: 1.0.9
3
+ Version: 1.0.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