Let modes reach relay lights and fans through output types #124
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/yaml-drives"
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-7. Every relay is
EndpointType::Switch, somodeSwitchesOffnever turned a relay lamp off in LightsOut or Travel. It now decides by semantic class (LightorFan), andEndpoint::onModepasses the endpoint's own class. TheEndpointTypeoverload is gone;extractor_policy.hand 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,fanandload(relays,SwitchEndpoint) anddimmable_lightanddimmable_fan(PWM,LevelEndpointwithEndpointType::DimmerandFan).lightandfancallsetPresentationwith the Light or Fan class;loadkeeps the default and the PWM types need nothing.relay,dimmeranddrivesare 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
setPresentationcalls insrc/are the water heater (Load, already the Switch default) andSettingEndpoint(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, andextractor_policy.hpassesFan. 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
lightskip its class fails the output-type test.pio runand the three fixtures build.Two small points. Neither blocks the merge.
lib/node-runtime/src/endpoint.h:93: the
EndpointTypeoverload ofmodeSwitchesOffhas one non-test caller, src/node_bathroom/extractor_policy.h:29. Call that site withcan::SemanticClass::Fanand 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.src/node_water_heater/main.cpp:28 sets
Loadon aSwitch, which is already the default. It is redundant, not wrong. It is outside this PR's scope.The
EndpointTypeoverload ofmodeSwitchesOffis gone.extractor_policy.hand 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.Make
drivestypeinsteadLet modes reach relay lights and fans via what an output drivesto Let modes reach relay lights and fans through output typesNo blockers. Three small things.
@ -7,3 +7,3 @@- index: 0type: relaytype: fanlabel: RelayLabel is still
Relayon what is now afan. Rename to something likeFan.@ -56,3 +56,2 @@endpointSummaries = {"relay": "On/off output.","dimmer": "PWM output.","light": "On/off light.",kind in outputs and outputs[kind]["pwm"]is repeated in four places (parse_endpoint, parse_node, declare_endpoint, render). AddpwmTypes = {kind for kind, output in outputs.items() if output["pwm"]}once and usekind in pwmTypes. It also drops the.get/in outputsguards.@ -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));}test_lights_out_takes_the_lighting now asserts the identical Light line twice (Dimmer and ColourLight collapsed). Drop one.
Can we make
dimmable_fanvariable_fan?