leapmotor-api 0.1.0__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.
@@ -0,0 +1,93 @@
1
+ """Leapmotor API — Unofficial Python client for the Leapmotor vehicle cloud API."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __version__ = "0.1.0"
6
+
7
+ from .client import LeapmotorApiClient, normalize_vehicle
8
+ from .const import (
9
+ DEFAULT_BASE_URL,
10
+ DEFAULT_LANGUAGE,
11
+ REMOTE_ACTION_SPECS,
12
+ REMOTE_CTL_AC_SWITCH,
13
+ REMOTE_CTL_BATTERY_PREHEAT,
14
+ REMOTE_CTL_FIND_CAR,
15
+ REMOTE_CTL_LOCK,
16
+ REMOTE_CTL_QUICK_COOL,
17
+ REMOTE_CTL_QUICK_HEAT,
18
+ REMOTE_CTL_SUNSHADE,
19
+ REMOTE_CTL_SUNSHADE_CLOSE,
20
+ REMOTE_CTL_SUNSHADE_OPEN,
21
+ REMOTE_CTL_TRUNK,
22
+ REMOTE_CTL_TRUNK_CLOSE,
23
+ REMOTE_CTL_TRUNK_OPEN,
24
+ REMOTE_CTL_UNLOCK,
25
+ REMOTE_CTL_WINDSHIELD_DEFROST,
26
+ REMOTE_CTL_WINDOWS,
27
+ REMOTE_CTL_WINDOWS_CLOSE,
28
+ REMOTE_CTL_WINDOWS_OPEN,
29
+ )
30
+ from .exceptions import (
31
+ LeapmotorAccountCertError,
32
+ LeapmotorApiError,
33
+ LeapmotorAuthError,
34
+ LeapmotorMissingAppCertError,
35
+ )
36
+ from .models import (
37
+ BatteryStatus,
38
+ ClimateStatus,
39
+ ConnectivityStatus,
40
+ DoorStatus,
41
+ DrivingStatus,
42
+ IgnitionStatus,
43
+ LocationStatus,
44
+ RemoteActionResult,
45
+ RemoteActionSpec,
46
+ TirePressure,
47
+ Vehicle,
48
+ VehicleStatus,
49
+ WindowStatus,
50
+ )
51
+
52
+ __all__ = [
53
+ "__version__",
54
+ "BatteryStatus",
55
+ "ClimateStatus",
56
+ "ConnectivityStatus",
57
+ "DEFAULT_BASE_URL",
58
+ "DEFAULT_LANGUAGE",
59
+ "DoorStatus",
60
+ "DrivingStatus",
61
+ "IgnitionStatus",
62
+ "LeapmotorAccountCertError",
63
+ "LeapmotorApiClient",
64
+ "LeapmotorApiError",
65
+ "LeapmotorAuthError",
66
+ "LeapmotorMissingAppCertError",
67
+ "LocationStatus",
68
+ "REMOTE_ACTION_SPECS",
69
+ "REMOTE_CTL_AC_SWITCH",
70
+ "REMOTE_CTL_BATTERY_PREHEAT",
71
+ "REMOTE_CTL_FIND_CAR",
72
+ "REMOTE_CTL_LOCK",
73
+ "REMOTE_CTL_QUICK_COOL",
74
+ "REMOTE_CTL_QUICK_HEAT",
75
+ "REMOTE_CTL_SUNSHADE",
76
+ "REMOTE_CTL_SUNSHADE_CLOSE",
77
+ "REMOTE_CTL_SUNSHADE_OPEN",
78
+ "REMOTE_CTL_TRUNK",
79
+ "REMOTE_CTL_TRUNK_CLOSE",
80
+ "REMOTE_CTL_TRUNK_OPEN",
81
+ "REMOTE_CTL_UNLOCK",
82
+ "REMOTE_CTL_WINDSHIELD_DEFROST",
83
+ "REMOTE_CTL_WINDOWS",
84
+ "REMOTE_CTL_WINDOWS_CLOSE",
85
+ "REMOTE_CTL_WINDOWS_OPEN",
86
+ "RemoteActionResult",
87
+ "RemoteActionSpec",
88
+ "TirePressure",
89
+ "Vehicle",
90
+ "VehicleStatus",
91
+ "WindowStatus",
92
+ "normalize_vehicle",
93
+ ]
@@ -0,0 +1,125 @@
1
+ """Async wrapper for the Leapmotor API client.
2
+
3
+ Wraps the synchronous ``LeapmotorApiClient`` using ``asyncio.to_thread()``
4
+ to provide a non-blocking interface for async frameworks (Home Assistant,
5
+ FastAPI, etc.).
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import asyncio
11
+ from typing import Any
12
+
13
+ from .client import LeapmotorApiClient
14
+ from .models import Vehicle, VehicleStatus
15
+
16
+
17
+ class AsyncLeapmotorApiClient:
18
+ """Async wrapper around :class:`LeapmotorApiClient`.
19
+
20
+ All methods delegate to the sync client via ``asyncio.to_thread()``.
21
+ """
22
+
23
+ def __init__(self, client: LeapmotorApiClient) -> None:
24
+ self._client = client
25
+
26
+ @property
27
+ def client(self) -> LeapmotorApiClient:
28
+ """Access the underlying synchronous client."""
29
+ return self._client
30
+
31
+ async def close(self) -> None:
32
+ await asyncio.to_thread(self._client.close)
33
+
34
+ async def login(self) -> None:
35
+ await asyncio.to_thread(self._client.login)
36
+
37
+ async def fetch_data(self) -> dict[str, Any]:
38
+ return await asyncio.to_thread(self._client.fetch_data)
39
+
40
+ async def get_vehicle_list(self) -> list[Vehicle]:
41
+ return await asyncio.to_thread(self._client.get_vehicle_list)
42
+
43
+ async def get_vehicle_status(self, vehicle: Vehicle) -> VehicleStatus:
44
+ return await asyncio.to_thread(self._client.get_vehicle_status, vehicle)
45
+
46
+ async def get_vehicle_raw_status(self, vehicle: Vehicle) -> dict[str, Any]:
47
+ return await asyncio.to_thread(self._client.get_vehicle_raw_status, vehicle)
48
+
49
+ async def get_mileage_energy_detail(self, vehicle: Vehicle) -> dict[str, Any]:
50
+ return await asyncio.to_thread(self._client.get_mileage_energy_detail, vehicle)
51
+
52
+ async def get_car_picture(self, vehicle: Vehicle) -> dict[str, Any]:
53
+ return await asyncio.to_thread(self._client.get_car_picture, vehicle)
54
+
55
+ async def lock_vehicle(self, vin: str) -> dict[str, Any]:
56
+ return await asyncio.to_thread(self._client.lock_vehicle, vin)
57
+
58
+ async def unlock_vehicle(self, vin: str) -> dict[str, Any]:
59
+ return await asyncio.to_thread(self._client.unlock_vehicle, vin)
60
+
61
+ async def open_trunk(self, vin: str) -> dict[str, Any]:
62
+ return await asyncio.to_thread(self._client.open_trunk, vin)
63
+
64
+ async def close_trunk(self, vin: str) -> dict[str, Any]:
65
+ return await asyncio.to_thread(self._client.close_trunk, vin)
66
+
67
+ async def find_vehicle(self, vin: str) -> dict[str, Any]:
68
+ return await asyncio.to_thread(self._client.find_vehicle, vin)
69
+
70
+ async def control_sunshade(self, vin: str) -> dict[str, Any]:
71
+ return await asyncio.to_thread(self._client.control_sunshade, vin)
72
+
73
+ async def open_sunshade(self, vin: str) -> dict[str, Any]:
74
+ return await asyncio.to_thread(self._client.open_sunshade, vin)
75
+
76
+ async def close_sunshade(self, vin: str) -> dict[str, Any]:
77
+ return await asyncio.to_thread(self._client.close_sunshade, vin)
78
+
79
+ async def battery_preheat(self, vin: str) -> dict[str, Any]:
80
+ return await asyncio.to_thread(self._client.battery_preheat, vin)
81
+
82
+ async def windows(self, vin: str) -> dict[str, Any]:
83
+ return await asyncio.to_thread(self._client.windows, vin)
84
+
85
+ async def open_windows(self, vin: str) -> dict[str, Any]:
86
+ return await asyncio.to_thread(self._client.open_windows, vin)
87
+
88
+ async def close_windows(self, vin: str) -> dict[str, Any]:
89
+ return await asyncio.to_thread(self._client.close_windows, vin)
90
+
91
+ async def ac_switch(self, vin: str) -> dict[str, Any]:
92
+ return await asyncio.to_thread(self._client.ac_switch, vin)
93
+
94
+ async def quick_cool(self, vin: str) -> dict[str, Any]:
95
+ return await asyncio.to_thread(self._client.quick_cool, vin)
96
+
97
+ async def quick_heat(self, vin: str) -> dict[str, Any]:
98
+ return await asyncio.to_thread(self._client.quick_heat, vin)
99
+
100
+ async def windshield_defrost(self, vin: str) -> dict[str, Any]:
101
+ return await asyncio.to_thread(self._client.windshield_defrost, vin)
102
+
103
+ async def set_charge_limit(self, vin: str, charge_limit_percent: int) -> dict[str, Any]:
104
+ return await asyncio.to_thread(self._client.set_charge_limit, vin, charge_limit_percent)
105
+
106
+ async def send_destination(
107
+ self,
108
+ vin: str,
109
+ *,
110
+ address: str,
111
+ address_name: str,
112
+ latitude: float,
113
+ longitude: float,
114
+ ) -> dict[str, Any]:
115
+ return await asyncio.to_thread(
116
+ self._client.send_destination,
117
+ vin,
118
+ address=address,
119
+ address_name=address_name,
120
+ latitude=latitude,
121
+ longitude=longitude,
122
+ )
123
+
124
+ async def download_car_picture_package(self, *, picture_key: str) -> bytes:
125
+ return await asyncio.to_thread(self._client.download_car_picture_package, picture_key=picture_key)