Skip to content

Add internal metrics sensor for relay on time - #137

Open
sjefferson99 wants to merge 1 commit into
masterfrom
136-add-relay-on-time-to-sensors-for-smib-howfresh-reporting
Open

Add internal metrics sensor for relay on time#137
sjefferson99 wants to merge 1 commit into
masterfrom
136-add-relay-on-time-to-sensors-for-smib-howfresh-reporting

Conversation

@sjefferson99

Copy link
Copy Markdown
Member

Summary

  • Add InternalMetrics sensor module (src/lib/sensors/internal_metrics.py) that reports SMIBHID-internal metrics rather than readings from an attached I2C sensor. Its get_reading() returns relay_on_time, sourced from relay_history.get_total_active_seconds.
  • Wire InternalMetrics into Sensors.__init__ directly (not via the I2C-based SENSOR_MODULES/load_modules path, since it needs no hardware and isn't optional), adding it to configured_modules so it flows through the existing polling/logging/push pipeline.
  • Handles relay_history being unset (no SPACE_OPEN_RELAY configured) and RTCUnreliableError (clock not yet NTP-synced) by returning None, which the existing clean_readings() pipeline already drops.

Closes #136

Test plan

  • Syntax-checked new/modified files
  • Ran full test suite before and after the change — same pre-existing failures/errors in both cases (missing framebuf MicroPython stub in the dev venv), confirming no regression
  • Manual on-device verification of relay_on_time reading in sensor push payload

Exposes relay_history's cumulative active seconds as a sensor reading
(relay_on_time) via a new InternalMetrics module, so it flows through
the existing sensor polling/push pipeline for SMIB howfresh reporting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sjefferson99 sjefferson99 linked an issue Sep 9, 2026 that may be closed by this pull request
@sjefferson99 sjefferson99 self-assigned this Sep 9, 2026
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.

Add relay on time to sensors for smib howfresh reporting

1 participant