tesla-fleet-api 0.7.5__py3-none-any.whl → 0.7.7__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.7.5"
6
+ VERSION = "0.7.7"
7
7
  LOGGER = logging.getLogger(__package__)
8
8
  SERVERS = {
9
9
  "na": "https://fleet-api.prd.na.vn.cloud.tesla.com",
@@ -15,10 +15,16 @@ SERVERS = {
15
15
  class IntEnum(int, Enum):
16
16
  """Integer Enum."""
17
17
 
18
+ def __str__(self) -> str:
19
+ return str(self.value)
20
+
18
21
 
19
22
  class StrEnum(str, Enum):
20
23
  """String Enum."""
21
24
 
25
+ def __str__(self) -> str:
26
+ return self.value
27
+
22
28
 
23
29
  class Method(StrEnum):
24
30
  """HTTP Methods."""
@@ -302,3 +308,13 @@ class TelemetryAlert(StrEnum):
302
308
  CUSTOMER = "Customer"
303
309
  SERVICE = "Service"
304
310
  SERVICE_FIX = "ServiceFix"
311
+
312
+
313
+ class TeslaEnergyPeriod(StrEnum):
314
+ """Period for history for energy sites"""
315
+
316
+ DAY = "day"
317
+ WEEK = "week"
318
+ MONTH = "month"
319
+ YEAR = "year"
320
+ LIFETIME = "lifetime"
tesla_fleet_api/energy.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
  from typing import Any, TYPE_CHECKING
3
- from .const import Method, EnergyOperationMode, EnergyExportMode
3
+ from .const import Method, EnergyOperationMode, EnergyExportMode, TeslaEnergyPeriod
4
4
  from .energyspecific import EnergySpecific
5
5
 
6
6
  if TYPE_CHECKING:
@@ -32,18 +32,17 @@ class Energy:
32
32
  async def backup_history(
33
33
  self,
34
34
  energy_site_id: int,
35
- kind: str,
36
35
  start_date: str,
37
36
  end_date: str,
38
- period: str,
37
+ period: TeslaEnergyPeriod | str,
39
38
  time_zone: str,
40
39
  ) -> dict[str, Any]:
41
40
  """Returns the backup (off-grid) event history of the site in duration of seconds."""
42
41
  return await self._request(
43
42
  Method.GET,
44
43
  f"api/1/energy_sites/{energy_site_id}/calendar_history",
45
- json={
46
- "kind": kind,
44
+ params={
45
+ "kind": "backup",
47
46
  "start_date": start_date,
48
47
  "end_date": end_date,
49
48
  "period": period,
@@ -54,7 +53,6 @@ class Energy:
54
53
  async def charge_history(
55
54
  self,
56
55
  energy_site_id: int,
57
- kind: str,
58
56
  start_date: str,
59
57
  end_date: str,
60
58
  time_zone: str,
@@ -64,7 +62,7 @@ class Energy:
64
62
  Method.GET,
65
63
  f"api/1/energy_sites/{energy_site_id}/telemetry_history",
66
64
  params={
67
- "kind": kind,
65
+ "kind": "charge",
68
66
  "start_date": start_date,
69
67
  "end_date": end_date,
70
68
  "time_zone": time_zone,
@@ -74,10 +72,9 @@ class Energy:
74
72
  async def energy_history(
75
73
  self,
76
74
  energy_site_id: int,
77
- kind: str,
78
75
  start_date: str,
79
76
  end_date: str,
80
- period: str,
77
+ period: TeslaEnergyPeriod | str,
81
78
  time_zone: str,
82
79
  ) -> dict[str, Any]:
83
80
  """Returns the energy measurements of the site, aggregated to the requested period."""
@@ -85,7 +82,7 @@ class Energy:
85
82
  Method.GET,
86
83
  f"api/1/energy_sites/{energy_site_id}/calendar_history",
87
84
  params={
88
- "kind": kind,
85
+ "kind": "energy",
89
86
  "start_date": start_date,
90
87
  "end_date": end_date,
91
88
  "period": period,
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
  from typing import Any, TYPE_CHECKING
3
- from .const import EnergyExportMode, EnergyOperationMode
3
+ from .const import EnergyExportMode, EnergyOperationMode, TeslaEnergyPeriod
4
4
 
5
5
  if TYPE_CHECKING:
6
6
  from .energy import Energy
@@ -29,20 +29,22 @@ class EnergySpecific:
29
29
 
30
30
  async def backup_history(
31
31
  self,
32
- kind: str,
33
32
  start_date: str,
34
33
  end_date: str,
35
- period: str,
34
+ period: TeslaEnergyPeriod | str,
36
35
  time_zone: str,
37
36
  ) -> dict[str, Any]:
38
37
  """Returns the backup (off-grid) event history of the site in duration of seconds."""
39
38
  return await self._parent.backup_history(
40
- self.energy_site_id, kind, start_date, end_date, period, time_zone
39
+ self.energy_site_id,
40
+ start_date,
41
+ end_date,
42
+ period,
43
+ time_zone,
41
44
  )
42
45
 
43
46
  async def charge_history(
44
47
  self,
45
- kind: str,
46
48
  start_date: str,
47
49
  end_date: str,
48
50
  time_zone: str,
@@ -50,7 +52,6 @@ class EnergySpecific:
50
52
  """Returns the charging history of a wall connector."""
51
53
  return await self._parent.charge_history(
52
54
  self.energy_site_id,
53
- kind,
54
55
  start_date,
55
56
  end_date,
56
57
  time_zone,
@@ -58,16 +59,14 @@ class EnergySpecific:
58
59
 
59
60
  async def energy_history(
60
61
  self,
61
- kind: str,
62
62
  start_date: str,
63
63
  end_date: str,
64
- period: str,
64
+ period: TeslaEnergyPeriod | str,
65
65
  time_zone: str,
66
66
  ) -> dict[str, Any]:
67
67
  """Returns the energy measurements of the site, aggregated to the requested period."""
68
68
  return await self._parent.energy_history(
69
69
  self.energy_site_id,
70
- kind,
71
70
  start_date,
72
71
  end_date,
73
72
  period,
@@ -98,7 +98,6 @@ class TeslaFleetApi:
98
98
  if access_token := await self.refresh_hook():
99
99
  self.access_token = access_token
100
100
 
101
- LOGGER.debug("Sending request to %s", path)
102
101
 
103
102
  # Remove None values from params and json
104
103
  if params:
@@ -119,6 +118,7 @@ class TeslaFleetApi:
119
118
  json=json,
120
119
  params=params,
121
120
  ) as resp:
121
+ LOGGER.debug("Requested: %s", resp.url)
122
122
  LOGGER.debug("Response Status: %s", resp.status)
123
123
  if "x-txid" in resp.headers:
124
124
  LOGGER.debug("Response TXID: %s", resp.headers["x-txid"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tesla_fleet_api
3
- Version: 0.7.5
3
+ Version: 0.7.7
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
@@ -1,12 +1,12 @@
1
1
  tesla_fleet_api/__init__.py,sha256=qGS4Qfp0uHaeK8UXOQVYjZ9rs_iR-CJ6rfCMLswphKA,667
2
2
  tesla_fleet_api/charging.py,sha256=N_mc8axrXj3iduqLj_jCt4Vx86tHqe3xqQT4R1R7HvU,1689
3
- tesla_fleet_api/const.py,sha256=V9xe0-ix3bAWLM6YcZQ8QzZJCBBh0X30tnwlg1lmfM4,9277
4
- tesla_fleet_api/energy.py,sha256=m4QytEJAeYg5NVtOiN8G6nLiv_ud20rkmCJ3lQVUPxk,5829
5
- tesla_fleet_api/energyspecific.py,sha256=zggN-q0tf6EH_57bM4EuQ-IdcemKP0o-xv__LArRNnA,4147
3
+ tesla_fleet_api/const.py,sha256=qKibu7-3myCC8IrfgY3qhJCuOXfawcJVdEDYp3brBTc,9577
4
+ tesla_fleet_api/energy.py,sha256=wFHF4M8DUAAIYEA6Y-GZNtxDfJnkNFSEeN3EXZSv6cI,5845
5
+ tesla_fleet_api/energyspecific.py,sha256=-k1M57QIm2ABSBy00XV1feX3k_nkTh08KOq5mTw9qEg,4156
6
6
  tesla_fleet_api/exceptions.py,sha256=0-qeJUfyUGUcm2R3_W4OuGImgshY92ApSixl_CRM8ak,11171
7
7
  tesla_fleet_api/partner.py,sha256=1vIBUaxKLIfqcC0X6VXZN0dMAzj_CLNPUMjA6QVqZ1k,1223
8
8
  tesla_fleet_api/ratecalculator.py,sha256=4lz8yruUeouHXh_3ezsXX-CTpIegp1T1J4VuRV_qdHA,1791
9
- tesla_fleet_api/teslafleetapi.py,sha256=U6kRKS0yYztQuXPcslhZxH15-G1mPMXoFKEcwKtuVY4,5496
9
+ tesla_fleet_api/teslafleetapi.py,sha256=T4BI9QYwygC4WsvcMEksR36Xzbow5M8uujktlFOE3UA,5496
10
10
  tesla_fleet_api/teslafleetoauth.py,sha256=OY9yRQuokYo3ts0C8Qb6Z-o9NNAGHbX9F5mHfAh50fo,4121
11
11
  tesla_fleet_api/teslafleetopensource.py,sha256=TJfVPcqJlA1b3kMoGuLr-g5Gn8UDyYsTZhjvGY1MtIk,2007
12
12
  tesla_fleet_api/teslemetry.py,sha256=tXGfZmF0lO3fdgdoR2T8mXlWuF4dPKZebGijkwQN5Mk,3138
@@ -14,8 +14,8 @@ tesla_fleet_api/tessie.py,sha256=4dBYxe1G2v9JvJGRbb01wXrAmvWT4jOfV4f_VQE_vkE,230
14
14
  tesla_fleet_api/user.py,sha256=TZE2oh-n5zrhKXmGRuiNL9voKVODD7rBhGE_IObYVGA,1179
15
15
  tesla_fleet_api/vehicle.py,sha256=KFFotHSmzaC4MhIlU8hoG7SVvPiV3_FC__uJf8BG_G0,31412
16
16
  tesla_fleet_api/vehiclespecific.py,sha256=Nr4zZzfmIuw3RFYjQEX6c_xtYZgztMsN5ohVn-YEH0I,20600
17
- tesla_fleet_api-0.7.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
- tesla_fleet_api-0.7.5.dist-info/METADATA,sha256=bkkbZDV0ZU2z0_yzK71LzN8iUXFJldQZmHvup9PI6cs,3821
19
- tesla_fleet_api-0.7.5.dist-info/WHEEL,sha256=5Mi1sN9lKoFv_gxcPtisEVrJZihrm_beibeg5R6xb4I,91
20
- tesla_fleet_api-0.7.5.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
21
- tesla_fleet_api-0.7.5.dist-info/RECORD,,
17
+ tesla_fleet_api-0.7.7.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
18
+ tesla_fleet_api-0.7.7.dist-info/METADATA,sha256=8VwPOUW8phYKyyjRXetnbuTjosx844WXy8KgWticPnA,3821
19
+ tesla_fleet_api-0.7.7.dist-info/WHEEL,sha256=5Mi1sN9lKoFv_gxcPtisEVrJZihrm_beibeg5R6xb4I,91
20
+ tesla_fleet_api-0.7.7.dist-info/top_level.txt,sha256=jeNbog_1saXBFrGpom9WyPWmilxsyP3szL_G7JLWQfM,16
21
+ tesla_fleet_api-0.7.7.dist-info/RECORD,,