aioebus 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 (39) hide show
  1. aioebus-0.1.0/LICENSE +202 -0
  2. aioebus-0.1.0/PKG-INFO +187 -0
  3. aioebus-0.1.0/README.md +163 -0
  4. aioebus-0.1.0/pyproject.toml +51 -0
  5. aioebus-0.1.0/setup.cfg +4 -0
  6. aioebus-0.1.0/src/aioebus/__init__.py +67 -0
  7. aioebus-0.1.0/src/aioebus/active.py +301 -0
  8. aioebus-0.1.0/src/aioebus/codecs.py +367 -0
  9. aioebus-0.1.0/src/aioebus/conditions.py +98 -0
  10. aioebus-0.1.0/src/aioebus/convert.py +106 -0
  11. aioebus-0.1.0/src/aioebus/engine.py +205 -0
  12. aioebus-0.1.0/src/aioebus/frame.py +174 -0
  13. aioebus-0.1.0/src/aioebus/messages.py +227 -0
  14. aioebus-0.1.0/src/aioebus/passive.py +77 -0
  15. aioebus-0.1.0/src/aioebus/poll.py +73 -0
  16. aioebus-0.1.0/src/aioebus/py.typed +0 -0
  17. aioebus-0.1.0/src/aioebus/scan.py +50 -0
  18. aioebus-0.1.0/src/aioebus/translations.py +56 -0
  19. aioebus-0.1.0/src/aioebus/transport.py +143 -0
  20. aioebus-0.1.0/src/aioebus.egg-info/PKG-INFO +187 -0
  21. aioebus-0.1.0/src/aioebus.egg-info/SOURCES.txt +37 -0
  22. aioebus-0.1.0/src/aioebus.egg-info/dependency_links.txt +1 -0
  23. aioebus-0.1.0/src/aioebus.egg-info/top_level.txt +1 -0
  24. aioebus-0.1.0/tests/test_active.py +33 -0
  25. aioebus-0.1.0/tests/test_active_read.py +96 -0
  26. aioebus-0.1.0/tests/test_bitfields.py +54 -0
  27. aioebus-0.1.0/tests/test_codecs.py +46 -0
  28. aioebus-0.1.0/tests/test_condition_eval.py +40 -0
  29. aioebus-0.1.0/tests/test_conditions.py +38 -0
  30. aioebus-0.1.0/tests/test_datatypes.py +59 -0
  31. aioebus-0.1.0/tests/test_engine.py +109 -0
  32. aioebus-0.1.0/tests/test_frame.py +74 -0
  33. aioebus-0.1.0/tests/test_messages.py +64 -0
  34. aioebus-0.1.0/tests/test_passive.py +40 -0
  35. aioebus-0.1.0/tests/test_poll.py +45 -0
  36. aioebus-0.1.0/tests/test_scan.py +21 -0
  37. aioebus-0.1.0/tests/test_translations.py +31 -0
  38. aioebus-0.1.0/tests/test_transport.py +59 -0
  39. aioebus-0.1.0/tests/test_write.py +115 -0
