Add on-delay and run time to follow binds #133
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/yn-16-follow-timing"
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?
ctrl::BindgainsonDelayMsandrunTimeMs. A follow bind turns its target on once the source has been on for the delay, and off once every follow source has been off for the run time; a source turning on again inside the run time holds the target on. A pending turn-on is dropped if the mode has since disabled the bind or its gate has closed. A stale source still applies failsafe immediately. Zero on both is today's behaviour; toggle binds ignore both.YAML follow binds take
on_delayandrun_time: whole seconds 0-6553, or the label of a same-nodedurationsetting (copied into the bind at the top ofloop). Toggle binds reject them. Schema, README, spec 9.5 and the C3 fixture are updated.Tested: native 616 -> 628 (existing bind tests untouched), Python 75 -> 78;
pio runpasses.YN-16
122416a3cbdf07a0f825Two timing gaps in follow(), one weak test. Nothing else to act on.
@ -57,0 +70,4 @@static void follow(Bind& bind, bool sourceOn, const Binds& binds, uint32_t now) {const bool anyOn = binds.anyFollowSourceOn(bind.target);const bool delays = sourceOn ? bind.onDelayMs > 0 && !bind.target->isOn() : bind.runTimeMs > 0 && !anyOn && bind.target->isOn();bind.pending = delays;Bypasses the on-delay with two sources. Source B rises (its on-delay pending, target off), then source A clears: sourceOn is false, anyOn is true, so delays is false and setOn(true) fires at once. B's delay is skipped. Fix: in the clear branch, if the target is off and another source is on, leave it to that source's pending turn-on instead of calling setOn(anyOn). Also, a second source rising while pending re-arms dueMs and stretches the delay; keep the earlier dueMs if already pending-on.
Per-bind run time: two binds on one target with different run_time. If the bind with run_time 0 clears last, setOn(false) fires immediately and the other bind's run time is ignored. Either document that the last-clearing bind's run_time wins, or reject mixed values.
@ -514,0 +656,4 @@TEST_ASSERT_FALSE(light.isOn());}void test_a_quiet_source_applies_failsafe_without_waiting_for_the_run_time() {This test passes without the new
bind.pending = falsein Binds:➿ failsafe turns the light off, then the stale pending-off fires setOn(false), which does nothing. Test the case the line exists for: source rises with an on_delay, goes quiet before it elapses, then tick past the delay and assert the light stays off.