Conversation
…ative on-time - Introduced the `Space Relay State` plugin with API endpoints to receive relay state and reset reports. - Added models for relay state reports, reset reports, and history tracking. - Implemented Slack alerting for relay lifetime warnings and state drift notifications. - Updated `README.md` and `SETTINGS.md` with plugin information and configuration options.
…nitoring - Introduced scheduled monitoring of relay states with configurable intervals. - Implemented Slack alerting for relay-lifetime thresholds and drift detection during periodic checks. - Extended configuration options (`monitor_interval`) for enabling and customizing periodic sweeps. - Updated related documentation (`README.md`, `SETTINGS.md`) and refactored code for enhanced maintainability.
…ove debounce logic
- Replaced individual alert fields with a unified `AlertState` model for relay lifetime and drift alerts.
- Unified debounce logic using `_should_resend_alert`, allowing consistent alert triggering rules.
- Introduced device-level locks to enforce atomic operations during state updates.
- Updated Slack alert templates to support `{threshold}` placeholder.
- Adjusted `SETTINGS.md` to document the updated alert message template.
- Added validation for timezone-aware timestamps in `common.py` to prevent usage of naive datetimes. - Introduced `reported_total_active_seconds_at_last_reset` to improve drift-check baseline accuracy. - Improved handling of out-of-order timestamps by clamping negative durations to zero. - Refactored `_update_drift_alert_state` to use `reported_since_reset` for clearer comparisons. - Updated relay state models and state-saving logic to support enhanced drift detection.
sjefferson99
approved these changes
Sep 9, 2026
sjefferson99
left a comment
Member
There was a problem hiding this comment.
Appears to meet the requirement.
- Document new SMIB_PLUGIN_SPACE_RELAY_STATE_* environment variables in template.env, including monitor interval, drift warning threshold, relay lifetime warning/alert settings, and alert channel/resend configuration - Provides example defaults so operators can configure the new space relay state plugin alongside the existing space state plugin section
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
Adds a new
space/relaystateplugin that tracks relay on/off state and cumulative on-time reported by SMIBHID devices, computing its own authoritative on-time from received transitions and cross-checking it against the device's self-reported counter. Also generalizes timestamp handling shared with the existingsmibhidplugin.New plugin:
space/relaystatelisteners/http.py):POST /space/relay/state— receive relay on/off + cumulative on-time reports from a device.POST /space/relay/reset— record that a device's on-time counter was manually reset (e.g. filter change).common.py,models.py): SMIB computes its owncomputed_total_active_secondsfrom ON→OFF transition durations (not just trusting the device's reported value), stored per-device inRelayState, with full event history inRelayStateHistoryand reset history inRelayResetHistory.listeners/scheduled.py): periodic sweep of all known relay states re-checks both alert types independent of new incoming reports, so a relay stuck ON with no new events still gets caught.RelayStaterecord each), though plugin configuration (thresholds, channels, message template) is currently global/shared rather than per-device — tracked separately in multiple smibhids reporting data #510.Shared timestamp handling (
smibhid/common.py)validate_timestampnow accepts Unix epoch (int/float) or ISO 8601 strings/datetimes, not just epoch numbers.SMIBHIDTimestampannotated type; the existingsmibhidsensor and UI-log models were migrated to use it instead of their own duplicated validator wiring.Robustness fixes
0and logged instead of being subtracted.reported_total_active_seconds_at_last_reset) prevents a false persistent drift alert on the very first report from a device that already had accumulated on-time before SMIB started tracking it.Docs
README.mdandSETTINGS.mdupdated with the new plugin's description and full list ofSMIB_PLUGIN_SPACE_RELAY_STATE_*environment variables.