kaco-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.
Files changed (36) hide show
  1. kaco_modbus-0.1.0/.github/workflows/ci.yml +15 -0
  2. kaco_modbus-0.1.0/.github/workflows/release.yml +89 -0
  3. kaco_modbus-0.1.0/.gitignore +8 -0
  4. kaco_modbus-0.1.0/.release-please-manifest.json +3 -0
  5. kaco_modbus-0.1.0/CHANGELOG.md +24 -0
  6. kaco_modbus-0.1.0/LICENSE +202 -0
  7. kaco_modbus-0.1.0/PKG-INFO +110 -0
  8. kaco_modbus-0.1.0/README.md +93 -0
  9. kaco_modbus-0.1.0/docs/ARCHITECTURE.md +145 -0
  10. kaco_modbus-0.1.0/docs/device-photos/IMG_4535.jpeg +0 -0
  11. kaco_modbus-0.1.0/docs/device-photos/IMG_4543.jpeg +0 -0
  12. kaco_modbus-0.1.0/pyproject.toml +52 -0
  13. kaco_modbus-0.1.0/release-please-config.json +12 -0
  14. kaco_modbus-0.1.0/src/kaco_modbus/__init__.py +21 -0
  15. kaco_modbus-0.1.0/src/kaco_modbus/common.py +17 -0
  16. kaco_modbus-0.1.0/src/kaco_modbus/discovery.py +55 -0
  17. kaco_modbus-0.1.0/src/kaco_modbus/dump.py +125 -0
  18. kaco_modbus-0.1.0/src/kaco_modbus/enums.py +37 -0
  19. kaco_modbus-0.1.0/src/kaco_modbus/exceptions.py +13 -0
  20. kaco_modbus-0.1.0/src/kaco_modbus/inverter.py +180 -0
  21. kaco_modbus-0.1.0/src/kaco_modbus/kaco.py +107 -0
  22. kaco_modbus-0.1.0/src/kaco_modbus/mppt.py +101 -0
  23. kaco_modbus-0.1.0/src/kaco_modbus/py.typed +0 -0
  24. kaco_modbus-0.1.0/src/kaco_modbus/testing.py +69 -0
  25. kaco_modbus-0.1.0/tests/__init__.py +0 -0
  26. kaco_modbus-0.1.0/tests/conftest.py +8 -0
  27. kaco_modbus-0.1.0/tests/reference/blueplanet_86tl3.json +924 -0
  28. kaco_modbus-0.1.0/tests/test_common.py +15 -0
  29. kaco_modbus-0.1.0/tests/test_discovery.py +38 -0
  30. kaco_modbus-0.1.0/tests/test_dump.py +25 -0
  31. kaco_modbus-0.1.0/tests/test_inverter.py +40 -0
  32. kaco_modbus-0.1.0/tests/test_kaco.py +33 -0
  33. kaco_modbus-0.1.0/tests/test_mppt.py +64 -0
  34. kaco_modbus-0.1.0/tests/test_reference_dump.py +49 -0
  35. kaco_modbus-0.1.0/tests/test_testing_fixture.py +14 -0
  36. kaco_modbus-0.1.0/uv.lock +370 -0
