Skip to content

Enhance Safety Monitor with Stale Data Failsafe and Reporting - #121

Merged
chvvkumar merged 22 commits into
devfrom
snd
Oct 9, 2026
Merged

chvvkumar merged 22 commits into
devfrom
snd

Conversation

@chvvkumar

@chvvkumar chvvkumar commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

📋 Overview

This pull request significantly enhances the safety monitoring system by introducing fail-safe mechanisms for stale camera images and persistent detection failures. It refines how the safety status is reported across various interfaces, including Alpaca, MQTT, the dashboard, and an external API, ensuring more accurate and reliable observatory safety.

🔄 Changes by Category

  • Features:
    • Implemented fail-safe mechanisms that trigger an unsafe state if the camera image stops updating (max_image_age_sec) or if detection continuously fails.
    • Introduced a Home Assistant data availability topic and a Safe binary sensor for improved integration.
    • Ensured the real IsSafe value is served to all Alpaca clients, removing the previous "False unless connected" gate.
    • Added a legacy MQTT is_safe field for backward compatibility.
    • Enhanced the external API to include an image object with status details.
  • Bug Fixes:
  • Configuration:
    • Added max_image_age_sec to the configuration, allowing users to define the image hash staleness limit.
  • Documentation:
    • Updated readme.md to reflect new Home Assistant integration details.
    • Modified docs/EXTERNAL_API.md to document the new image object status.
  • UI/UX:
    • Added a new field to the setup page with a live preview for safety settings related to image and detection staleness.
    • Refined the dashboard image row to split the status display into a distinct value and subtext.
  • Tests:
    • Introduced comprehensive new tests (test_stale_failsafe.py, test_image_status_api.py) for the stale data fail-safe logic and image status API.
    • Modified conftest.py to stub keras.models, allowing route-level unit tests to run without TensorFlow.
    • Updated existing tests related to the issafe gate and MQTT reconnect functionality.

📊 Analyzed 22 commit(s) | 🕐 Updated: 2026-10-09T11:55:49.726Z | Generated by GitHub Actions


Update README, add Alpaca test, and enhance PR summary
Fix Windows image paths and add SSL verification for image URLs
Introduce and refine system architecture documentation and diagrams
Modular Refactor, Multi-Client Support, and UI/Config Enhancements
Improve client list display and add ASCOM status tooltip
Implement client heartbeats, improve display formatting, and fix UI
Make MQTT and Home Assistant settings optional
Bugfix: Fix client connection duration display in UI
Optimize Docker build caching and add parallel job flags
Fix device detection label case sensitivity and setup title format
Enhance configuration safety, fix regressions, and sanitize settings
Introduce External API, enhance timestamps, and update documentation
Adjust styling for detection items in setup page
The previous change moved the "False unless connected" gate out of
is_safe() and into the Alpaca issafe/devicestate routes, keyed per client.
That still blocked the use case in issue #117: a roof controller that polls
/api/v1/safetymonitor/0/issafe directly and never sends Connected=true kept
reading False while the dashboard showed Safe. The ASCOM spec never requires
False when not connected and ConformU dropped that check on 2025-03-16, so
the gate is removed and issafe, devicestate, the external API, the
dashboard and MQTT now all report the debounced detector state.

tests/conftest.py stubs keras.models when TensorFlow is not installed so the
route-level unit tests run without the model stack.
Improve Safety State Reporting and MQTT Reconnect Availability
The safety monitor could keep reporting safe while the camera image
stopped updating or detection kept failing, leaving the observatory
open on stale data. Refs #120

- Image hash staleness limit: max_image_age_sec (default 600,
  0 disables); startup requires one new frame before reporting safe
- Detection-failure limit: max(180, 3x update interval)
- Both commit unsafe immediately; recovery waits debounce_to_safe_sec
- Home Assistant data availability topic plus Safe binary_sensor
- Legacy MQTT is_safe field
- Setup page field with live preview
- Dashboard image row
- External API image object
- Tests for stale fail-safe and image status API, shared conftest
@github-actions github-actions Bot changed the title Snd Enhance Safety Monitor with Stale Data Failsafe and Reporting Oct 9, 2026
@chvvkumar
chvvkumar merged commit 7133809 into dev Oct 9, 2026
8 checks passed
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