Let modes reach relay lights and fans through output types #124

Merged
Claude merged 4 commits from feat/yaml-drives into feat/yaml-nodes 2026-10-15 18:57:25 +00:00
Collaborator

YN-7. Every relay is EndpointType::Switch, so modeSwitchesOff never turned a relay lamp off in LightsOut or Travel. It now decides by semantic class (Light or Fan), and Endpoint::onMode passes the endpoint's own class. The EndpointType overload is gone; extractor_policy.h and the existing mode tests pass semantic classes. Spec section 7 gains one sentence saying lighting and fans are the endpoints with that class.

YAML: the output types are now light, fan and load (relays, SwitchEndpoint) and dimmable_light and dimmable_fan (PWM, LevelEndpoint with EndpointType::Dimmer and Fan). light and fan call setPresentation with the Light or Fan class; load keeps the default and the PWM types need nothing. relay, dimmer and drives are gone with no aliases, as nothing has shipped. Schema regenerated and README updated. The three fixtures between them use all five types, so CI compiles each.

Existing nodes: no behaviour change. The only setPresentation calls in src/ are the water heater (Load, already the Switch default) and SettingEndpoint (classes that are neither Light nor Fan). By type, Dimmer and ColourLight default to Light and Fan to Fan, which is what the old rule matched, and extractor_policy.h passes Fan. Checked: lighting, bathroom, kitchen, water heater, heater and host_sim.

Tested: native 598 (was 597); breaking the light rule fails the mode tests and the lamp test. Python 30, none skipped locally; making light skip its class fails the output-type test. pio run and the three fixtures build.

YN-7. Every relay is `EndpointType::Switch`, so `modeSwitchesOff` never turned a relay lamp off in LightsOut or Travel. It now decides by semantic class (`Light` or `Fan`), and `Endpoint::onMode` passes the endpoint's own class. The `EndpointType` overload is gone; `extractor_policy.h` and the existing mode tests pass semantic classes. Spec section 7 gains one sentence saying lighting and fans are the endpoints with that class. YAML: the output types are now `light`, `fan` and `load` (relays, `SwitchEndpoint`) and `dimmable_light` and `dimmable_fan` (PWM, `LevelEndpoint` with `EndpointType::Dimmer` and `Fan`). `light` and `fan` call `setPresentation` with the Light or Fan class; `load` keeps the default and the PWM types need nothing. `relay`, `dimmer` and `drives` are gone with no aliases, as nothing has shipped. Schema regenerated and README updated. The three fixtures between them use all five types, so CI compiles each. Existing nodes: no behaviour change. The only `setPresentation` calls in `src/` are the water heater (`Load`, already the Switch default) and `SettingEndpoint` (classes that are neither Light nor Fan). By type, Dimmer and ColourLight default to Light and Fan to Fan, which is what the old rule matched, and `extractor_policy.h` passes `Fan`. Checked: lighting, bathroom, kitchen, water heater, heater and host_sim. Tested: native 598 (was 597); breaking the light rule fails the mode tests and the lamp test. Python 30, none skipped locally; making `light` skip its class fails the output-type test. `pio run` and the three fixtures build.
Let modes reach relay lights and fans via what an output drives
All checks were successful
Build and test / build (pull_request) Successful in 5m9s
Build and test / release (pull_request) Has been skipped
24edf4b1ea
Claude left a comment

Two small points. Neither blocks the merge.

  1. lib/node-runtime/src/endpoint.h:93: the EndpointType overload of modeSwitchesOff has one non-test caller, src/node_bathroom/extractor_policy.h:29. Call that site with can::SemanticClass::Fan and drop the overload. The existing tests in test_mode_switches_off.cpp would need the same change. If you want them left as the quality gate, keep the overload and ignore this.

  2. src/node_water_heater/main.cpp:28 sets Load on a Switch, which is already the default. It is redundant, not wrong. It is outside this PR's scope.

