Skip to content

Enhance Safety Monitor with Stale Data Failsafe and IsSafe Fix - #122

Merged
chvvkumar merged 6 commits into
mainfrom
dev
Oct 12, 2026
Merged

chvvkumar merged 6 commits into
mainfrom
dev

Conversation

@chvvkumar

@chvvkumar chvvkumar commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

📋 Overview

This pull request significantly enhances the safety monitor by introducing a failsafe mechanism that triggers an unsafe state if camera images become stale or detection continuously fails. It also corrects the IsSafe reporting logic, ensuring all clients consistently receive the true debounced detector state, regardless of their connection status, aligning with updated ASCOM specifications.

🔄 Changes by Category

  • Features:
    • Introduces a failsafe mechanism for the safety monitor, triggering an unsafe status if camera images are stale or detection continuously fails.
    • Adds configuration options for image staleness limits (max_image_age_sec).
    • Integrates Home Assistant data availability topic and a Safe binary_sensor.
    • Updates the setup page with a live preview and new configuration fields.
    • Enhances the dashboard with image status display and updates the external API image object.
  • Bug Fixes:
    • Corrects the IsSafe reporting logic to always reflect the true debounced detector state to all Alpaca clients and external APIs, removing the "False unless connected" gate.
    • Resolves an issue where the safety monitor could report safe despite stale camera images or detection failures.
    • Fixes a dashboard UI issue where the image tooltip could go outside the viewport.
  • Refactoring:
    • Refactors the IsSafe logic by moving the "False unless connected" gate out of the core is_safe() function.
    • Splits image status display on the dashboard into value and subtext for better clarity.
  • Documentation:
    • Updates readme.md to reflect new safety monitor features and configuration.
    • Modifies docs/EXTERNAL_API.md to reflect changes in the external API.
  • Tests:
    • Adds extensive new tests for the stale failsafe mechanism and image status API.
    • Modifies existing tests related to IsSafe gating, MQTT reconnect, and multi-client verification.
    • Adds keras.models stubbing to conftest.py to allow route-level unit tests to run without TensorFlow.
  • Configuration:
    • Adds max_image_age_sec to alpaca/config.py for configuring image staleness.

📊 Analyzed 6 commit(s) | 🕐 Updated: 2026-10-12T08:01:40.975Z | Generated by GitHub Actions


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.
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
Enhance Safety Monitor with Stale Data Failsafe and Reporting
@github-actions github-actions Bot changed the title Dev Enhance Safety Monitor with Stale Data Failsafe and IsSafe Fix Oct 12, 2026
@chvvkumar
chvvkumar merged commit d77faa7 into main Oct 12, 2026
14 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