@@ -0,0 +1,15 @@
1
+ name: CI
2
+ on:
3
+ push: {branches: [main]}
4
+ pull_request:
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - uses: astral-sh/setup-uv@v5
11
+ - run: uv sync
12
+ - run: uv run ruff check
13
+ - run: uv run ruff format --check
14
+ - run: uv run mypy
15
+ - run: uv run pytest -v
@@ -0,0 +1,89 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch:
8
+ inputs:
9
+ tag:
10
+ description: "Tag to publish to PyPI (e.g. v0.1.0). Leave empty to run release-please only."
11
+ required: false
12
+ type: string
13
+
14
+ permissions: {}
15
+
16
+ concurrency:
17
+ group: release
18
+ cancel-in-progress: false
19
+
20
+ jobs:
21
+ release-please:
22
+ runs-on: ubuntu-latest
23
+ timeout-minutes: 10
24
+ permissions:
25
+ contents: write
26
+ pull-requests: write
27
+ outputs:
28
+ release_created: ${{ steps.release.outputs.release_created }}
29
+ tag_name: ${{ steps.release.outputs.tag_name }}
30
+ steps:
31
+ - uses: googleapis/release-please-action@v5
32
+ id: release
33
+ with:
34
+ release-type: python
35
+
36
+ # release-please bumps the version in pyproject.toml but does not refresh
37
+ # uv.lock (which records the project's own version). Left stale, every
38
+ # later `uv run` rewrites uv.lock and dirties the tree / blocks commits.
39
+ # Regenerate it on the release PR branch so the bump and lockfile land
40
+ # together. Idempotent: re-runs each time release-please updates the PR.
41
+ - if: ${{ steps.release.outputs.prs_created == 'true' }}
42
+ uses: actions/checkout@v6
43
+ with:
44
+ ref: release-please--branches--${{ github.ref_name }}
45
+ - if: ${{ steps.release.outputs.prs_created == 'true' }}
46
+ uses: astral-sh/setup-uv@v8.1.0
47
+ - if: ${{ steps.release.outputs.prs_created == 'true' }}
48
+ name: Sync uv.lock on the release PR
49
+ run: |
50
+ uv lock
51
+ if ! git diff --quiet -- uv.lock; then
52
+ git config user.name "github-actions[bot]"
53
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
54
+ git add uv.lock
55
+ git commit -m "chore: sync uv.lock with release version"
56
+ git push origin HEAD:release-please--branches--${{ github.ref_name }}
57
+ fi
58
+
59
+ publish:
60
+ needs: release-please
61
+ if: needs.release-please.outputs.release_created == 'true' || inputs.tag != ''
62
+ runs-on: ubuntu-latest
63
+ timeout-minutes: 15
64
+ permissions:
65
+ id-token: write
66
+ steps:
67
+ - uses: actions/checkout@v6
68
+ with:
69
+ ref: ${{ inputs.tag || needs.release-please.outputs.tag_name }}
70
+
71
+ - name: Set up Python
72
+ uses: actions/setup-python@v6
73
+ with:
74
+ python-version: "3.13"
75
+
76
+ - name: Install uv
77
+ uses: astral-sh/setup-uv@v8.1.0
78
+
79
+ - name: Install dependencies
80
+ run: uv sync
81
+
82
+ - name: Build package
83
+ run: uv build
84
+
85
+ - name: Publish to PyPI
86
+ uses: pypa/gh-action-pypi-publish@release/v1
87
+ with:
88
+ verbose: true
89
+ skip-existing: true
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ .venv/
3
+ dist/
4
+ *.egg-info/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ .pytest_cache/
8
+ .superpowers/
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.1.0"
3
+ }
@@ -0,0 +1,24 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-07-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * dump CLI for on-site register capture ([fd5d4c6](https://github.com/g4bri3lDev/kaco-modbus/commit/fd5d4c6f23f2ab43f1407f2a1945e725e32d4e16))
9
+ * KacoInverter entrypoint with setup probe ([af7f6ff](https://github.com/g4bri3lDev/kaco-modbus/commit/af7f6ff710991748327b56b5b507c7878a337d41))
10
+ * registers_from_dump loader closing the capture-replay loop ([d545982](https://github.com/g4bri3lDev/kaco-modbus/commit/d54598230c58b76db18a5cecc181de5e2197d189))
11
+ * SunSpec base discovery and model-chain walker ([7664172](https://github.com/g4bri3lDev/kaco-modbus/commit/7664172b4f60ead8c45ca2662b6e6b973ff76268))
12
+ * SunSpec common model component ([5045579](https://github.com/g4bri3lDev/kaco-modbus/commit/5045579a8849b91b2f7e30c2c894278d25863f8c))
13
+ * SunSpec inverter model component and enums ([bc9acb0](https://github.com/g4bri3lDev/kaco-modbus/commit/bc9acb0d1847daaa869d56d560792a408f001a1a))
14
+ * SunSpec model 160 per-MPPT-string monitoring ([7969465](https://github.com/g4bri3lDev/kaco-modbus/commit/7969465c24147735ce627147590dbf7d33ff98c4))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * consistent None scale-factor policy ([5d71246](https://github.com/g4bri3lDev/kaco-modbus/commit/5d71246cb3a3dd961975032858e33feaf9bb1e17))
20
+
21
+
22
+ ### Documentation
23
+
24
+ * README and architecture document ([9a4a73b](https://github.com/g4bri3lDev/kaco-modbus/commit/9a4a73ba0bbdb0964e8b35f4987c575b8fcd44e5))
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.4
2
+ Name: kaco-modbus
3
+ Version: 0.1.0
4
+ Summary: Read a KACO blueplanet inverter over SunSpec Modbus TCP.
5
+ Project-URL: Homepage, https://github.com/g4bri3lDev/kaco-modbus
6
+ Author-email: g4bri3lDev <admin@g4bri3l.de>
7
+ License: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: blueplanet,home-assistant,kaco,modbus,solar,sunspec
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Home Automation
12
+ Requires-Python: >=3.13
13
+ Requires-Dist: modbus-connection<4,>=3.4
14
+ Provides-Extra: cli
15
+ Requires-Dist: modbus-connection[tmodbus]<4,>=3.4; extra == 'cli'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # kaco-modbus
19
+
20
+ Read a KACO blueplanet inverter over SunSpec Modbus TCP. This library discovers the device's register layout at runtime using SunSpec, then provides typed access to identity and live data. Built on the [modbus-connection](https://home-assistant-libs.github.io/modbus-connection/) library, it is the core device integration behind the [kaco Home Assistant integration](https://github.com/g4bri3lDev/kaco-modbus-hass).
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ pip install kaco-modbus
26
+ ```
27
+
28
+ For the `dump` CLI tool (below), install with the `cli` extra:
29
+
30
+ ```bash
31
+ pip install "kaco-modbus[cli]"
32
+ ```
33
+
34
+ Note: The package is not yet published to PyPI; for now, install from the GitHub repository or build locally with `uv`.
35
+
36
+ ## Usage
37
+
38
+ ```python
39
+ import asyncio
40
+ from modbus_connection.tmodbus import connect_tcp
41
+ from kaco_modbus import KacoInverter
42
+
43
+ async def main():
44
+ connection = await connect_tcp("192.168.1.50", port=502)
45
+ try:
46
+ unit = connection.for_unit(1)
47
+ probe = await KacoInverter.async_probe(unit)
48
+ device = KacoInverter(unit, probe)
49
+ await device.async_update()
50
+
51
+ print(f"AC Power: {device.inverter.ac_power} W")
52
+ print(f"Energy Total: {device.inverter.energy_total} kWh")
53
+ print(f"State: {device.inverter.state}")
54
+ finally:
55
+ await connection.close()
56
+
57
+ asyncio.run(main())
58
+ ```
59
+
60
+ ## Dump CLI
61
+
62
+ The `dump` tool reads your inverter's complete SunSpec register image. This is useful for:
63
+ - Capturing on-device ground-truth data for test fixtures
64
+ - Verifying Modbus connectivity
65
+ - Debugging SunSpec layout issues
66
+
67
+ Run it directly on the inverter's LAN:
68
+
69
+ ```bash
70
+ uv run --extra cli python -m kaco_modbus.dump 192.168.1.50 --json dump.json
71
+ ```
72
+
73
+ The command prints live data (AC power, energy, state, temperatures) and optionally saves the raw register image as JSON for analysis.
74
+
75
+ **Important:** Modbus TCP must be enabled on the inverter. In the inverter's menu (local GUI or WebGUI), navigate to **MODBUS / SunSpec protocol** and enable it (default port 502). The inverter's Modbus server is single-threaded, so sharing a connection across multiple clients (via modbus-connection) is more reliable than opening separate TCP connections.
76
+
77
+ ## Supported Devices
78
+
79
+ | Device Series | Models | SunSpec IDs | Firmware |
80
+ |---|---|---|---|
81
+ | KACO blueplanet TL1 | TL1.5 – TL8.6 | 1, 101/102/103 | ≥ V2.02 |
82
+ | KACO blueplanet TL3 | TL3.0 – TL10.0 | 1, 101/102/103 | ≥ V2.02 |
83
+ | KACO Powador TL3 | TL3.0 – TL15.0 | 1, 101/102/103 | ≥ V2.02 |
84
+
85
+ Data based on KACO's "MODBUS Protocol Application Note, Tx1 and Tx3 Series" (v180730) and SunSpec specs. Other firmware versions and models may expose additional SunSpec models (e.g., 112, 113, 160); the library skips unknown models and will discover them in future versions.
86
+
87
+ ## Development
88
+
89
+ Clone and set up:
90
+
91
+ ```bash
92
+ git clone https://github.com/g4bri3lDev/kaco-modbus
93
+ cd kaco-modbus
94
+ uv sync
95
+ ```
96
+
97
+ Run tests, type checks, and lint:
98
+
99
+ ```bash
100
+ uv run pytest -v
101
+ uv run mypy
102
+ uv run ruff check
103
+ uv run ruff format --check
104
+ ```
105
+
106
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for a detailed explanation of the library's design, module responsibilities, and layering.
107
+
108
+ ## License
109
+
110
+ Apache License 2.0. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,93 @@
1
+ # kaco-modbus
2
+
3
+ Read a KACO blueplanet inverter over SunSpec Modbus TCP. This library discovers the device's register layout at runtime using SunSpec, then provides typed access to identity and live data. Built on the [modbus-connection](https://home-assistant-libs.github.io/modbus-connection/) library, it is the core device integration behind the [kaco Home Assistant integration](https://github.com/g4bri3lDev/kaco-modbus-hass).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install kaco-modbus
9
+ ```
10
+
11
+ For the `dump` CLI tool (below), install with the `cli` extra:
12
+
13
+ ```bash
14
+ pip install "kaco-modbus[cli]"
15
+ ```
16
+
17
+ Note: The package is not yet published to PyPI; for now, install from the GitHub repository or build locally with `uv`.
18
+
19
+ ## Usage
20
+
21
+ ```python
22
+ import asyncio
23
+ from modbus_connection.tmodbus import connect_tcp
24
+ from kaco_modbus import KacoInverter
25
+
26
+ async def main():
27
+ connection = await connect_tcp("192.168.1.50", port=502)
28
+ try:
29
+ unit = connection.for_unit(1)
30
+ probe = await KacoInverter.async_probe(unit)
31
+ device = KacoInverter(unit, probe)
32
+ await device.async_update()
33
+
34
+ print(f"AC Power: {device.inverter.ac_power} W")
35
+ print(f"Energy Total: {device.inverter.energy_total} kWh")
36
+ print(f"State: {device.inverter.state}")
37
+ finally:
38
+ await connection.close()
39
+
40
+ asyncio.run(main())
41
+ ```
42
+
43
+ ## Dump CLI
44
+
45
+ The `dump` tool reads your inverter's complete SunSpec register image. This is useful for:
46
+ - Capturing on-device ground-truth data for test fixtures
47
+ - Verifying Modbus connectivity
48
+ - Debugging SunSpec layout issues
49
+
50
+ Run it directly on the inverter's LAN:
51
+
52
+ ```bash
53
+ uv run --extra cli python -m kaco_modbus.dump 192.168.1.50 --json dump.json
54
+ ```
55
+
56
+ The command prints live data (AC power, energy, state, temperatures) and optionally saves the raw register image as JSON for analysis.
57
+
58
+ **Important:** Modbus TCP must be enabled on the inverter. In the inverter's menu (local GUI or WebGUI), navigate to **MODBUS / SunSpec protocol** and enable it (default port 502). The inverter's Modbus server is single-threaded, so sharing a connection across multiple clients (via modbus-connection) is more reliable than opening separate TCP connections.
59
+
60
+ ## Supported Devices
61
+
62
+ | Device Series | Models | SunSpec IDs | Firmware |
63
+ |---|---|---|---|
64
+ | KACO blueplanet TL1 | TL1.5 – TL8.6 | 1, 101/102/103 | ≥ V2.02 |
65
+ | KACO blueplanet TL3 | TL3.0 – TL10.0 | 1, 101/102/103 | ≥ V2.02 |
66
+ | KACO Powador TL3 | TL3.0 – TL15.0 | 1, 101/102/103 | ≥ V2.02 |
67
+
68
+ Data based on KACO's "MODBUS Protocol Application Note, Tx1 and Tx3 Series" (v180730) and SunSpec specs. Other firmware versions and models may expose additional SunSpec models (e.g., 112, 113, 160); the library skips unknown models and will discover them in future versions.
69
+
70
+ ## Development
71
+
72
+ Clone and set up:
73
+
74
+ ```bash
75
+ git clone https://github.com/g4bri3lDev/kaco-modbus
76
+ cd kaco-modbus
77
+ uv sync
78
+ ```
79
+
80
+ Run tests, type checks, and lint:
81
+
82
+ ```bash
83
+ uv run pytest -v
84
+ uv run mypy
85
+ uv run ruff check
86
+ uv run ruff format --check
87
+ ```
88
+
89
+ See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for a detailed explanation of the library's design, module responsibilities, and layering.
90
+
91
+ ## License
92
+
93
+ Apache License 2.0. See [LICENSE](LICENSE) for details.