aiopowerwall 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.
- aiopowerwall-0.1.0/.gitignore +222 -0
- aiopowerwall-0.1.0/LICENSE +26 -0
- aiopowerwall-0.1.0/PKG-INFO +135 -0
- aiopowerwall-0.1.0/README.md +100 -0
- aiopowerwall-0.1.0/pyproject.toml +78 -0
- aiopowerwall-0.1.0/src/aiopowerwall/__init__.py +55 -0
- aiopowerwall-0.1.0/src/aiopowerwall/client.py +720 -0
- aiopowerwall-0.1.0/src/aiopowerwall/exceptions.py +38 -0
- aiopowerwall-0.1.0/src/aiopowerwall/models.py +68 -0
- aiopowerwall-0.1.0/src/aiopowerwall/proto/__init__.py +23 -0
- aiopowerwall-0.1.0/src/aiopowerwall/proto/tedapi.proto +308 -0
- aiopowerwall-0.1.0/src/aiopowerwall/proto/tedapi_combined.proto +345 -0
- aiopowerwall-0.1.0/src/aiopowerwall/proto/tedapi_combined_pb2.py +119 -0
- aiopowerwall-0.1.0/src/aiopowerwall/proto/tedapi_pb2.py +62 -0
- aiopowerwall-0.1.0/src/aiopowerwall/py.typed +0 -0
- aiopowerwall-0.1.0/src/aiopowerwall/queries.py +51 -0
- aiopowerwall-0.1.0/src/aiopowerwall/transport.py +372 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
# Local testing
|
|
221
|
+
*.pem
|
|
222
|
+
test.py
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Portions of this project are derived from pypowerwall by Jason Cox
|
|
4
|
+
(https://github.com/jasonacox/pypowerwall), licensed under the MIT License:
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2022 Jason A. Cox
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Teslemetry
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aiopowerwall
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async Tesla Powerwall 3 client over the TEDAPI v1r RSA-signed LAN protocol.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Teslemetry/aiopowerwall
|
|
6
|
+
Project-URL: Repository, https://github.com/Teslemetry/aiopowerwall
|
|
7
|
+
Project-URL: Issues, https://github.com/Teslemetry/aiopowerwall/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/Teslemetry/aiopowerwall/releases
|
|
9
|
+
Author-email: Teslemetry <hello@teslemetry.com>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: aiohttp,asyncio,home-assistant,powerwall,tedapi,tesla
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
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.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Home Automation
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.11
|
|
25
|
+
Requires-Dist: aiohttp>=3.9
|
|
26
|
+
Requires-Dist: cryptography>=41
|
|
27
|
+
Requires-Dist: protobuf>=4.25
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
31
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
33
|
+
Requires-Dist: types-protobuf; extra == 'dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# aiopowerwall
|
|
37
|
+
|
|
38
|
+
An async Tesla Powerwall 3 client built on `aiohttp`, written for Home
|
|
39
|
+
Assistant and any other asyncio code.
|
|
40
|
+
|
|
41
|
+
## Status
|
|
42
|
+
|
|
43
|
+
**Beta (0.x).** The wire protocol and the public Python API may change
|
|
44
|
+
between minor versions until 1.0. Pin a tight version range if you depend
|
|
45
|
+
on this library in production.
|
|
46
|
+
|
|
47
|
+
This library speaks the Powerwall's **TEDAPI v1r** protocol — RSA-signed
|
|
48
|
+
protobuf messages directly to your Powerwall. It is intentionally
|
|
49
|
+
scoped to:
|
|
50
|
+
|
|
51
|
+
- Powerwall 3, and updated Powerwall 2 (untested)
|
|
52
|
+
- Local LAN access only (no cloud telemetry)
|
|
53
|
+
- Read + control commands (status, config, firmware, components, max-backup)
|
|
54
|
+
|
|
55
|
+
The RSA key pair used for v1r authentication must be **registered with the
|
|
56
|
+
gateway out-of-band**, typically via the Tesla Fleet API. This library
|
|
57
|
+
consumes an already-paired private key — it does not implement registration.
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install aiopowerwall
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Quick start
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import asyncio
|
|
69
|
+
from pathlib import Path
|
|
70
|
+
from aiopowerwall import PowerwallClient
|
|
71
|
+
|
|
72
|
+
async def main() -> None:
|
|
73
|
+
pem = Path("tedapi_rsa_private.pem").read_bytes()
|
|
74
|
+
async with PowerwallClient(
|
|
75
|
+
host="192.168.91.1",
|
|
76
|
+
gateway_password="<gateway-password>",
|
|
77
|
+
rsa_private_key_pem=pem,
|
|
78
|
+
) as pw:
|
|
79
|
+
await pw.connect()
|
|
80
|
+
print("DIN:", pw.din)
|
|
81
|
+
print("Battery SoC:", await pw.get_battery_soe(), "%")
|
|
82
|
+
print("Grid:", await pw.get_grid_status())
|
|
83
|
+
print("Power:", await pw.current_power())
|
|
84
|
+
|
|
85
|
+
asyncio.run(main())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## API surface
|
|
89
|
+
|
|
90
|
+
| Method | Returns |
|
|
91
|
+
| --- | --- |
|
|
92
|
+
| `connect()` | DIN string |
|
|
93
|
+
| `get_din()` | DIN string |
|
|
94
|
+
| `get_config()` | `config.json` (dict) |
|
|
95
|
+
| `get_status()` | DeviceController query (narrow) |
|
|
96
|
+
| `get_device_controller()` | DeviceController query (extended) |
|
|
97
|
+
| `get_components()` | Powerwall 3 component data |
|
|
98
|
+
| `get_firmware_version(details=...)` | Version string or details dict |
|
|
99
|
+
| `get_meters_aggregates()` | `/api/meters/aggregates` |
|
|
100
|
+
| `get_battery_soe()` | Battery SoC percentage |
|
|
101
|
+
| `get_grid_status()` | Grid status string |
|
|
102
|
+
| `battery_level()` | SoC computed from status payload |
|
|
103
|
+
| `current_power(location=...)` | Real power per meter aggregate |
|
|
104
|
+
| `backup_time_remaining()` | Hours of backup at current load |
|
|
105
|
+
| `write_config(updates)` | Patch `config.json` (dotted paths) |
|
|
106
|
+
| `schedule_max_backup(seconds)` | Schedule manual backup event |
|
|
107
|
+
| `cancel_max_backup()` | Cancel manual backup event |
|
|
108
|
+
| `get_backup_events()` | Active and scheduled backup events |
|
|
109
|
+
|
|
110
|
+
All read methods cache responses with a configurable TTL
|
|
111
|
+
(`cache_status_ttl`, `cache_config_ttl`); pass `force=True` to refresh.
|
|
112
|
+
|
|
113
|
+
## Exceptions
|
|
114
|
+
|
|
115
|
+
All errors are subclasses of `PowerwallError`:
|
|
116
|
+
|
|
117
|
+
- `PowerwallConnectionError` — transport failure / timeout
|
|
118
|
+
- `PowerwallAuthenticationError` — bad password or unregistered RSA key
|
|
119
|
+
- `PowerwallRateLimitError` — gateway returned 429/503
|
|
120
|
+
- `PowerwallFaultError` — signed-message fault (key inactive, expired, etc.)
|
|
121
|
+
- `PowerwallProtocolError` — malformed response
|
|
122
|
+
|
|
123
|
+
## Acknowledgements
|
|
124
|
+
|
|
125
|
+
This project builds on the protocol research and reference implementation in
|
|
126
|
+
[`pypowerwall`](https://github.com/jasonacox/pypowerwall) by
|
|
127
|
+
[Jason Cox](https://github.com/jasonacox), distributed under the
|
|
128
|
+
[MIT License](https://github.com/jasonacox/pypowerwall/blob/main/LICENSE).
|
|
129
|
+
Huge thanks to Jason and the pypowerwall contributors for reverse-engineering
|
|
130
|
+
and documenting the TEDAPI protocol.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT (see `LICENSE`). Original pypowerwall copyright and license notice are
|
|
135
|
+
retained in `LICENSE`.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# aiopowerwall
|
|
2
|
+
|
|
3
|
+
An async Tesla Powerwall 3 client built on `aiohttp`, written for Home
|
|
4
|
+
Assistant and any other asyncio code.
|
|
5
|
+
|
|
6
|
+
## Status
|
|
7
|
+
|
|
8
|
+
**Beta (0.x).** The wire protocol and the public Python API may change
|
|
9
|
+
between minor versions until 1.0. Pin a tight version range if you depend
|
|
10
|
+
on this library in production.
|
|
11
|
+
|
|
12
|
+
This library speaks the Powerwall's **TEDAPI v1r** protocol — RSA-signed
|
|
13
|
+
protobuf messages directly to your Powerwall. It is intentionally
|
|
14
|
+
scoped to:
|
|
15
|
+
|
|
16
|
+
- Powerwall 3, and updated Powerwall 2 (untested)
|
|
17
|
+
- Local LAN access only (no cloud telemetry)
|
|
18
|
+
- Read + control commands (status, config, firmware, components, max-backup)
|
|
19
|
+
|
|
20
|
+
The RSA key pair used for v1r authentication must be **registered with the
|
|
21
|
+
gateway out-of-band**, typically via the Tesla Fleet API. This library
|
|
22
|
+
consumes an already-paired private key — it does not implement registration.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install aiopowerwall
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import asyncio
|
|
34
|
+
from pathlib import Path
|
|
35
|
+
from aiopowerwall import PowerwallClient
|
|
36
|
+
|
|
37
|
+
async def main() -> None:
|
|
38
|
+
pem = Path("tedapi_rsa_private.pem").read_bytes()
|
|
39
|
+
async with PowerwallClient(
|
|
40
|
+
host="192.168.91.1",
|
|
41
|
+
gateway_password="<gateway-password>",
|
|
42
|
+
rsa_private_key_pem=pem,
|
|
43
|
+
) as pw:
|
|
44
|
+
await pw.connect()
|
|
45
|
+
print("DIN:", pw.din)
|
|
46
|
+
print("Battery SoC:", await pw.get_battery_soe(), "%")
|
|
47
|
+
print("Grid:", await pw.get_grid_status())
|
|
48
|
+
print("Power:", await pw.current_power())
|
|
49
|
+
|
|
50
|
+
asyncio.run(main())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API surface
|
|
54
|
+
|
|
55
|
+
| Method | Returns |
|
|
56
|
+
| --- | --- |
|
|
57
|
+
| `connect()` | DIN string |
|
|
58
|
+
| `get_din()` | DIN string |
|
|
59
|
+
| `get_config()` | `config.json` (dict) |
|
|
60
|
+
| `get_status()` | DeviceController query (narrow) |
|
|
61
|
+
| `get_device_controller()` | DeviceController query (extended) |
|
|
62
|
+
| `get_components()` | Powerwall 3 component data |
|
|
63
|
+
| `get_firmware_version(details=...)` | Version string or details dict |
|
|
64
|
+
| `get_meters_aggregates()` | `/api/meters/aggregates` |
|
|
65
|
+
| `get_battery_soe()` | Battery SoC percentage |
|
|
66
|
+
| `get_grid_status()` | Grid status string |
|
|
67
|
+
| `battery_level()` | SoC computed from status payload |
|
|
68
|
+
| `current_power(location=...)` | Real power per meter aggregate |
|
|
69
|
+
| `backup_time_remaining()` | Hours of backup at current load |
|
|
70
|
+
| `write_config(updates)` | Patch `config.json` (dotted paths) |
|
|
71
|
+
| `schedule_max_backup(seconds)` | Schedule manual backup event |
|
|
72
|
+
| `cancel_max_backup()` | Cancel manual backup event |
|
|
73
|
+
| `get_backup_events()` | Active and scheduled backup events |
|
|
74
|
+
|
|
75
|
+
All read methods cache responses with a configurable TTL
|
|
76
|
+
(`cache_status_ttl`, `cache_config_ttl`); pass `force=True` to refresh.
|
|
77
|
+
|
|
78
|
+
## Exceptions
|
|
79
|
+
|
|
80
|
+
All errors are subclasses of `PowerwallError`:
|
|
81
|
+
|
|
82
|
+
- `PowerwallConnectionError` — transport failure / timeout
|
|
83
|
+
- `PowerwallAuthenticationError` — bad password or unregistered RSA key
|
|
84
|
+
- `PowerwallRateLimitError` — gateway returned 429/503
|
|
85
|
+
- `PowerwallFaultError` — signed-message fault (key inactive, expired, etc.)
|
|
86
|
+
- `PowerwallProtocolError` — malformed response
|
|
87
|
+
|
|
88
|
+
## Acknowledgements
|
|
89
|
+
|
|
90
|
+
This project builds on the protocol research and reference implementation in
|
|
91
|
+
[`pypowerwall`](https://github.com/jasonacox/pypowerwall) by
|
|
92
|
+
[Jason Cox](https://github.com/jasonacox), distributed under the
|
|
93
|
+
[MIT License](https://github.com/jasonacox/pypowerwall/blob/main/LICENSE).
|
|
94
|
+
Huge thanks to Jason and the pypowerwall contributors for reverse-engineering
|
|
95
|
+
and documenting the TEDAPI protocol.
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT (see `LICENSE`). Original pypowerwall copyright and license notice are
|
|
100
|
+
retained in `LICENSE`.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.18"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aiopowerwall"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Async Tesla Powerwall 3 client over the TEDAPI v1r RSA-signed LAN protocol."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
authors = [{ name = "Teslemetry", email = "hello@teslemetry.com" }]
|
|
14
|
+
keywords = ["tesla", "powerwall", "tedapi", "asyncio", "aiohttp", "home-assistant"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Framework :: AsyncIO",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Home Automation",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"aiohttp>=3.9",
|
|
30
|
+
"cryptography>=41",
|
|
31
|
+
"protobuf>=4.25",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
dev = [
|
|
36
|
+
"mypy>=1.8",
|
|
37
|
+
"pytest>=8",
|
|
38
|
+
"pytest-asyncio>=0.23",
|
|
39
|
+
"ruff>=0.5",
|
|
40
|
+
"types-protobuf",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/Teslemetry/aiopowerwall"
|
|
45
|
+
Repository = "https://github.com/Teslemetry/aiopowerwall"
|
|
46
|
+
Issues = "https://github.com/Teslemetry/aiopowerwall/issues"
|
|
47
|
+
Changelog = "https://github.com/Teslemetry/aiopowerwall/releases"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["src/aiopowerwall"]
|
|
51
|
+
|
|
52
|
+
[tool.hatch.build.targets.sdist]
|
|
53
|
+
include = ["src/aiopowerwall", "README.md", "LICENSE", "pyproject.toml"]
|
|
54
|
+
|
|
55
|
+
[tool.mypy]
|
|
56
|
+
python_version = "3.11"
|
|
57
|
+
strict = true
|
|
58
|
+
warn_unreachable = true
|
|
59
|
+
files = ["src/aiopowerwall"]
|
|
60
|
+
|
|
61
|
+
[[tool.mypy.overrides]]
|
|
62
|
+
# Generated protobuf bindings ship without strict stubs; they're an
|
|
63
|
+
# implementation detail of the transport.
|
|
64
|
+
module = "aiopowerwall.proto.*"
|
|
65
|
+
ignore_errors = true
|
|
66
|
+
|
|
67
|
+
[[tool.mypy.overrides]]
|
|
68
|
+
module = ["google.protobuf.*"]
|
|
69
|
+
ignore_missing_imports = true
|
|
70
|
+
|
|
71
|
+
[tool.ruff]
|
|
72
|
+
line-length = 100
|
|
73
|
+
target-version = "py311"
|
|
74
|
+
extend-exclude = ["src/aiopowerwall/proto/*_pb2.py"]
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint]
|
|
77
|
+
select = ["E", "F", "W", "I", "B", "UP", "ASYNC", "SIM", "RUF"]
|
|
78
|
+
ignore = ["E501"] # long lines come from the verbatim GraphQL constants
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""Async Tesla Powerwall 3 client (TEDAPI v1r over RSA-signed LAN).
|
|
2
|
+
|
|
3
|
+
This package provides a single high-level entry point,
|
|
4
|
+
:class:`PowerwallClient`, plus typed exceptions and TypedDict response models.
|
|
5
|
+
|
|
6
|
+
The RSA key pair used for v1r signing must be registered with the gateway
|
|
7
|
+
out-of-band (typically via the Tesla Fleet API). This library only consumes
|
|
8
|
+
an already-paired private key.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
from .client import DEFAULT_GATEWAY_HOST, PowerwallClient
|
|
14
|
+
from .exceptions import (
|
|
15
|
+
PowerwallAuthenticationError,
|
|
16
|
+
PowerwallConnectionError,
|
|
17
|
+
PowerwallError,
|
|
18
|
+
PowerwallFaultError,
|
|
19
|
+
PowerwallProtocolError,
|
|
20
|
+
PowerwallRateLimitError,
|
|
21
|
+
)
|
|
22
|
+
from .models import (
|
|
23
|
+
BackupEvent,
|
|
24
|
+
BackupEventsPayload,
|
|
25
|
+
ComponentsPayload,
|
|
26
|
+
ConfigPayload,
|
|
27
|
+
ControllerPayload,
|
|
28
|
+
FirmwareDetails,
|
|
29
|
+
ManualBackupInfo,
|
|
30
|
+
PowerLocation,
|
|
31
|
+
StatusPayload,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__version__ = "0.1.0"
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"DEFAULT_GATEWAY_HOST",
|
|
38
|
+
"BackupEvent",
|
|
39
|
+
"BackupEventsPayload",
|
|
40
|
+
"ComponentsPayload",
|
|
41
|
+
"ConfigPayload",
|
|
42
|
+
"ControllerPayload",
|
|
43
|
+
"FirmwareDetails",
|
|
44
|
+
"ManualBackupInfo",
|
|
45
|
+
"PowerLocation",
|
|
46
|
+
"PowerwallAuthenticationError",
|
|
47
|
+
"PowerwallClient",
|
|
48
|
+
"PowerwallConnectionError",
|
|
49
|
+
"PowerwallError",
|
|
50
|
+
"PowerwallFaultError",
|
|
51
|
+
"PowerwallProtocolError",
|
|
52
|
+
"PowerwallRateLimitError",
|
|
53
|
+
"StatusPayload",
|
|
54
|
+
"__version__",
|
|
55
|
+
]
|