Make endpoint index optional with auto-increment #137
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/yaml-auto-index"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
YN-19.
indexis now optional on a YAML endpoint. One without it takes the previous endpoint's last index plus one, the first starts at 0, and an explicitindexrestarts the count. Every parsed endpoint carries aspan(1 for all of today's types), and the counter advances by it. A later block type can claim several indices that way. Collisions are checked as overlapping ranges, so they also catch spans, and all existing range checks apply (a count that runs past 31 fails on that endpoint'sindex).When any endpoint was numbered by the generator,
renderprints one line to stderr listing every resolved index and label, so a shift from a reorder or removal shows in the build output. Schema regenerated withindexno longer required. README makesindexoptional in the example, and says that once a node is on the bus its indices must be pinned before reordering or removing an endpoint, because Home Assistant keys entities on them.Generator, schema, README and Python tests only.
Tested: Python 94 (was 87), none skipped locally. Tests cover the counter, the reset after an explicit index, the collision, the limit, the printed line and its absence for explicit indices; freezing the counter fails them. All three fixtures build.
Two minor points, nothing blocking.
nextIndexis camelCase in a snake_case file (used_pins,board_name). Rename tonext_index.@ -57,3 +57,3 @@"minimum": 0,"maximum": 31,"description": "Unique in this node.""description": "Unique in this node. Without it, the previous endpoint's last index plus one, starting at 0."Unique per node. Autoincrements if not specified