Skip to content

feat: add modem device tracking (reboots, SW updates, IPs) and refine event log#356

Merged
itsDNNS merged 1 commit intoitsDNNS:mainfrom
NonCertus:feat-device-tracking
Apr 26, 2026
Merged

feat: add modem device tracking (reboots, SW updates, IPs) and refine event log#356
itsDNNS merged 1 commit intoitsDNNS:mainfrom
NonCertus:feat-device-tracking

Conversation

@NonCertus
Copy link
Copy Markdown
Contributor

Description

  • Feature Overview:

DOCSight now monitors additional values of the modem in addition to its signal levels. Key features:

Reboot Detection:
Automatically identifies when the modem reboots by monitoring uptime drops. It calculates and logs the "Prior Uptime" so you know exactly how long the connection lasted before the failure.

Firmware Monitoring:
Detects when the modem’s software version changes (useful for tracking ISP-pushed updates).

WAN IP Tracking:
Monitors both IPv4 and IPv6 address changes. This is especially helpful for users with dynamic IPs who want to see how often their ISP "rotates" their connection.

Zero Resource Impact:
It "piggybacks" on the existing data collection loop. No additional network requests or polls are needed, making it extremely lightweight.

Improved Device Support:
It provides a reliable reboot detection method for modems that don't expose DOCSIS error logs (like many Vodafone devices).

New "Device" UI:
Adds a dedicated filter in the Event Log, so you can separate system-level events (reboots/IPs) from signal-level events (SNR/Power drops).

  • Event Badge Refactor & Bug Fix:

While implementing the new device tracking, I fixed an architectural limitation in how unacknowledged events were counted.

Issue:

Previously, the event badge count was calculated client-side by checking only the currently loaded "page" of events. If a user had many events or active filters (like "Hide Operational"), the badge would be inaccurate because the browser couldn't "see" events on subsequent pages.

Fix:

Moved the counting logic to a new /api/events/count backend endpoint. This allows the database to perform a native COUNT(*) query that respects all active filters (severity, prefix, and operational status).

Result:

Sidebar and navigation counters are now accurate regardless of pagination or filters, and the UI no longer "jumps" between different counts during refreshes. Additionally, this improves performance by letting the database handle the calculation via a native COUNT(*) query rather than processing large event lists on the client-side.

  • Improved Test Stability:

Context:

Developing on a WSL2 setup on resource restricted hardware revealed some "race conditions" where the server or browser would occasionally time out or crash due to virtualization overhead.

Chromium Stability:

Added --disable-gpu, --disable-dev-shm-usage, --disable-setuid-sandbox, and --no-sandbox to the Playwright launch arguments. These flags make the tests much more robust in WSL2/virtualized environments.

Increased Boot Timeout:

Increased the server start timeout from 60s to 150s. On lower-end hardware, generating 9 months of demo data can be intensive, and this prevents the test suite from failing prematurely.

  • Unit Test Mock Fixes:

Updated ModemCollector unit tests to properly mock the new device_state storage calls. This resolves a TypeError that occurred when comparing mocked objects to integers.

User-Facing Impact

  • Added a dedicated device tab in the Event Log UI to filter for specific system events.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • New modem driver
  • Performance improvement

Checklist

  • I have read the Contributing Guidelines
  • I have opened an issue before starting work on this PR
  • My code follows the project's code style
  • I have tested my changes locally
  • All tests pass (python -m pytest tests/ -v)
  • I have added tests for new functionality
  • I have tested both success and failure paths (if applicable)
  • I have updated the documentation (if applicable)
  • I have added i18n translations for new strings (EN/DE/FR/ES)
  • I have documented any UI, API, or config impact (if applicable)
  • I have attached screenshots/video for UI changes (if applicable)

Testing

Test Environment:

  • Modem: Vodafone Station TG
  • Deployment: local Python / WSL2
  • Browser: Firefox

Verification Commands:

python -m pytest tests/test_speedtest.py -v

Results:

all tests passed

Screenshots (if applicable):

DOCSight_device_tracking - Copy

Additional Notes

@itsDNNS
Copy link
Copy Markdown
Owner

itsDNNS commented Apr 24, 2026

Thanks for the work on this. I like the direction, especially keeping device lifecycle changes visible as first-class events instead of burying them in raw modem data.

Before merging, I think a few things should be tightened up:

  1. git diff --check currently reports trailing whitespace in several changed files. Easy cleanup, but worth fixing before merge.

  2. The new event_prefix filtering looks only partially wired through right now. The event list can be filtered to device events, but the unread count / badge path still appears to use the broader count:

    • /api/events passes event_prefix to get_events(...), but not to the unacknowledged_count query.
    • /api/events/count reads event_prefix, but does not pass it into get_event_count(...).
    • refreshEventBadge() does not send the active device filter.

    Result: the Device filter can show the right rows while the badge/count still reflects other events. I would fix this in the same PR and add a small API test for event_prefix on both list and count behavior.

  3. The new device UI/event types need i18n coverage:

    • the Device pill is hardcoded while the other filter pills use translations
    • device_sw_update, device_reboot, and device_ip_change need labels so the UI does not fall back to raw event keys

I would intentionally leave Smart Capture out of this. These are device lifecycle events, and I do not think they need to trigger Smart Capture as part of this PR.

Once the whitespace, count filtering, and i18n bits are fixed, this should be in much better shape to merge.

@NonCertus NonCertus force-pushed the feat-device-tracking branch from 6fbc934 to c219422 Compare April 25, 2026 02:35
@NonCertus NonCertus marked this pull request as draft April 25, 2026 03:55
@NonCertus NonCertus force-pushed the feat-device-tracking branch from c219422 to 3d3d922 Compare April 25, 2026 04:29
@NonCertus
Copy link
Copy Markdown
Contributor Author

NonCertus commented Apr 25, 2026

I completely agree with all your points, and I apologize for the messy state of the initial commit and for missing those counting and i18n details.

I hope to have now addressed all the feedback and tightened up the implementation.

  • device events are fully wired up now and added to the Notification Settings UI
  • counts are context-aware and robust against race conditions
  • improved event messages and cleaned up whitespace
  • included tests and squashed the changes into a single clean commit

@NonCertus NonCertus marked this pull request as ready for review April 25, 2026 06:24
@itsDNNS
Copy link
Copy Markdown
Owner

itsDNNS commented Apr 25, 2026

Thanks, this is moving in the right direction. The important behavior is there: lifecycle events are detected, can notify, and do not trigger Smart Capture by default.

Before this can move forward, please tighten up a few things:

  • Add regression coverage that reboot / software update / IP change events do not trigger Smart Capture by default, and that the first poll only establishes the baseline.
  • Add the new i18n keys to es.json, fr.json, and template.json, not just EN/DE.
  • Clean up the trailing whitespace reported by git diff --check.
  • Replace the demo WAN IPv4s with documentation ranges like 203.0.113.x.

After that, I’ll re-review.

@NonCertus NonCertus force-pushed the feat-device-tracking branch from 3d3d922 to 1670108 Compare April 25, 2026 20:51
@NonCertus NonCertus force-pushed the feat-device-tracking branch from 1670108 to 1b6d4b2 Compare April 25, 2026 21:24
@NonCertus
Copy link
Copy Markdown
Contributor Author

Thanks!

  • I tried to address everything.
  • "git diff --check" shows no problems

@itsDNNS itsDNNS merged commit 6b6f253 into itsDNNS:main Apr 26, 2026
3 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.

2 participants