python-vw-carnet 0.3.0__tar.gz → 0.4.0__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 (19) hide show
  1. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/PKG-INFO +1 -1
  2. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/pyproject.toml +1 -1
  3. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/__main__.py +12 -1
  4. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/client.py +27 -0
  5. python_vw_carnet-0.4.0/src/python_vw_carnet/models/generic.py +9 -0
  6. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/README.md +0 -0
  7. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/__init__.py +0 -0
  8. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/constants.py +0 -0
  9. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/errors.py +0 -0
  10. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/__init__.py +0 -0
  11. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/ev_summary.py +0 -0
  12. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/garage.py +0 -0
  13. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/spin.py +0 -0
  14. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/token.py +0 -0
  15. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/vehicle.py +0 -0
  16. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/vehicle_location.py +0 -0
  17. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/models/vehicle_session.py +0 -0
  18. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/py.typed +0 -0
  19. {python_vw_carnet-0.3.0 → python_vw_carnet-0.4.0}/src/python_vw_carnet/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: python-vw-carnet
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: Python client for myVW login, session management, and vehicle data APIs
5
5
  Author: dmillerw
6
6
  Author-email: dmillerw <dmillerw@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-vw-carnet"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "Python client for myVW login, session management, and vehicle data APIs"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -9,7 +9,14 @@ def build_parser() -> argparse.ArgumentParser:
9
9
  parser = argparse.ArgumentParser(description="Query captured myVW endpoints")
10
10
  parser.add_argument(
11
11
  "command",
12
- choices=["garage", "status", "location", "ev-summary"],
12
+ choices=[
13
+ "garage",
14
+ "status",
15
+ "location",
16
+ "ev-summary",
17
+ "preclimate_start",
18
+ "preclimate_stop",
19
+ ],
13
20
  help="Which payload to fetch",
14
21
  )
15
22
  parser.add_argument("--email", default=os.getenv("VW_EMAIL"))
@@ -44,6 +51,10 @@ def main() -> int:
44
51
  payload = client.get_vehicle(vehicle_id=args.vehicle_id)
45
52
  elif args.command == "location":
46
53
  payload = client.get_vehicle_location(vehicle_id=args.vehicle_id)
54
+ elif args.command == "preclimate_start":
55
+ payload = client.start_ev_preclimate(vehicle_id=args.vehicle_id)
56
+ elif args.command == "preclimate_stop":
57
+ payload = client.stop_ev_preclimate(vehicle_id=args.vehicle_id)
47
58
  else:
48
59
  payload = client.get_ev_summary(
49
60
  vehicle_id=args.vehicle_id, temp_unit=args.temp_unit
@@ -42,6 +42,7 @@ from .models import (
42
42
  VehicleSessionRequest,
43
43
  VehicleSessionResponse,
44
44
  )
45
+ from .models.generic import GenericCorrelationIdResponse
45
46
 
46
47
  logger = logging.getLogger(__name__)
47
48
 
@@ -177,6 +178,30 @@ class VWClient:
177
178
 
178
179
  return EVSummaryResponse.model_validate(self._decode_json(response))
179
180
 
181
+ def start_ev_preclimate(self, vehicle_id: str) -> GenericCorrelationIdResponse:
182
+ logger.debug("Starting climate for %s", vehicle_id)
183
+ user_id = self._require(self.state.user_id, "Missing user id")
184
+ response = self._request(
185
+ "POST",
186
+ f"{BASE_URL}/ev/v1/vehicle/{vehicle_id}/pretripclimate/start",
187
+ token=self._resolve_vehicle_token(vehicle_id),
188
+ user_id_header=user_id,
189
+ )
190
+
191
+ return GenericCorrelationIdResponse.model_validate(self._decode_json(response))
192
+
193
+ def stop_ev_preclimate(self, vehicle_id: str) -> GenericCorrelationIdResponse:
194
+ logger.debug("Starting climate for %s", vehicle_id)
195
+ user_id = self._require(self.state.user_id, "Missing user id")
196
+ response = self._request(
197
+ "POST",
198
+ f"{BASE_URL}/ev/v1/vehicle/{vehicle_id}/pretripclimate/stop",
199
+ token=self._resolve_vehicle_token(vehicle_id),
200
+ user_id_header=user_id,
201
+ )
202
+
203
+ return GenericCorrelationIdResponse.model_validate(self._decode_json(response))
204
+
180
205
  def close(self) -> None:
181
206
  logger.debug("Closing HTTP session")
182
207
  self.session.close()
@@ -308,6 +333,8 @@ class VWClient:
308
333
  return True
309
334
 
310
335
  def _try_refresh_vehicle_token(self, vehicle_id: str) -> bool:
336
+ self._try_refresh_access_token()
337
+
311
338
  if self._vehicle_token_valid(vehicle_id):
312
339
  logger.debug('Using cached vehicle token for "%s"', vehicle_id)
313
340
  return True
@@ -0,0 +1,9 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class Data(BaseModel):
5
+ correlationId: str
6
+
7
+
8
+ class GenericCorrelationIdResponse(BaseModel):
9
+ data: Data