aiopytedapi 0.1.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.
- aiopytedapi-0.1.0/.gitignore +17 -0
- aiopytedapi-0.1.0/CHANGELOG.md +13 -0
- aiopytedapi-0.1.0/LICENSE +21 -0
- aiopytedapi-0.1.0/NOTICE +32 -0
- aiopytedapi-0.1.0/PKG-INFO +139 -0
- aiopytedapi-0.1.0/README.md +107 -0
- aiopytedapi-0.1.0/pyproject.toml +92 -0
- aiopytedapi-0.1.0/src/aiopytedapi/__init__.py +71 -0
- aiopytedapi-0.1.0/src/aiopytedapi/_proto/__init__.py +1 -0
- aiopytedapi-0.1.0/src/aiopytedapi/_proto/tedapi.proto +641 -0
- aiopytedapi-0.1.0/src/aiopytedapi/_proto/tedapi_pb2.py +186 -0
- aiopytedapi-0.1.0/src/aiopytedapi/_proto/tedapi_pb2.pyi +857 -0
- aiopytedapi-0.1.0/src/aiopytedapi/_version.py +24 -0
- aiopytedapi-0.1.0/src/aiopytedapi/client.py +364 -0
- aiopytedapi-0.1.0/src/aiopytedapi/exceptions.py +76 -0
- aiopytedapi-0.1.0/src/aiopytedapi/keys.py +142 -0
- aiopytedapi-0.1.0/src/aiopytedapi/models.py +404 -0
- aiopytedapi-0.1.0/src/aiopytedapi/py.typed +0 -0
- aiopytedapi-0.1.0/src/aiopytedapi/transport.py +351 -0
- aiopytedapi-0.1.0/tests/__init__.py +0 -0
- aiopytedapi-0.1.0/tests/conftest.py +68 -0
- aiopytedapi-0.1.0/tests/fakes.py +97 -0
- aiopytedapi-0.1.0/tests/test_client.py +400 -0
- aiopytedapi-0.1.0/tests/test_keys_models.py +234 -0
- aiopytedapi-0.1.0/tests/test_transport.py +331 -0
- aiopytedapi-0.1.0/tools/gen_proto.sh +29 -0
- aiopytedapi-0.1.0/tools/requirements-gen.txt +2 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
/dist/
|
|
4
|
+
/build/
|
|
5
|
+
*.egg-info/
|
|
6
|
+
.venv*/
|
|
7
|
+
/.gen/
|
|
8
|
+
.coverage
|
|
9
|
+
coverage.xml
|
|
10
|
+
.mypy_cache/
|
|
11
|
+
.ruff_cache/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
src/aiopytedapi/_version.py
|
|
14
|
+
# Keys and gateway captures never belong in the repo
|
|
15
|
+
*.pem
|
|
16
|
+
*.der
|
|
17
|
+
*.key
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (2026-11-19)
|
|
4
|
+
|
|
5
|
+
First release.
|
|
6
|
+
|
|
7
|
+
- Async client (`TedapiClient`) over an aiohttp session you provide, with two connections: signed (`/tedapi/v1r`, RSA key) and Gateway Wi-Fi (`/tedapi/v1`, Wi-Fi password, read-only).
|
|
8
|
+
- Network status: each interface's state, connectivity and signal strength.
|
|
9
|
+
- Site import/export limits: read on both connections, set over the signed connection.
|
|
10
|
+
- Battery calibration delay: status and delay, over the signed connection.
|
|
11
|
+
- Registered keys: list on both connections; add and remove over the signed connection.
|
|
12
|
+
- Gateway configuration (config.json) read.
|
|
13
|
+
- Typed exceptions for every failure (`TedapiError` and subclasses).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chandana Napagoda
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
aiopytedapi-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
aiopytedapi includes material derived from pypowerwall
|
|
2
|
+
(https://github.com/jasonacox/pypowerwall), used under the MIT License:
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2021 Jason Cox
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Derived material:
|
|
27
|
+
- src/aiopytedapi/_proto/tedapi.proto: the TEDAPI wire schema, from
|
|
28
|
+
pypowerwall's tedapi_combined.proto, which credits Matthew1471's Tesla-API
|
|
29
|
+
(signing protocol), Nexarian's TEDAPI protocol work and
|
|
30
|
+
Teslemetry/tesla-protocol (energy device schema).
|
|
31
|
+
- The signed (v1r) request format, and the network status, authorized clients,
|
|
32
|
+
battery calibration delay and site limit models, ported from pypowerwall.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: aiopytedapi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async client for the Tesla Powerwall gateway's local TEDAPI
|
|
5
|
+
Project-URL: Homepage, https://github.com/cnapagoda/aiopytedapi
|
|
6
|
+
Project-URL: Issues, https://github.com/cnapagoda/aiopytedapi/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/cnapagoda/aiopytedapi/blob/main/CHANGELOG.md
|
|
8
|
+
Author-email: Chandana Napagoda <cnapagoda@gmail.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: asyncio,home-assistant,powerwall,tedapi,tesla
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
25
|
+
Classifier: Topic :: Home Automation
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Requires-Dist: aiohttp>=3.9
|
|
29
|
+
Requires-Dist: cryptography>=42
|
|
30
|
+
Requires-Dist: protobuf>=4.25.1
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# aiopytedapi
|
|
34
|
+
|
|
35
|
+
An async Python client for the Tesla Powerwall gateway's local TEDAPI.
|
|
36
|
+
|
|
37
|
+
- **Async only**, built on [aiohttp](https://docs.aiohttp.org/). You pass in the `ClientSession`, so it fits Home Assistant and other asyncio apps.
|
|
38
|
+
- **Typed** (`py.typed`, checked with `mypy --strict`).
|
|
39
|
+
- **Local**: talks to the gateway on your network. Nothing goes to Tesla's servers.
|
|
40
|
+
- **Errors are exceptions**, never `None`: every one derives from `TedapiError`.
|
|
41
|
+
|
|
42
|
+
> **Status: alpha (0.x).** The API may change between minor versions. Pin `aiopytedapi>=0.1,<0.2`.
|
|
43
|
+
|
|
44
|
+
## Connections
|
|
45
|
+
|
|
46
|
+
| Connection | Endpoint | Authenticates with | Can change settings |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| **Signed** | `/tedapi/v1r` on the gateway's home-network address or its Wi-Fi address (192.168.91.1) | An RSA key registered with the gateway | Yes |
|
|
49
|
+
| **Gateway Wi-Fi** | `/tedapi/v1` on 192.168.91.1 | The Wi-Fi password printed on the gateway | No (read-only) |
|
|
50
|
+
|
|
51
|
+
Registering a key needs Tesla's cloud once (for example `python -m pypowerwall register`). This library doesn't do that step.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
| Feature | Methods | Signed | Gateway Wi-Fi |
|
|
56
|
+
|---|---|---|---|
|
|
57
|
+
| Network status (Wi-Fi, Ethernet, cellular) | `get_network_status()` | ✅ Powerwall 3 | ✅ Powerwall 3 and 2 |
|
|
58
|
+
| Site import/export limits | `get_site_limits()`, `set_import_limit()`, `set_export_limit()` | ✅ read and write | ✅ read |
|
|
59
|
+
| Battery calibration delay | `get_battery_calibration_delay_status()`, `delay_battery_calibration()` | ✅ | — |
|
|
60
|
+
| Registered keys | `get_authorized_clients()`, `add_authorized_client()`, `remove_authorized_client()` | ✅ list, add, remove | ✅ list |
|
|
61
|
+
| Gateway configuration | `get_config()` | ✅ | ✅ |
|
|
62
|
+
|
|
63
|
+
What has been seen on hardware so far:
|
|
64
|
+
|
|
65
|
+
- **Network status:** Powerwall 3 (firmware 26.34.3) on both connections; Powerwall 2 (26.42.0) on Gateway Wi-Fi only. Over the signed connection a Powerwall 2 answers `MessageFaultError` (`MESSAGEFAULT_ERROR_TIMEOUT`).
|
|
66
|
+
- **Registered keys:** listing, adding and removing on a Powerwall 3 (26.34.3).
|
|
67
|
+
- **Site limits:** reading on a Powerwall 3 (26.34.3). Writing has not been tried on hardware.
|
|
68
|
+
- **Calibration delay:** a Powerwall 3 on 26.34.3 answers `NotSupportedError` (the firmware doesn't implement it). The delay command has not been sent to hardware.
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import asyncio
|
|
74
|
+
from pathlib import Path
|
|
75
|
+
|
|
76
|
+
import aiohttp
|
|
77
|
+
|
|
78
|
+
from aiopytedapi import RsaKey, TedapiClient
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
async def main() -> None:
|
|
82
|
+
key = RsaKey.from_pem(Path("tedapi_rsa_private.pem").read_bytes())
|
|
83
|
+
async with aiohttp.ClientSession() as session:
|
|
84
|
+
client = TedapiClient.signed(session, "192.168.1.50", key, password="ABCDE")
|
|
85
|
+
await client.connect()
|
|
86
|
+
|
|
87
|
+
status = await client.get_network_status()
|
|
88
|
+
print(status.active, status.to_dict())
|
|
89
|
+
|
|
90
|
+
limits = await client.get_site_limits()
|
|
91
|
+
print(limits.import_limit_kw, limits.export_limit_kw)
|
|
92
|
+
|
|
93
|
+
for c in (await client.get_authorized_clients()).clients:
|
|
94
|
+
print(c.fingerprint[:16], c.type, c.state)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
asyncio.run(main())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`password` is the customer login password (the last 5 characters of the Gateway Wi-Fi password on most gateways). It's used to fetch the DIN. Pass `din=` instead if you already know it.
|
|
101
|
+
|
|
102
|
+
For the Gateway Wi-Fi connection:
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
client = TedapiClient.wifi(session, "WIFI_PASSWORD")
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Safety
|
|
109
|
+
|
|
110
|
+
Some commands change how your Powerwall and your site behave.
|
|
111
|
+
|
|
112
|
+
- **Site limits:** an installer may have set the import or export limit to meet your grid connection agreement (for example a network export limit). Don't raise or remove one unless you're allowed to.
|
|
113
|
+
- **Calibration delay:** the gateway allows a limited number of delays, and each may use one.
|
|
114
|
+
- **Removing a key** stops that client sending commands. Removing the key you sign with is refused unless you pass `allow_current_key=True`.
|
|
115
|
+
|
|
116
|
+
Every command that changes something logs a WARNING. You use these commands at your own risk; check your warranty and your grid connection agreement first.
|
|
117
|
+
|
|
118
|
+
## Privacy
|
|
119
|
+
|
|
120
|
+
Models keep values that identify a home or a person (Wi-Fi SSID, MAC and IP addresses, key descriptions) out of `repr`, and `to_dict()` only includes them with `details=True`. The gateway's Wi-Fi password is never parsed. `get_config()` returns the gateway's full configuration, which includes identifiers: don't log or publish it.
|
|
121
|
+
|
|
122
|
+
## Credits
|
|
123
|
+
|
|
124
|
+
The wire schema and the request formats come from [pypowerwall](https://github.com/jasonacox/pypowerwall) (MIT), which in turn credits Matthew1471's Tesla-API, Nexarian's TEDAPI work and [Teslemetry/tesla-protocol](https://github.com/Teslemetry/tesla-protocol). See [NOTICE](NOTICE).
|
|
125
|
+
|
|
126
|
+
This project is not affiliated with or endorsed by Tesla.
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
pip install -e . pytest pytest-asyncio pytest-cov mypy ruff types-protobuf
|
|
132
|
+
ruff check . && mypy && pytest --cov
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The protobuf bindings are generated: change `src/aiopytedapi/_proto/tedapi.proto`, then run `bash tools/gen_proto.sh`. Never edit `tedapi_pb2.py` by hand.
|
|
136
|
+
|
|
137
|
+
## Licence
|
|
138
|
+
|
|
139
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# aiopytedapi
|
|
2
|
+
|
|
3
|
+
An async Python client for the Tesla Powerwall gateway's local TEDAPI.
|
|
4
|
+
|
|
5
|
+
- **Async only**, built on [aiohttp](https://docs.aiohttp.org/). You pass in the `ClientSession`, so it fits Home Assistant and other asyncio apps.
|
|
6
|
+
- **Typed** (`py.typed`, checked with `mypy --strict`).
|
|
7
|
+
- **Local**: talks to the gateway on your network. Nothing goes to Tesla's servers.
|
|
8
|
+
- **Errors are exceptions**, never `None`: every one derives from `TedapiError`.
|
|
9
|
+
|
|
10
|
+
> **Status: alpha (0.x).** The API may change between minor versions. Pin `aiopytedapi>=0.1,<0.2`.
|
|
11
|
+
|
|
12
|
+
## Connections
|
|
13
|
+
|
|
14
|
+
| Connection | Endpoint | Authenticates with | Can change settings |
|
|
15
|
+
|---|---|---|---|
|
|
16
|
+
| **Signed** | `/tedapi/v1r` on the gateway's home-network address or its Wi-Fi address (192.168.91.1) | An RSA key registered with the gateway | Yes |
|
|
17
|
+
| **Gateway Wi-Fi** | `/tedapi/v1` on 192.168.91.1 | The Wi-Fi password printed on the gateway | No (read-only) |
|
|
18
|
+
|
|
19
|
+
Registering a key needs Tesla's cloud once (for example `python -m pypowerwall register`). This library doesn't do that step.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
| Feature | Methods | Signed | Gateway Wi-Fi |
|
|
24
|
+
|---|---|---|---|
|
|
25
|
+
| Network status (Wi-Fi, Ethernet, cellular) | `get_network_status()` | ✅ Powerwall 3 | ✅ Powerwall 3 and 2 |
|
|
26
|
+
| Site import/export limits | `get_site_limits()`, `set_import_limit()`, `set_export_limit()` | ✅ read and write | ✅ read |
|
|
27
|
+
| Battery calibration delay | `get_battery_calibration_delay_status()`, `delay_battery_calibration()` | ✅ | — |
|
|
28
|
+
| Registered keys | `get_authorized_clients()`, `add_authorized_client()`, `remove_authorized_client()` | ✅ list, add, remove | ✅ list |
|
|
29
|
+
| Gateway configuration | `get_config()` | ✅ | ✅ |
|
|
30
|
+
|
|
31
|
+
What has been seen on hardware so far:
|
|
32
|
+
|
|
33
|
+
- **Network status:** Powerwall 3 (firmware 26.34.3) on both connections; Powerwall 2 (26.42.0) on Gateway Wi-Fi only. Over the signed connection a Powerwall 2 answers `MessageFaultError` (`MESSAGEFAULT_ERROR_TIMEOUT`).
|
|
34
|
+
- **Registered keys:** listing, adding and removing on a Powerwall 3 (26.34.3).
|
|
35
|
+
- **Site limits:** reading on a Powerwall 3 (26.34.3). Writing has not been tried on hardware.
|
|
36
|
+
- **Calibration delay:** a Powerwall 3 on 26.34.3 answers `NotSupportedError` (the firmware doesn't implement it). The delay command has not been sent to hardware.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import asyncio
|
|
42
|
+
from pathlib import Path
|
|
43
|
+
|
|
44
|
+
import aiohttp
|
|
45
|
+
|
|
46
|
+
from aiopytedapi import RsaKey, TedapiClient
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
async def main() -> None:
|
|
50
|
+
key = RsaKey.from_pem(Path("tedapi_rsa_private.pem").read_bytes())
|
|
51
|
+
async with aiohttp.ClientSession() as session:
|
|
52
|
+
client = TedapiClient.signed(session, "192.168.1.50", key, password="ABCDE")
|
|
53
|
+
await client.connect()
|
|
54
|
+
|
|
55
|
+
status = await client.get_network_status()
|
|
56
|
+
print(status.active, status.to_dict())
|
|
57
|
+
|
|
58
|
+
limits = await client.get_site_limits()
|
|
59
|
+
print(limits.import_limit_kw, limits.export_limit_kw)
|
|
60
|
+
|
|
61
|
+
for c in (await client.get_authorized_clients()).clients:
|
|
62
|
+
print(c.fingerprint[:16], c.type, c.state)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
asyncio.run(main())
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`password` is the customer login password (the last 5 characters of the Gateway Wi-Fi password on most gateways). It's used to fetch the DIN. Pass `din=` instead if you already know it.
|
|
69
|
+
|
|
70
|
+
For the Gateway Wi-Fi connection:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
client = TedapiClient.wifi(session, "WIFI_PASSWORD")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Safety
|
|
77
|
+
|
|
78
|
+
Some commands change how your Powerwall and your site behave.
|
|
79
|
+
|
|
80
|
+
- **Site limits:** an installer may have set the import or export limit to meet your grid connection agreement (for example a network export limit). Don't raise or remove one unless you're allowed to.
|
|
81
|
+
- **Calibration delay:** the gateway allows a limited number of delays, and each may use one.
|
|
82
|
+
- **Removing a key** stops that client sending commands. Removing the key you sign with is refused unless you pass `allow_current_key=True`.
|
|
83
|
+
|
|
84
|
+
Every command that changes something logs a WARNING. You use these commands at your own risk; check your warranty and your grid connection agreement first.
|
|
85
|
+
|
|
86
|
+
## Privacy
|
|
87
|
+
|
|
88
|
+
Models keep values that identify a home or a person (Wi-Fi SSID, MAC and IP addresses, key descriptions) out of `repr`, and `to_dict()` only includes them with `details=True`. The gateway's Wi-Fi password is never parsed. `get_config()` returns the gateway's full configuration, which includes identifiers: don't log or publish it.
|
|
89
|
+
|
|
90
|
+
## Credits
|
|
91
|
+
|
|
92
|
+
The wire schema and the request formats come from [pypowerwall](https://github.com/jasonacox/pypowerwall) (MIT), which in turn credits Matthew1471's Tesla-API, Nexarian's TEDAPI work and [Teslemetry/tesla-protocol](https://github.com/Teslemetry/tesla-protocol). See [NOTICE](NOTICE).
|
|
93
|
+
|
|
94
|
+
This project is not affiliated with or endorsed by Tesla.
|
|
95
|
+
|
|
96
|
+
## Development
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install -e . pytest pytest-asyncio pytest-cov mypy ruff types-protobuf
|
|
100
|
+
ruff check . && mypy && pytest --cov
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The protobuf bindings are generated: change `src/aiopytedapi/_proto/tedapi.proto`, then run `bash tools/gen_proto.sh`. Never edit `tedapi_pb2.py` by hand.
|
|
104
|
+
|
|
105
|
+
## Licence
|
|
106
|
+
|
|
107
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.21", "hatch-vcs>=0.4"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aiopytedapi"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Async client for the Tesla Powerwall gateway's local TEDAPI"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
12
|
+
authors = [{ name = "Chandana Napagoda", email = "cnapagoda@gmail.com" }]
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"aiohttp>=3.9",
|
|
16
|
+
"cryptography>=42",
|
|
17
|
+
"protobuf>=4.25.1",
|
|
18
|
+
]
|
|
19
|
+
keywords = ["tesla", "powerwall", "tedapi", "asyncio", "home-assistant"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Framework :: AsyncIO",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
27
|
+
"Programming Language :: Python :: 3.9",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Topic :: Home Automation",
|
|
34
|
+
"Typing :: Typed",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/cnapagoda/aiopytedapi"
|
|
39
|
+
Issues = "https://github.com/cnapagoda/aiopytedapi/issues"
|
|
40
|
+
Changelog = "https://github.com/cnapagoda/aiopytedapi/blob/main/CHANGELOG.md"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.version]
|
|
43
|
+
source = "vcs"
|
|
44
|
+
fallback-version = "0.0.0"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.hooks.vcs]
|
|
47
|
+
version-file = "src/aiopytedapi/_version.py"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.sdist]
|
|
50
|
+
include = ["src/aiopytedapi", "tests", "tools", "README.md", "CHANGELOG.md", "LICENSE", "NOTICE"]
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.wheel]
|
|
53
|
+
packages = ["src/aiopytedapi"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 120
|
|
57
|
+
target-version = "py39"
|
|
58
|
+
extend-exclude = ["src/aiopytedapi/_proto/tedapi_pb2.py", "src/aiopytedapi/_proto/tedapi_pb2.pyi"]
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = ["E", "F", "W", "I", "B", "UP", "S", "BLE", "SIM", "RUF", "PL", "PT", "ASYNC"]
|
|
62
|
+
ignore = ["PLR0913", "PLR2004", "UP007", "UP006", "UP035", "UP045"]
|
|
63
|
+
|
|
64
|
+
[tool.ruff.lint.per-file-ignores]
|
|
65
|
+
"tests/**" = ["S101", "S105", "S106", "PLR2004", "PLC0415", "SLF001", "PT018", "PLR0912", "PLR0917"]
|
|
66
|
+
|
|
67
|
+
[tool.mypy]
|
|
68
|
+
python_version = "3.10"
|
|
69
|
+
strict = true
|
|
70
|
+
files = ["src/aiopytedapi"]
|
|
71
|
+
exclude = ["src/aiopytedapi/_proto/tedapi_pb2\\.py$"]
|
|
72
|
+
|
|
73
|
+
[[tool.mypy.overrides]]
|
|
74
|
+
module = ["aiopytedapi._proto.*"]
|
|
75
|
+
ignore_errors = true
|
|
76
|
+
|
|
77
|
+
[tool.pytest.ini_options]
|
|
78
|
+
asyncio_mode = "auto"
|
|
79
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
80
|
+
testpaths = ["tests"]
|
|
81
|
+
markers = ["live: needs a real gateway (never run in CI)"]
|
|
82
|
+
addopts = "-m 'not live'"
|
|
83
|
+
|
|
84
|
+
[tool.coverage.run]
|
|
85
|
+
source = ["aiopytedapi"]
|
|
86
|
+
branch = true
|
|
87
|
+
omit = ["*/_proto/*", "*/_version.py"]
|
|
88
|
+
|
|
89
|
+
[tool.coverage.report]
|
|
90
|
+
fail_under = 95
|
|
91
|
+
show_missing = true
|
|
92
|
+
skip_covered = true
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""aiopytedapi: an async client for the Tesla Powerwall gateway's local TEDAPI.
|
|
2
|
+
|
|
3
|
+
Talks to the gateway over the signed connection (an RSA key registered with
|
|
4
|
+
the gateway) or the Gateway Wi-Fi connection (the Wi-Fi password). Uses an
|
|
5
|
+
aiohttp session the caller provides.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from .client import NOT_IMPLEMENTED, TedapiClient
|
|
11
|
+
from .exceptions import (
|
|
12
|
+
GatewayAuthError,
|
|
13
|
+
GatewayBusyError,
|
|
14
|
+
GatewayConnectionError,
|
|
15
|
+
GatewayRejectedError,
|
|
16
|
+
KeyNotAuthorizedError,
|
|
17
|
+
KeyPendingVerificationError,
|
|
18
|
+
MessageFaultError,
|
|
19
|
+
NotSupportedError,
|
|
20
|
+
SignedConnectionRequired,
|
|
21
|
+
TedapiError,
|
|
22
|
+
UnexpectedResponseError,
|
|
23
|
+
)
|
|
24
|
+
from .keys import RsaKey, fingerprint, public_key_bytes, rsa_public_key_der
|
|
25
|
+
from .models import (
|
|
26
|
+
AuthorizedClient,
|
|
27
|
+
AuthorizedClients,
|
|
28
|
+
CalibrationDelayStatus,
|
|
29
|
+
IPv4Settings,
|
|
30
|
+
NetworkInterfaceStatus,
|
|
31
|
+
NetworkStatus,
|
|
32
|
+
SiteLimits,
|
|
33
|
+
)
|
|
34
|
+
from .transport import WIFI_HOST, SignedTransport, Transport, WifiTransport
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
from ._version import __version__
|
|
38
|
+
except ImportError: # pragma: no cover - only in an unbuilt checkout
|
|
39
|
+
__version__ = "0.0.0"
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"NOT_IMPLEMENTED",
|
|
43
|
+
"WIFI_HOST",
|
|
44
|
+
"AuthorizedClient",
|
|
45
|
+
"AuthorizedClients",
|
|
46
|
+
"CalibrationDelayStatus",
|
|
47
|
+
"GatewayAuthError",
|
|
48
|
+
"GatewayBusyError",
|
|
49
|
+
"GatewayConnectionError",
|
|
50
|
+
"GatewayRejectedError",
|
|
51
|
+
"IPv4Settings",
|
|
52
|
+
"KeyNotAuthorizedError",
|
|
53
|
+
"KeyPendingVerificationError",
|
|
54
|
+
"MessageFaultError",
|
|
55
|
+
"NetworkInterfaceStatus",
|
|
56
|
+
"NetworkStatus",
|
|
57
|
+
"NotSupportedError",
|
|
58
|
+
"RsaKey",
|
|
59
|
+
"SignedConnectionRequired",
|
|
60
|
+
"SignedTransport",
|
|
61
|
+
"SiteLimits",
|
|
62
|
+
"TedapiClient",
|
|
63
|
+
"TedapiError",
|
|
64
|
+
"Transport",
|
|
65
|
+
"UnexpectedResponseError",
|
|
66
|
+
"WifiTransport",
|
|
67
|
+
"__version__",
|
|
68
|
+
"fingerprint",
|
|
69
|
+
"public_key_bytes",
|
|
70
|
+
"rsa_public_key_der",
|
|
71
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Generated protobuf bindings (see tools/gen_proto.sh)."""
|