aioebus-0.1.0/LICENSE ADDED
@@ -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.
aioebus-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.4
2
+ Name: aioebus
3
+ Version: 0.1.0
4
+ Summary: Standalone async eBUS library (decode-first). No ebusd daemon required.
5
+ Author-email: dneprojects <dne.projects.1@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/dneprojects/aioebus
8
+ Project-URL: Repository, https://github.com/dneprojects/aioebus
9
+ Project-URL: Issues, https://github.com/dneprojects/aioebus/issues
10
+ Keywords: ebus,ebusd,vaillant,heating,home-assistant,asyncio
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Home Automation
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Dynamic: license-file
24
+
25
+ # aioebus
26
+
27
+ A **standalone, async, pure-Python eBUS library** — the goal is to talk to an
28
+ eBUS adapter (enhanced protocol) and decode Vaillant/eBUS messages **without a
29
+ separate ebusd daemon**, so a Home Assistant integration can embed it directly
30
+ (lib in PyPI, thin integration in HA Core).
31
+
32
+ This is an incremental port of [ebusd](https://github.com/john30/ebusd)'s
33
+ behaviour to Python — **not** a line-by-line transpile. Each layer is ported by
34
+ spec and checked against real captured telegrams (a conformance harness), so the
35
+ long tail of real-world quirks is caught automatically.
36
+
37
+ ## Status
38
+
39
+ | Phase | Scope | State |
40
+ |---|---|---|
41
+ | 0 | Scaffold + conformance harness (real captures as golden data) | ✅ |
42
+ | 1 | **Datatype codecs** (`datatype.cpp` port) + CSV type specs | ✅ |
43
+ | 2 | **Message model + CSV ingest + decode** (default rows, IGN, value tables) | ✅ |
44
+ | 2.5 | **Full datatypes** (date/time/float/bit), **conditions** as metadata | ✅ |
45
+ | 3 | **eBUS frame/CRC + passive decode** (wire bytes → named values) | ✅ |
46
+ | 3b | **Enhanced-adapter transport** (protocol ✅; live socket needs a window) | ◐ |
47
+ | 4 | Active read: build + scheduler + **send FSM ✅ (offline)**; live send, scan, write | ◐ |
48
+ | 5 | Thin HA integration swaps its ebusd-HTTP client for this lib | ⏳ |
49
+
50
+ The enhanced adapter does bus arbitration in hardware, so the timing-critical
51
+ part is offloaded — Phase 3 ports a documented host↔adapter byte protocol, not
52
+ microsecond timing.
53
+
54
+ ## Phase 1 — what works now
55
+
56
+ Pure, offline decoding of eBUS field types, validated against telegrams captured
57
+ from a real Vaillant cascade (2× aroTHERM, sensoCOMFORT, eloBlock, VR 71):
58
+
59
+ ```python
60
+ from aioebus import decode
61
+
62
+ decode("D2C", "bd01") # 27.8125 (flow temp)
63
+ decode("UCH", "0f") # 15
64
+ decode("STR:5", "4e45545833") # "NETX3"
65
+ decode("HEX:6", "090264186418") # "09 02 64 18 64 18"
66
+ decode("SIN", "f401", divisor=10) # 50.0 (CSV divisor column)
67
+ decode("UCH", "ff") # None (invalid/replacement sentinel)
68
+ ```
69
+
70
+ Supported types: the integers (UCH SCH UIN SIN ULG U2L U4L, reversed UIR SIR),
71
+ fixed-point D1B D1C D2B D2C FLT, floats EXP/EXR, BCD[:n] PIN, HEX:n, STR:n/STR:*,
72
+ IGN:n, bit fields BI0..BI7[:n], and the date/time family (TTM TTH TTQ, HTM BTM
73
+ VTM, HTI BTI VTI, HDA BDA[:3], BDY HDY, DTM DAY) -- with the CSV divisor column
74
+ and ebusd's replacement (invalid) handling. This resolves every field type used
75
+ across the 104 stock Vaillant configs.
76
+
77
+ ## Phase 2 — structured messages + CSV ingest
78
+
79
+ The in-memory model is structured dataclasses (`MessageDef` / `FieldDef`), never
80
+ CSV-shaped. The community ebusd-CSV library is read *into* the model with Python's
81
+ `csv` module (so quoted commas no longer abort a file). Our own curated
82
+ definitions can instead live in the native JSON format (`convert.py`) — both
83
+ become the same objects.
84
+
85
+ ```python
86
+ from aioebus.messages import parse_csv
87
+
88
+ msgs = {m.name: m for m in parse_csv(open("38.v32.csv").read())}
89
+ msgs["Statenumber"].decode_labeled(slave="1f") # {'Statenumber': 'sommer'}
90
+ msgs["PositionValveSet"].decode_labeled(slave="64") # {'PositionValveSet': 'dhw'}
91
+ ```
92
+
93
+ `tools/demo_live.py <csv> <telegrams.db>` parses a real config and decodes the
94
+ newest live telegram for every message — pure Python, no ebusd decoding.
95
+ `python -m aioebus.convert <csv> [out.json]` converts curated CSVs to the native
96
+ structured format.
97
+
98
+ ## Phase 3 — frame layer + passive decode
99
+
100
+ The wire format is parsed end to end: escaping (`A9 01`→`AA`, `A9 00`→`A9`), the
101
+ eBUS CRC-8 (polynomial `0x9B`, computed over the *escaped* stream), and the full
102
+ frame structure incl. NAK-retransmission. Combined with the message model this
103
+ turns raw bytes seen on the bus into named values, read-only:
104
+
105
+ ```python
106
+ from aioebus import parse_csv, MessageRegistry, decode_raw
107
+
108
+ reg = MessageRegistry(parse_csv(open("38.v32.csv").read()))
109
+ decode_raw(reg, "3138b509030d1800740003910100bb00") # (FlowTemp def, {'FlowTemp': 25.0625})
110
+ ```
111
+
112
+ Validated bit-exact against **285 358** complete telegrams captured from the live
113
+ bus: every one parses, matches ebusd's own decoded columns and verifies CRC
114
+ (`tools/validate_frame_db.py`).
115
+
116
+ ## Phase 3b — enhanced-adapter transport
117
+
118
+ `transport.py` decodes the adapter's framed byte stream (`11ccccdd 10dddddd`
119
+ symbols, short form for bytes < 0x80), assembles telegrams on SYN and decodes
120
+ them — all read-only, nothing is ever written to the bus:
121
+
122
+ ```python
123
+ from aioebus import parse_csv, MessageRegistry, listen
124
+
125
+ reg = MessageRegistry(parse_csv(open("38.v32.csv").read()))
126
+ async for msgdef, values in listen("192.168.178.179", 9999, reg):
127
+ print(values)
128
+ ```
129
+
130
+ The protocol logic is validated offline by round-tripping real telegrams through
131
+ a synthetic adapter stream, including arbitrary read fragmentation
132
+ (`tests/test_transport.py`). Live listening is gated on hardware: the enhanced
133
+ adapter is single-client, so ebusd must be stopped first (a maintenance window).
134
+ It has been run live against the reference adapter — passive decode works
135
+ end-to-end without ebusd.
136
+
137
+ ## Phase 4 — active reads under limited bandwidth
138
+
139
+ `active.build_read()` constructs the on-wire master request; its CRC matches
140
+ ebusd for every real read in the log. `poll.PollScheduler` decides *what* to read
141
+ and *when*, because eBUS is ~2400 baud and only a handful of reads fit per second:
142
+
143
+ - only `r1`..`r9` are polled; the priority digit scales the interval (`r1` most
144
+ frequent), plain `r` is on-demand, `w`/`u` never;
145
+ - **passive-first** — a value seen on the bus refreshes that register's timer, so
146
+ broadcasts are never re-polled (on the live bus this is most of the traffic);
147
+ - one request at a time — the scheduler hands back only the most-overdue message.
148
+
149
+ The bus *send* FSM (`active.ReadDriver`/`ActiveReader`) is ported from ebusd's
150
+ `protocol_direct.cpp`: arbitrate (START with QQ) → send `ZZ PB SB NN DD` + CRC,
151
+ each byte echoed back and **verified for collision** → master ACK → read the
152
+ slave frame and check its CRC → ACK → SYN. The pure `ReadDriver` is driven in
153
+ tests by a simulated adapter through a full round-trip (arbitration-won, echoes,
154
+ answer, decode) plus the arbitration-lost and collision paths — all offline.
155
+
156
+ The live send (`tools/active_read.py`, reads only) uses master address **0x31**,
157
+ the address ebusd itself uses on the reference bus: known-good, and free exactly
158
+ while ebusd is stopped (which the single-client adapter requires anyway). It has
159
+ not been run on hardware yet — that is the next maintenance window.
160
+
161
+ ## Native config format + converter
162
+
163
+ `configs/vaillant/*.json` are native-format device definitions (eloBlock, netx3)
164
+ — **our own, independently-created** definitions, Apache-2.0. `aioebus.convert`
165
+ turns any ebusd CSV into this format:
166
+
167
+ ```bash
168
+ python -m aioebus.convert path/to/15.ctlv3.csv ctlv3.json
169
+ ```
170
+
171
+ The ebusd-configuration CSVs are GPL-3.0, so a file converted from them is a
172
+ GPL-3.0 derivative: convert those **locally, against your own copy** — this
173
+ Apache-2.0 library ships only our own definitions, never a derivative of that
174
+ GPL data. `tools/convert_configs.py` regenerates our own set and the HA
175
+ translations base.
176
+
177
+ Names are **not** baked in: `aioebus.translations.ha_strings()` derives a stable
178
+ `translation_key` per field and emits `configs/vaillant/translations/strings.json`
179
+ (the English base); a `de.json` is a translated copy with the same keys.
180
+
181
+ ## Dev
182
+
183
+ ```bash
184
+ python -m pytest # conformance tests (real captures)
185
+ python tools/validate_frame_db.py /path/to/telegrams.db # frames vs ebusd (100%)
186
+ python tools/validate_against_db.py /path/to/telegrams.db # optional field decode
187
+ ```
@@ -0,0 +1,163 @@
1
+ # aioebus
2
+
3
+ A **standalone, async, pure-Python eBUS library** — the goal is to talk to an
4
+ eBUS adapter (enhanced protocol) and decode Vaillant/eBUS messages **without a
5
+ separate ebusd daemon**, so a Home Assistant integration can embed it directly
6
+ (lib in PyPI, thin integration in HA Core).
7
+
8
+ This is an incremental port of [ebusd](https://github.com/john30/ebusd)'s
9
+ behaviour to Python — **not** a line-by-line transpile. Each layer is ported by
10
+ spec and checked against real captured telegrams (a conformance harness), so the
11
+ long tail of real-world quirks is caught automatically.
12
+
13
+ ## Status
14
+
15
+ | Phase | Scope | State |
16
+ |---|---|---|
17
+ | 0 | Scaffold + conformance harness (real captures as golden data) | ✅ |
18
+ | 1 | **Datatype codecs** (`datatype.cpp` port) + CSV type specs | ✅ |
19
+ | 2 | **Message model + CSV ingest + decode** (default rows, IGN, value tables) | ✅ |
20
+ | 2.5 | **Full datatypes** (date/time/float/bit), **conditions** as metadata | ✅ |
21
+ | 3 | **eBUS frame/CRC + passive decode** (wire bytes → named values) | ✅ |
22
+ | 3b | **Enhanced-adapter transport** (protocol ✅; live socket needs a window) | ◐ |
23
+ | 4 | Active read: build + scheduler + **send FSM ✅ (offline)**; live send, scan, write | ◐ |
24
+ | 5 | Thin HA integration swaps its ebusd-HTTP client for this lib | ⏳ |
25
+
26
+ The enhanced adapter does bus arbitration in hardware, so the timing-critical
27
+ part is offloaded — Phase 3 ports a documented host↔adapter byte protocol, not
28
+ microsecond timing.
29
+
30
+ ## Phase 1 — what works now
31
+
32
+ Pure, offline decoding of eBUS field types, validated against telegrams captured
33
+ from a real Vaillant cascade (2× aroTHERM, sensoCOMFORT, eloBlock, VR 71):
34
+
35
+ ```python
36
+ from aioebus import decode
37
+
38
+ decode("D2C", "bd01") # 27.8125 (flow temp)
39
+ decode("UCH", "0f") # 15
40
+ decode("STR:5", "4e45545833") # "NETX3"
41
+ decode("HEX:6", "090264186418") # "09 02 64 18 64 18"
42
+ decode("SIN", "f401", divisor=10) # 50.0 (CSV divisor column)
43
+ decode("UCH", "ff") # None (invalid/replacement sentinel)
44
+ ```
45
+
46
+ Supported types: the integers (UCH SCH UIN SIN ULG U2L U4L, reversed UIR SIR),
47
+ fixed-point D1B D1C D2B D2C FLT, floats EXP/EXR, BCD[:n] PIN, HEX:n, STR:n/STR:*,
48
+ IGN:n, bit fields BI0..BI7[:n], and the date/time family (TTM TTH TTQ, HTM BTM
49
+ VTM, HTI BTI VTI, HDA BDA[:3], BDY HDY, DTM DAY) -- with the CSV divisor column
50
+ and ebusd's replacement (invalid) handling. This resolves every field type used
51
+ across the 104 stock Vaillant configs.
52
+
53
+ ## Phase 2 — structured messages + CSV ingest
54
+
55
+ The in-memory model is structured dataclasses (`MessageDef` / `FieldDef`), never
56
+ CSV-shaped. The community ebusd-CSV library is read *into* the model with Python's
57
+ `csv` module (so quoted commas no longer abort a file). Our own curated
58
+ definitions can instead live in the native JSON format (`convert.py`) — both
59
+ become the same objects.
60
+
61
+ ```python
62
+ from aioebus.messages import parse_csv
63
+
64
+ msgs = {m.name: m for m in parse_csv(open("38.v32.csv").read())}
65
+ msgs["Statenumber"].decode_labeled(slave="1f") # {'Statenumber': 'sommer'}
66
+ msgs["PositionValveSet"].decode_labeled(slave="64") # {'PositionValveSet': 'dhw'}
67
+ ```
68
+
69
+ `tools/demo_live.py <csv> <telegrams.db>` parses a real config and decodes the
70
+ newest live telegram for every message — pure Python, no ebusd decoding.
71
+ `python -m aioebus.convert <csv> [out.json]` converts curated CSVs to the native
72
+ structured format.
73
+
74
+ ## Phase 3 — frame layer + passive decode
75
+
76
+ The wire format is parsed end to end: escaping (`A9 01`→`AA`, `A9 00`→`A9`), the
77
+ eBUS CRC-8 (polynomial `0x9B`, computed over the *escaped* stream), and the full
78
+ frame structure incl. NAK-retransmission. Combined with the message model this
79
+ turns raw bytes seen on the bus into named values, read-only:
80
+
81
+ ```python
82
+ from aioebus import parse_csv, MessageRegistry, decode_raw
83
+
84
+ reg = MessageRegistry(parse_csv(open("38.v32.csv").read()))
85
+ decode_raw(reg, "3138b509030d1800740003910100bb00") # (FlowTemp def, {'FlowTemp': 25.0625})
86
+ ```
87
+
88
+ Validated bit-exact against **285 358** complete telegrams captured from the live
89
+ bus: every one parses, matches ebusd's own decoded columns and verifies CRC
90
+ (`tools/validate_frame_db.py`).
91
+
92
+ ## Phase 3b — enhanced-adapter transport
93
+
94
+ `transport.py` decodes the adapter's framed byte stream (`11ccccdd 10dddddd`
95
+ symbols, short form for bytes < 0x80), assembles telegrams on SYN and decodes
96
+ them — all read-only, nothing is ever written to the bus:
97
+
98
+ ```python
99
+ from aioebus import parse_csv, MessageRegistry, listen
100
+
101
+ reg = MessageRegistry(parse_csv(open("38.v32.csv").read()))
102
+ async for msgdef, values in listen("192.168.178.179", 9999, reg):
103
+ print(values)
104
+ ```
105
+
106
+ The protocol logic is validated offline by round-tripping real telegrams through
107
+ a synthetic adapter stream, including arbitrary read fragmentation
108
+ (`tests/test_transport.py`). Live listening is gated on hardware: the enhanced
109
+ adapter is single-client, so ebusd must be stopped first (a maintenance window).
110
+ It has been run live against the reference adapter — passive decode works
111
+ end-to-end without ebusd.
112
+
113
+ ## Phase 4 — active reads under limited bandwidth
114
+
115
+ `active.build_read()` constructs the on-wire master request; its CRC matches
116
+ ebusd for every real read in the log. `poll.PollScheduler` decides *what* to read
117
+ and *when*, because eBUS is ~2400 baud and only a handful of reads fit per second:
118
+
119
+ - only `r1`..`r9` are polled; the priority digit scales the interval (`r1` most
120
+ frequent), plain `r` is on-demand, `w`/`u` never;
121
+ - **passive-first** — a value seen on the bus refreshes that register's timer, so
122
+ broadcasts are never re-polled (on the live bus this is most of the traffic);
123
+ - one request at a time — the scheduler hands back only the most-overdue message.
124
+
125
+ The bus *send* FSM (`active.ReadDriver`/`ActiveReader`) is ported from ebusd's
126
+ `protocol_direct.cpp`: arbitrate (START with QQ) → send `ZZ PB SB NN DD` + CRC,
127
+ each byte echoed back and **verified for collision** → master ACK → read the
128
+ slave frame and check its CRC → ACK → SYN. The pure `ReadDriver` is driven in
129
+ tests by a simulated adapter through a full round-trip (arbitration-won, echoes,
130
+ answer, decode) plus the arbitration-lost and collision paths — all offline.
131
+
132
+ The live send (`tools/active_read.py`, reads only) uses master address **0x31**,
133
+ the address ebusd itself uses on the reference bus: known-good, and free exactly
134
+ while ebusd is stopped (which the single-client adapter requires anyway). It has
135
+ not been run on hardware yet — that is the next maintenance window.
136
+
137
+ ## Native config format + converter
138
+
139
+ `configs/vaillant/*.json` are native-format device definitions (eloBlock, netx3)
140
+ — **our own, independently-created** definitions, Apache-2.0. `aioebus.convert`
141
+ turns any ebusd CSV into this format:
142
+
143
+ ```bash
144
+ python -m aioebus.convert path/to/15.ctlv3.csv ctlv3.json
145
+ ```
146
+
147
+ The ebusd-configuration CSVs are GPL-3.0, so a file converted from them is a
148
+ GPL-3.0 derivative: convert those **locally, against your own copy** — this
149
+ Apache-2.0 library ships only our own definitions, never a derivative of that
150
+ GPL data. `tools/convert_configs.py` regenerates our own set and the HA
151
+ translations base.
152
+
153
+ Names are **not** baked in: `aioebus.translations.ha_strings()` derives a stable
154
+ `translation_key` per field and emits `configs/vaillant/translations/strings.json`
155
+ (the English base); a `de.json` is a translated copy with the same keys.
156
+
157
+ ## Dev
158
+
159
+ ```bash
160
+ python -m pytest # conformance tests (real captures)
161
+ python tools/validate_frame_db.py /path/to/telegrams.db # frames vs ebusd (100%)
162
+ python tools/validate_against_db.py /path/to/telegrams.db # optional field decode
163
+ ```
@@ -0,0 +1,51 @@
1
+ [project]
2
+ name = "aioebus"
3
+ version = "0.1.0"
4
+ description = "Standalone async eBUS library (decode-first). No ebusd daemon required."
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "Apache-2.0"
8
+ authors = [{ name = "dneprojects", email = "dne.projects.1@gmail.com" }]
9
+ keywords = ["ebus", "ebusd", "vaillant", "heating", "home-assistant", "asyncio"]
10
+ dependencies = []
11
+ classifiers = [
12
+ "Development Status :: 3 - Alpha",
13
+ "Intended Audience :: Developers",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Topic :: Home Automation",
20
+ "Typing :: Typed",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/dneprojects/aioebus"
25
+ Repository = "https://github.com/dneprojects/aioebus"
26
+ Issues = "https://github.com/dneprojects/aioebus/issues"
27
+
28
+ [build-system]
29
+ requires = ["setuptools>=68"]
30
+ build-backend = "setuptools.build_meta"
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+
35
+ [tool.setuptools.package-data]
36
+ aioebus = ["py.typed"]
37
+
38
+ [tool.pytest.ini_options]
39
+ pythonpath = ["src"]
40
+ testpaths = ["tests"]
41
+
42
+ [tool.ruff]
43
+ target-version = "py311"
44
+ line-length = 110
45
+
46
+ [tool.ruff.lint]
47
+ select = ["E", "F", "W", "I", "UP", "B", "SIM", "C4", "RUF"]
48
+
49
+ [tool.ruff.lint.per-file-ignores]
50
+ "tests/*" = ["E501", "SIM102", "RUF059", "RUF015", "C401"]
51
+ "tools/*" = ["E501", "RUF015", "SIM105", "B007"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,67 @@
1
+ """aioebus -- standalone async eBUS library (work in progress).
2
+
3
+ Pure, offline eBUS decoding validated against real captured telegrams:
4
+ - codecs: datatype decoding (ebusd datatype.cpp port)
5
+ - messages: structured definitions + ebusd-CSV ingest + decode
6
+ - frame: on-the-wire telegram parsing, escaping, eBUS CRC-8
7
+ - passive: raw wire bytes -> matched message -> named values (read-only)
8
+ - transport/active/engine: enhanced-adapter I/O, active read/write, and a
9
+ passive-first engine that caches decoded values and interleaves reads.
10
+ """
11
+ from .active import (
12
+ ActiveReader,
13
+ ActiveWriter,
14
+ ReadDriver,
15
+ ReadError,
16
+ WriteDriver,
17
+ build_read,
18
+ build_read_frame,
19
+ build_write_frame,
20
+ )
21
+ from .codecs import Codec, decode, encode, make_codec
22
+ from .conditions import ConditionContext, context_from_scan, evaluate, evaluate_all
23
+ from .engine import EbusEngine, value_key
24
+ from .frame import Telegram, crc8, escape, parse_telegram, unescape
25
+ from .messages import FieldDef, MessageDef, parse_csv
26
+ from .passive import MessageRegistry, decode_raw
27
+ from .poll import PollScheduler
28
+ from .scan import ScanResult, decode_scan
29
+ from .transport import EnhDecoder, PassiveListener, listen
30
+
31
+ __all__ = [
32
+ "ActiveReader",
33
+ "ActiveWriter",
34
+ "Codec",
35
+ "ConditionContext",
36
+ "EbusEngine",
37
+ "EnhDecoder",
38
+ "FieldDef",
39
+ "MessageDef",
40
+ "MessageRegistry",
41
+ "PassiveListener",
42
+ "PollScheduler",
43
+ "ReadDriver",
44
+ "ReadError",
45
+ "ScanResult",
46
+ "Telegram",
47
+ "WriteDriver",
48
+ "build_read",
49
+ "build_read_frame",
50
+ "build_write_frame",
51
+ "context_from_scan",
52
+ "crc8",
53
+ "decode",
54
+ "decode_raw",
55
+ "decode_scan",
56
+ "encode",
57
+ "escape",
58
+ "evaluate",
59
+ "evaluate_all",
60
+ "listen",
61
+ "make_codec",
62
+ "parse_csv",
63
+ "parse_telegram",
64
+ "unescape",
65
+ "value_key",
66
+ ]
67
+ __version__ = "0.1.0"