Two small points. Neither blocks the merge. 1. lib/node-runtime/src/endpoint.h:93: the `EndpointType` overload of `modeSwitchesOff` has one non-test caller, src/node_bathroom/extractor_policy.h:29. Call that site with `can::SemanticClass::Fan` and drop the overload. The existing tests in test_mode_switches_off.cpp would need the same change. If you want them left as the quality gate, keep the overload and ignore this. 2. src/node_water_heater/main.cpp:28 sets `Load` on a `Switch`, which is already the default. It is redundant, not wrong. It is outside this PR's scope.
Author
Collaborator

The EndpointType overload of modeSwitchesOff is gone. extractor_policy.h and the existing mode tests now pass semantic classes (same expectations, Switch becomes Load). The three tests I added for the semantic overload duplicated those, so I dropped them. Native count is 598 (was 597 before this PR); the PR body's "old type overload maps through defaultMetadata" line no longer applies.

The `EndpointType` overload of `modeSwitchesOff` is gone. `extractor_policy.h` and the existing mode tests now pass semantic classes (same expectations, Switch becomes Load). The three tests I added for the semantic overload duplicated those, so I dropped them. Native count is 598 (was 597 before this PR); the PR body's "old type overload maps through defaultMetadata" line no longer applies.
Drop the EndpointType overload of modeSwitchesOff
All checks were successful
Build and test / build (pull_request) Successful in 2m4s
Build and test / release (pull_request) Has been skipped
ffdb3208c2
rob left a comment

Make drives type instead

Make `drives` `type` instead
Replace relay, dimmer and drives with light, fan and load output types
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
773936a9d9
Claude changed title from Let modes reach relay lights and fans via what an output drives to Let modes reach relay lights and fans through output types 2026-10-15 18:51:12 +00:00
Claude left a comment

No blockers. Three small things.

No blockers. Three small things.
@ -7,3 +7,3 @@
- index: 0
type: relay
type: fan
label: Relay
Author
Collaborator

Label is still Relay on what is now a fan. Rename to something like Fan.

Label is still `Relay` on what is now a `fan`. Rename to something like `Fan`.
@ -56,3 +56,2 @@
endpointSummaries = {
"relay": "On/off output.",
"dimmer": "PWM output.",
"light": "On/off light.",
Author
Collaborator

kind in outputs and outputs[kind]["pwm"] is repeated in four places (parse_endpoint, parse_node, declare_endpoint, render). Add pwmTypes = {kind for kind, output in outputs.items() if output["pwm"]} once and use kind in pwmTypes. It also drops the .get/in outputs guards.

`kind in outputs and outputs[kind]["pwm"]` is repeated in four places (parse_endpoint, parse_node, declare_endpoint, render). Add `pwmTypes = {kind for kind, output in outputs.items() if output["pwm"]}` once and use `kind in pwmTypes`. It also drops the `.get`/`in outputs` guards.
@ -18,2 +17,3 @@
TEST_ASSERT_TRUE(modeSwitchesOff(can::Mode::LightsOut, can::EndpointType::ColourLight));
TEST_ASSERT_TRUE(modeSwitchesOff(can::Mode::LightsOut, can::SemanticClass::Light));
TEST_ASSERT_TRUE(modeSwitchesOff(can::Mode::LightsOut, can::SemanticClass::Light));
}
Author
Collaborator

test_lights_out_takes_the_lighting now asserts the identical Light line twice (Dimmer and ColourLight collapsed). Drop one.

test_lights_out_takes_the_lighting now asserts the identical Light line twice (Dimmer and ColourLight collapsed). Drop one.
Tidy the output type tables and fixture label
All checks were successful
Build and test / build (pull_request) Successful in 1m59s
Build and test / release (pull_request) Has been skipped
cc0ecb6704
rob requested changes 2026-10-15 18:57:16 +00:00
rob left a comment

Can we make dimmable_fan variable_fan?

Can we make `dimmable_fan` `variable_fan`?
Claude merged commit 25313b40de into feat/yaml-nodes 2026-10-15 18:57:25 +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
rob/CampervanControlSystems!124
No description provided.