Add internal metrics sensor for relay on time - #137
Open
sjefferson99 wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InternalMetricssensor module (src/lib/sensors/internal_metrics.py) that reports SMIBHID-internal metrics rather than readings from an attached I2C sensor. Itsget_reading()returnsrelay_on_time, sourced fromrelay_history.get_total_active_seconds.InternalMetricsintoSensors.__init__directly (not via the I2C-basedSENSOR_MODULES/load_modulespath, since it needs no hardware and isn't optional), adding it toconfigured_modulesso it flows through the existing polling/logging/push pipeline.relay_historybeing unset (noSPACE_OPEN_RELAYconfigured) andRTCUnreliableError(clock not yet NTP-synced) by returningNone, which the existingclean_readings()pipeline already drops.Closes #136
Test plan
framebufMicroPython stub in the dev venv), confirming no regressionrelay_on_timereading in sensor push payload