Skip to content

Release the sensor hold as soon as a valid value arrives - #84

Merged
michaelarnauts merged 1 commit into
masterfrom
sensor-hold-release-on-valid-value
Aug 3, 2026
Merged

Release the sensor hold as soon as a valid value arrives#84
michaelarnauts merged 1 commit into
masterfrom
sensor-hold-release-on-valid-value

Conversation

@michaelarnauts

Copy link
Copy Markdown
Owner

The bridge sends invalid (zero) sensor values right after we subscribe to a sensor, so we hold every value back for sensor_delay seconds. That also delays the correct values that arrive quickly — all sensors stay silent for the full delay even when the bridge has already reported real data.

Now we only hold zero values. The first non-zero value for a held sensor is treated as a real one: the hold timer is cancelled and the value is emitted immediately. Any later value for that sensor — including zero — passes straight through.

A sensor that only ever reports zero still behaves as before: the cached value is emitted when the hold expires. The timer is cancelled rather than left to fire, so _unhold_sensor doesn't re-emit the value a second time.

Tests

  • test_sensor_hold now uses a zero value (it previously asserted that 100 was held, which is exactly the case that changed).
  • test_sensor_hold_when_registered_after_connect reworded for the now-immediate emit.
  • New test_sensor_hold_released_on_valid_value covers the early release, pass-through of later zeros, and the absence of a duplicate emit on expiry.

Full suite: 89 passed.

🤖 Generated with Claude Code

The bridge sends invalid (zero) sensor values right after we subscribe,
so we hold every value for `sensor_delay` seconds. That also delayed the
correct values that arrive quickly.

Keep holding zero values, but treat the first non-zero value as a real
one: cancel the hold and emit it immediately. Subsequent values for that
sensor (including zero) pass straight through.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@michaelarnauts
michaelarnauts merged commit 5ec197c into master Aug 3, 2026
6 checks passed
@michaelarnauts
michaelarnauts deleted the sensor-hold-release-on-valid-value branch August 3, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant