weider-modbus 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.
- weider_modbus-0.1.0/.gitignore +220 -0
- weider_modbus-0.1.0/LICENSE +21 -0
- weider_modbus-0.1.0/PKG-INFO +160 -0
- weider_modbus-0.1.0/README.md +136 -0
- weider_modbus-0.1.0/pyproject.toml +70 -0
- weider_modbus-0.1.0/src/weider_modbus/__init__.py +36 -0
- weider_modbus-0.1.0/src/weider_modbus/components.py +246 -0
- weider_modbus-0.1.0/src/weider_modbus/const.py +22 -0
- weider_modbus-0.1.0/src/weider_modbus/device.py +75 -0
- weider_modbus-0.1.0/src/weider_modbus/helpers.py +60 -0
- weider_modbus-0.1.0/src/weider_modbus/py.typed +0 -0
- weider_modbus-0.1.0/tests/__init__.py +0 -0
- weider_modbus-0.1.0/tests/conftest.py +23 -0
- weider_modbus-0.1.0/tests/simulator.py +71 -0
- weider_modbus-0.1.0/tests/test_device.py +295 -0
- weider_modbus-0.1.0/tests/test_helpers.py +59 -0
- weider_modbus-0.1.0/tests/test_tcp.py +44 -0
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
*.lcov
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
53
|
+
cover/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
# Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# uv
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
# uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
# poetry.lock
|
|
110
|
+
# poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
# pdm.lock
|
|
117
|
+
# pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
# pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi/*
|
|
127
|
+
!.pixi/config.toml
|
|
128
|
+
|
|
129
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
130
|
+
__pypackages__/
|
|
131
|
+
|
|
132
|
+
# Celery stuff
|
|
133
|
+
celerybeat-schedule*
|
|
134
|
+
celerybeat.pid
|
|
135
|
+
|
|
136
|
+
# Redis
|
|
137
|
+
*.rdb
|
|
138
|
+
*.aof
|
|
139
|
+
*.pid
|
|
140
|
+
|
|
141
|
+
# RabbitMQ
|
|
142
|
+
mnesia/
|
|
143
|
+
rabbitmq/
|
|
144
|
+
rabbitmq-data/
|
|
145
|
+
|
|
146
|
+
# ActiveMQ
|
|
147
|
+
activemq-data/
|
|
148
|
+
|
|
149
|
+
# SageMath parsed files
|
|
150
|
+
*.sage.py
|
|
151
|
+
|
|
152
|
+
# Environments
|
|
153
|
+
.env
|
|
154
|
+
.envrc
|
|
155
|
+
.venv
|
|
156
|
+
env/
|
|
157
|
+
venv/
|
|
158
|
+
ENV/
|
|
159
|
+
env.bak/
|
|
160
|
+
venv.bak/
|
|
161
|
+
|
|
162
|
+
# Spyder project settings
|
|
163
|
+
.spyderproject
|
|
164
|
+
.spyproject
|
|
165
|
+
|
|
166
|
+
# Rope project settings
|
|
167
|
+
.ropeproject
|
|
168
|
+
|
|
169
|
+
# mkdocs/Zensical documentation
|
|
170
|
+
/site
|
|
171
|
+
|
|
172
|
+
# mypy
|
|
173
|
+
.mypy_cache/
|
|
174
|
+
.dmypy.json
|
|
175
|
+
dmypy.json
|
|
176
|
+
|
|
177
|
+
# Pyre type checker
|
|
178
|
+
.pyre/
|
|
179
|
+
|
|
180
|
+
# pytype static type analyzer
|
|
181
|
+
.pytype/
|
|
182
|
+
|
|
183
|
+
# Cython debug symbols
|
|
184
|
+
cython_debug/
|
|
185
|
+
|
|
186
|
+
# PyCharm
|
|
187
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
188
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
189
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
190
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
191
|
+
# .idea/
|
|
192
|
+
|
|
193
|
+
# Abstra
|
|
194
|
+
# Abstra is an AI-powered process automation framework.
|
|
195
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
196
|
+
# Learn more at https://abstra.io/docs
|
|
197
|
+
.abstra/
|
|
198
|
+
|
|
199
|
+
# Visual Studio Code
|
|
200
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore that
|
|
201
|
+
# can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
202
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer, you
|
|
203
|
+
# could uncomment the following to ignore the entire vscode folder
|
|
204
|
+
# .vscode/
|
|
205
|
+
# Temporary file for partial code execution
|
|
206
|
+
tempCodeRunnerFile.py
|
|
207
|
+
|
|
208
|
+
# Ruff stuff:
|
|
209
|
+
.ruff_cache/
|
|
210
|
+
|
|
211
|
+
# PyPI configuration file
|
|
212
|
+
.pypirc
|
|
213
|
+
|
|
214
|
+
# Marimo
|
|
215
|
+
marimo/_static/
|
|
216
|
+
marimo/_lsp/
|
|
217
|
+
__marimo__/
|
|
218
|
+
|
|
219
|
+
# Streamlit
|
|
220
|
+
.streamlit/secrets.toml
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 schadom
|
|
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.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: weider-modbus
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Async Python library for the Modbus TCP interface of Weider heat pumps, built on modbus-connection
|
|
5
|
+
Project-URL: Homepage, https://github.com/schadom/weider-modbus
|
|
6
|
+
Project-URL: Source, https://github.com/schadom/weider-modbus
|
|
7
|
+
Project-URL: Issues, https://github.com/schadom/weider-modbus/issues
|
|
8
|
+
Author: schadom
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: heat pump,home-assistant,modbus,weider,wt16
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: AsyncIO
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Home Automation
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.13
|
|
22
|
+
Requires-Dist: modbus-connection>=4.12.1
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# weider-modbus
|
|
26
|
+
|
|
27
|
+
Async Python library for the Modbus TCP interface of Weider WT16 heat pumps,
|
|
28
|
+
built on [modbus-connection](https://github.com/home-assistant-libs/modbus-connection).
|
|
29
|
+
|
|
30
|
+
> [!IMPORTANT]
|
|
31
|
+
> This library is not affiliated with Weider Wärmepumpen GmbH and is provided
|
|
32
|
+
> as-is and without warranty.
|
|
33
|
+
|
|
34
|
+
The library only reads and writes registers. It takes a `ModbusUnit` and never
|
|
35
|
+
opens a connection itself, so it works over any modbus-connection backend
|
|
36
|
+
(tmodbus, pymodbus, or the in-memory mock). It is used by the
|
|
37
|
+
[Weider WT16 Home Assistant integration](https://github.com/schadom/hacs_weider).
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install weider-modbus
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The library depends only on the backend-neutral `modbus-connection`
|
|
46
|
+
interface. To open a connection yourself, also install a backend:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
pip install "modbus-connection[tmodbus]"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import asyncio
|
|
56
|
+
|
|
57
|
+
from modbus_connection import ModbusTcpParams
|
|
58
|
+
from modbus_connection.tmodbus import ModbusConnection
|
|
59
|
+
|
|
60
|
+
from weider_modbus import WeiderWT16, plausible_temperature
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
async def main() -> None:
|
|
64
|
+
connection = ModbusConnection(ModbusTcpParams(host="192.168.1.50", port=502))
|
|
65
|
+
try:
|
|
66
|
+
device = WeiderWT16(connection.for_unit(1))
|
|
67
|
+
await device.async_update()
|
|
68
|
+
|
|
69
|
+
print("Hot water:", device.measurements.hot_water_temperature)
|
|
70
|
+
outdoor = plausible_temperature(device.measurements.outdoor_temperature)
|
|
71
|
+
print("Outdoor:", outdoor)
|
|
72
|
+
print("Compressor running:", device.digital_inputs.compressor)
|
|
73
|
+
print("SG Ready mode:", device.sg_ready_mode)
|
|
74
|
+
|
|
75
|
+
await device.async_set_hot_water_target(47.5)
|
|
76
|
+
finally:
|
|
77
|
+
await connection.close()
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
asyncio.run(main())
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Components
|
|
84
|
+
|
|
85
|
+
| Attribute | Modbus space | Content |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `device.measurements` | Input registers (FC04) | Temperatures, volume flow, runtimes, mixer position, active error text |
|
|
88
|
+
| `device.settings` | Holding registers (FC03/FC16) | Hot water and room target temperatures |
|
|
89
|
+
| `device.digital_inputs` | Discrete inputs (FC02) | Compressor, pumps, valves, blocks, SG Ready inputs |
|
|
90
|
+
|
|
91
|
+
A value reads as `None` until the first successful poll, or if the device
|
|
92
|
+
does not provide the register.
|
|
93
|
+
|
|
94
|
+
### Optional registers
|
|
95
|
+
|
|
96
|
+
Some firmware versions do not provide every register. The room temperature,
|
|
97
|
+
room target, mixer position, runtimes, active error text and any digital input
|
|
98
|
+
are optional. If the device rejects one of them with an illegal data address,
|
|
99
|
+
the library drops that register on the first poll and stops reading it. Any
|
|
100
|
+
other register error still raises, so real problems are not hidden.
|
|
101
|
+
|
|
102
|
+
### Errors
|
|
103
|
+
|
|
104
|
+
`async_update()` raises a `modbus_connection.ModbusError` subclass (or
|
|
105
|
+
`TimeoutError` / `OSError` from the transport) when a poll fails. The shared
|
|
106
|
+
connection reopens on the next request, so the caller can simply retry.
|
|
107
|
+
|
|
108
|
+
The target setters raise `ValueError` for a value outside the allowed range
|
|
109
|
+
(hot water 15–55 °C, room 15–35 °C), before anything is written.
|
|
110
|
+
|
|
111
|
+
### Helpers
|
|
112
|
+
|
|
113
|
+
- `plausible_temperature(value)` returns `None` for the placeholder values the
|
|
114
|
+
device reports for an unconnected sensor (outside −45 to 150 °C).
|
|
115
|
+
- `clean_error_text(value)` strips the padding from the active error text and
|
|
116
|
+
returns `None` when there is no error.
|
|
117
|
+
- `sg_ready_mode(...)` and `device.sg_ready_mode` derive the SG Ready operating
|
|
118
|
+
state (BZ1–BZ4) from the digital inputs.
|
|
119
|
+
|
|
120
|
+
## Hardware verification
|
|
121
|
+
|
|
122
|
+
The register addresses, the signed 0.1 °C temperature format and the
|
|
123
|
+
multi-register word order come from the existing integration. Confirm them
|
|
124
|
+
against your WT16 documentation, especially for negative temperatures. The
|
|
125
|
+
test simulator checks the software against this map, not the map against a
|
|
126
|
+
real heat pump.
|
|
127
|
+
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
Requires Python 3.13 or newer and [uv](https://docs.astral.sh/uv/).
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
uv sync
|
|
134
|
+
uv run pytest
|
|
135
|
+
uv run ruff check .
|
|
136
|
+
uv run ruff format --check .
|
|
137
|
+
uv run mypy
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
To run the synthetic WT16 on port 5020 for manual testing:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
uv run python -m tests.simulator
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Releasing
|
|
147
|
+
|
|
148
|
+
Releases are published to PyPI from GitHub Actions with
|
|
149
|
+
[trusted publishing](https://docs.pypi.org/trusted-publishers/).
|
|
150
|
+
|
|
151
|
+
1. Set the new `version` in `pyproject.toml` and merge it to `main`.
|
|
152
|
+
2. Create a GitHub release with a tag equal to that version (for example
|
|
153
|
+
`0.1.0`).
|
|
154
|
+
3. The `Publish` workflow builds the package and uploads it to PyPI.
|
|
155
|
+
|
|
156
|
+
A version number can be published only once.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# weider-modbus
|
|
2
|
+
|
|
3
|
+
Async Python library for the Modbus TCP interface of Weider WT16 heat pumps,
|
|
4
|
+
built on [modbus-connection](https://github.com/home-assistant-libs/modbus-connection).
|
|
5
|
+
|
|
6
|
+
> [!IMPORTANT]
|
|
7
|
+
> This library is not affiliated with Weider Wärmepumpen GmbH and is provided
|
|
8
|
+
> as-is and without warranty.
|
|
9
|
+
|
|
10
|
+
The library only reads and writes registers. It takes a `ModbusUnit` and never
|
|
11
|
+
opens a connection itself, so it works over any modbus-connection backend
|
|
12
|
+
(tmodbus, pymodbus, or the in-memory mock). It is used by the
|
|
13
|
+
[Weider WT16 Home Assistant integration](https://github.com/schadom/hacs_weider).
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install weider-modbus
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
The library depends only on the backend-neutral `modbus-connection`
|
|
22
|
+
interface. To open a connection yourself, also install a backend:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install "modbus-connection[tmodbus]"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import asyncio
|
|
32
|
+
|
|
33
|
+
from modbus_connection import ModbusTcpParams
|
|
34
|
+
from modbus_connection.tmodbus import ModbusConnection
|
|
35
|
+
|
|
36
|
+
from weider_modbus import WeiderWT16, plausible_temperature
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
async def main() -> None:
|
|
40
|
+
connection = ModbusConnection(ModbusTcpParams(host="192.168.1.50", port=502))
|
|
41
|
+
try:
|
|
42
|
+
device = WeiderWT16(connection.for_unit(1))
|
|
43
|
+
await device.async_update()
|
|
44
|
+
|
|
45
|
+
print("Hot water:", device.measurements.hot_water_temperature)
|
|
46
|
+
outdoor = plausible_temperature(device.measurements.outdoor_temperature)
|
|
47
|
+
print("Outdoor:", outdoor)
|
|
48
|
+
print("Compressor running:", device.digital_inputs.compressor)
|
|
49
|
+
print("SG Ready mode:", device.sg_ready_mode)
|
|
50
|
+
|
|
51
|
+
await device.async_set_hot_water_target(47.5)
|
|
52
|
+
finally:
|
|
53
|
+
await connection.close()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
asyncio.run(main())
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Components
|
|
60
|
+
|
|
61
|
+
| Attribute | Modbus space | Content |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `device.measurements` | Input registers (FC04) | Temperatures, volume flow, runtimes, mixer position, active error text |
|
|
64
|
+
| `device.settings` | Holding registers (FC03/FC16) | Hot water and room target temperatures |
|
|
65
|
+
| `device.digital_inputs` | Discrete inputs (FC02) | Compressor, pumps, valves, blocks, SG Ready inputs |
|
|
66
|
+
|
|
67
|
+
A value reads as `None` until the first successful poll, or if the device
|
|
68
|
+
does not provide the register.
|
|
69
|
+
|
|
70
|
+
### Optional registers
|
|
71
|
+
|
|
72
|
+
Some firmware versions do not provide every register. The room temperature,
|
|
73
|
+
room target, mixer position, runtimes, active error text and any digital input
|
|
74
|
+
are optional. If the device rejects one of them with an illegal data address,
|
|
75
|
+
the library drops that register on the first poll and stops reading it. Any
|
|
76
|
+
other register error still raises, so real problems are not hidden.
|
|
77
|
+
|
|
78
|
+
### Errors
|
|
79
|
+
|
|
80
|
+
`async_update()` raises a `modbus_connection.ModbusError` subclass (or
|
|
81
|
+
`TimeoutError` / `OSError` from the transport) when a poll fails. The shared
|
|
82
|
+
connection reopens on the next request, so the caller can simply retry.
|
|
83
|
+
|
|
84
|
+
The target setters raise `ValueError` for a value outside the allowed range
|
|
85
|
+
(hot water 15–55 °C, room 15–35 °C), before anything is written.
|
|
86
|
+
|
|
87
|
+
### Helpers
|
|
88
|
+
|
|
89
|
+
- `plausible_temperature(value)` returns `None` for the placeholder values the
|
|
90
|
+
device reports for an unconnected sensor (outside −45 to 150 °C).
|
|
91
|
+
- `clean_error_text(value)` strips the padding from the active error text and
|
|
92
|
+
returns `None` when there is no error.
|
|
93
|
+
- `sg_ready_mode(...)` and `device.sg_ready_mode` derive the SG Ready operating
|
|
94
|
+
state (BZ1–BZ4) from the digital inputs.
|
|
95
|
+
|
|
96
|
+
## Hardware verification
|
|
97
|
+
|
|
98
|
+
The register addresses, the signed 0.1 °C temperature format and the
|
|
99
|
+
multi-register word order come from the existing integration. Confirm them
|
|
100
|
+
against your WT16 documentation, especially for negative temperatures. The
|
|
101
|
+
test simulator checks the software against this map, not the map against a
|
|
102
|
+
real heat pump.
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
Requires Python 3.13 or newer and [uv](https://docs.astral.sh/uv/).
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv sync
|
|
110
|
+
uv run pytest
|
|
111
|
+
uv run ruff check .
|
|
112
|
+
uv run ruff format --check .
|
|
113
|
+
uv run mypy
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To run the synthetic WT16 on port 5020 for manual testing:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
uv run python -m tests.simulator
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Releasing
|
|
123
|
+
|
|
124
|
+
Releases are published to PyPI from GitHub Actions with
|
|
125
|
+
[trusted publishing](https://docs.pypi.org/trusted-publishers/).
|
|
126
|
+
|
|
127
|
+
1. Set the new `version` in `pyproject.toml` and merge it to `main`.
|
|
128
|
+
2. Create a GitHub release with a tag equal to that version (for example
|
|
129
|
+
`0.1.0`).
|
|
130
|
+
3. The `Publish` workflow builds the package and uploads it to PyPI.
|
|
131
|
+
|
|
132
|
+
A version number can be published only once.
|
|
133
|
+
|
|
134
|
+
## License
|
|
135
|
+
|
|
136
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "weider-modbus"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Async Python library for the Modbus TCP interface of Weider heat pumps, built on modbus-connection"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "schadom" }]
|
|
13
|
+
requires-python = ">=3.13"
|
|
14
|
+
keywords = ["weider", "heat pump", "wt16", "modbus", "home-assistant"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Framework :: AsyncIO",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Programming Language :: Python :: 3.14",
|
|
23
|
+
"Topic :: Home Automation",
|
|
24
|
+
"Typing :: Typed",
|
|
25
|
+
]
|
|
26
|
+
# Only the backend-neutral interface. The consumer (e.g. Home Assistant)
|
|
27
|
+
# owns the connection and picks the backend.
|
|
28
|
+
dependencies = ["modbus-connection>=4.12.1"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/schadom/weider-modbus"
|
|
32
|
+
Source = "https://github.com/schadom/weider-modbus"
|
|
33
|
+
Issues = "https://github.com/schadom/weider-modbus/issues"
|
|
34
|
+
|
|
35
|
+
[dependency-groups]
|
|
36
|
+
dev = [
|
|
37
|
+
"modbus-connection[tmodbus]>=4.12.1",
|
|
38
|
+
"mypy>=1.19",
|
|
39
|
+
"pymodbus>=3.13,<4",
|
|
40
|
+
"pytest>=8.4",
|
|
41
|
+
"pytest-asyncio>=1.0",
|
|
42
|
+
"ruff>=0.15",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src/weider_modbus"]
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.sdist]
|
|
49
|
+
include = ["src", "tests", "README.md", "LICENSE"]
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
asyncio_mode = "auto"
|
|
53
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
|
|
56
|
+
[tool.mypy]
|
|
57
|
+
python_version = "3.13"
|
|
58
|
+
files = ["src"]
|
|
59
|
+
strict = true
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
target-version = "py313"
|
|
63
|
+
src = ["src"]
|
|
64
|
+
|
|
65
|
+
[tool.ruff.lint]
|
|
66
|
+
select = ["E", "F", "W", "I", "UP", "B", "D", "SIM", "RUF"]
|
|
67
|
+
ignore = ["D203", "D213"]
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint.per-file-ignores]
|
|
70
|
+
"tests/**" = ["D"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""Async Python library for the Modbus TCP interface of Weider WT16 heat pumps."""
|
|
2
|
+
|
|
3
|
+
from .components import DigitalInputs, Measurements, Settings
|
|
4
|
+
from .const import (
|
|
5
|
+
HOT_WATER_TARGET_MAX,
|
|
6
|
+
HOT_WATER_TARGET_MIN,
|
|
7
|
+
MANUFACTURER,
|
|
8
|
+
MAX_PLAUSIBLE_TEMPERATURE,
|
|
9
|
+
MIN_PLAUSIBLE_TEMPERATURE,
|
|
10
|
+
MODEL,
|
|
11
|
+
ROOM_TARGET_MAX,
|
|
12
|
+
ROOM_TARGET_MIN,
|
|
13
|
+
TARGET_STEP,
|
|
14
|
+
)
|
|
15
|
+
from .device import WeiderWT16
|
|
16
|
+
from .helpers import SgReadyMode, clean_error_text, plausible_temperature, sg_ready_mode
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"HOT_WATER_TARGET_MAX",
|
|
20
|
+
"HOT_WATER_TARGET_MIN",
|
|
21
|
+
"MANUFACTURER",
|
|
22
|
+
"MAX_PLAUSIBLE_TEMPERATURE",
|
|
23
|
+
"MIN_PLAUSIBLE_TEMPERATURE",
|
|
24
|
+
"MODEL",
|
|
25
|
+
"ROOM_TARGET_MAX",
|
|
26
|
+
"ROOM_TARGET_MIN",
|
|
27
|
+
"TARGET_STEP",
|
|
28
|
+
"DigitalInputs",
|
|
29
|
+
"Measurements",
|
|
30
|
+
"Settings",
|
|
31
|
+
"SgReadyMode",
|
|
32
|
+
"WeiderWT16",
|
|
33
|
+
"clean_error_text",
|
|
34
|
+
"plausible_temperature",
|
|
35
|
+
"sg_ready_mode",
|
|
36
|
+
]
|