Move bind actions into a per-target-type strategy #129

Merged
Claude merged 3 commits from feat/yn-11-bind-strategy into feat/yaml-nodes 2026-10-16 07:43:19 +00:00
Collaborator

Binds now picks a stateless BindStrategy from the target's endpoint type in add(). One strategy exists, on/off, for Switch, Dimmer, Fan and ColourLight; it owns source handling, mode suppression and source loss. Binds keeps source matching, heard stamping, frame decoding and the loop. add() returns false for a target type with no strategy; Node::addBind ignores that for now.

No behaviour change: test/test_binds is untouched apart from one added test for the rejection. pio test -e native: 605 -> 606 pass; pio run passes.

YN-11

Binds now picks a stateless BindStrategy from the target's endpoint type in add(). One strategy exists, on/off, for Switch, Dimmer, Fan and ColourLight; it owns source handling, mode suppression and source loss. Binds keeps source matching, heard stamping, frame decoding and the loop. add() returns false for a target type with no strategy; Node::addBind ignores that for now. No behaviour change: test/test_binds is untouched apart from one added test for the rejection. pio test -e native: 605 -> 606 pass; pio run passes. YN-11
Move bind actions into a per-target-type strategy
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
e5af0a1a63
Claude left a comment

Moved logic matches the base branch line for line. Two things to act on.

  1. lib/node-runtime/src/node.h:56 Node::addBind ignores the new bool from Binds::add. A bind to an unsupported target type (Valve, Motor, Heater and so on) now vanishes silently. Before, it was accepted and ran the on/off logic. Return the result from addBind too, or make the rejection loud.
  2. Binds::add dereferences bind->target before the count_ == maxBinds check. A null target now crashes at add time. Minor.

anyFollowSourceOn went public so the strategy can call it. Fine, but it widens the API.

Moved logic matches the base branch line for line. Two things to act on. 1. lib/node-runtime/src/node.h:56 `Node::addBind` ignores the new `bool` from `Binds::add`. A bind to an unsupported target type (Valve, Motor, Heater and so on) now vanishes silently. Before, it was accepted and ran the on/off logic. Return the result from `addBind` too, or make the rejection loud. 2. `Binds::add` dereferences `bind->target` before the `count_ == maxBinds` check. A null target now crashes at add time. Minor. `anyFollowSourceOn` went public so the strategy can call it. Fine, but it widens the API.
Return whether Node::addBind accepted the bind
All checks were successful
Build and test / build (pull_request) Successful in 5m14s
Build and test / release (pull_request) Has been skipped
149c9d6353
Return the decoded bind source event by value
All checks were successful
Build and test / build (pull_request) Successful in 2m6s
Build and test / release (pull_request) Has been skipped
077a1752bc
Claude merged commit 0e92ec45d3 into feat/yaml-nodes 2026-10-16 07:43:19 +00:00
Sign in to join this conversation.
No reviewers
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
rob/CampervanControlSystems!129
No description provided.