Make endpoint index optional with auto-increment #137

Merged
Claude merged 3 commits from feat/yaml-auto-index into feat/yaml-nodes 2026-10-17 19:46:23 +00:00
Collaborator

YN-19. index is 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 explicit index restarts the count. Every parsed endpoint carries a span (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's index).

When any endpoint was numbered by the generator, render prints 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 with index no longer required. README makes index optional 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.

YN-19. `index` is 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 explicit `index` restarts the count. Every parsed endpoint carries a `span` (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's `index`). When any endpoint was numbered by the generator, `render` prints 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 with `index` no longer required. README makes `index` optional 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.
Make endpoint index optional with auto-increment
Some checks failed
Build and test / build (pull_request) Has been cancelled
Build and test / release (pull_request) Has been cancelled
a105a004cd
Claude left a comment

Two minor points, nothing blocking.

  • scripts/yaml_node.py: nextIndex is camelCase in a snake_case file (used_pins, board_name). Rename to next_index.
  • nodes/README.md: the strapping-pin paragraph was reflowed (first line now much longer) though the change doesn't touch it. Restore the original wrapping to keep the diff focused.
Two minor points, nothing blocking. - scripts/yaml_node.py: `nextIndex` is camelCase in a snake_case file (`used_pins`, `board_name`). Rename to `next_index`. - nodes/README.md: the strapping-pin paragraph was reflowed (first line now much longer) though the change doesn't touch it. Restore the original wrapping to keep the diff focused.
Rename next_index and restore the README wrapping
All checks were successful
Build and test / build (pull_request) Successful in 5m46s
Build and test / release (pull_request) Has been skipped
2448011705
rob requested changes 2026-10-17 16:14:28 +00:00
Dismissed
@ -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."
Owner

Unique per node. Autoincrements if not specified

Unique per node. Autoincrements if not specified
rob marked this conversation as resolved
Shorten the index description in the schema
All checks were successful
Build and test / build (pull_request) Successful in 5m34s
Build and test / release (pull_request) Has been skipped
1b2e23fff8
rob approved these changes 2026-10-17 16:49:41 +00:00
Claude merged commit 7ace58de68 into feat/yaml-nodes 2026-10-17 19:46:23 +00:00
Sign in to join this conversation.
No reviewers
rob
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
CamperCan/CampervanControlSystems!137
No description provided.