Skip to content

fix(biometrics): register sensHealth, frzWater, and lps as known record types - #872

Merged
ng merged 2 commits into
sleepypod:devfrom
onemec:fix/known-record-types
Oct 28, 2026
Merged

ng merged 2 commits into
sleepypod:devfrom
onemec:fix/known-record-types

Conversation

@onemec

@onemec onemec commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Following recent STM32 microcontroller firmware upgrades (cover sensor STM32G0 to v5.5.22.0 and freezer thermal controller STM32 to v1.6.114), the firmware emits three telemetry record types over NATS JetStream:

  • sensHealth: Cover sensor health and link connectivity (left.connected, right.connected, version: 1).
  • frzWater: Water level, capacitive reading, and priming status (isPriming, hasWater, capValid, capLevel, needsPriming).
  • lps: Linear Pressure Sensor raw load-cell samples (200 Hz binary waveform buffers).

In modules/common/dialect.py, KNOWN_RECORD_TYPES is an allowlist intended to surface genuinely unknown firmware types once on startup while quietly ignoring known telemetry belonging to other subsystems. Because these types were missing, sleep-detector (and other biometrics daemons) logged startup warnings for each type.

Additionally, in the TypeScript WebSocket streaming server (src/streaming/piezoStream.ts), ALL_SENSOR_TYPES flagged frzWater and sensHealth with [sensorStream] unknown sensor frame type ....

This PR:

  1. Adds "sensHealth", "frzWater", "lps", "tap-gesture", and "alarm-info" to KNOWN_RECORD_TYPES in modules/common/dialect.py.
  2. Updates modules/common/test_dialect.py to assert these types are recognized.
  3. Adds 'frzWater' and 'sensHealth' to ALL_SENSOR_TYPES in src/streaming/piezoStream.ts, src/hooks/useSensorStream.ts, and src/demo/sensorFrames.ts.
  4. Defines FrzWaterFrame and SensHealthFrame TypeScript interfaces, added to the SensorFrame union.
  5. Adds unit tests in src/streaming/tests/piezoStream.test.ts verifying subscriptions to frzWater and sensHealth function cleanly without unknown-type warnings.

Verification

Automated Tests

  • Python Unit Tests: 242 tests passing in modules/common:
    cd modules && uv run --with pytest --with cbor2 pytest common
    # ============================= 242 passed in 0.92s ==============================
  • TypeScript Vitest:
    pnpm vitest run src/streaming/tests/piezoStream.test.ts
    # ✓ src/streaming/tests/piezoStream.test.ts (119 tests)
    pnpm vitest run src/hooks/tests/useSensorStream.test.ts
    # ✓ src/hooks/tests/useSensorStream.test.ts (84 tests)

Live Hardware Verification (Pod 3 Hub)

Tested live on a physical Pod 3 Hub (MediaTek MT8365 Pumpkin, running frankenfirmware 3c552d6, cover sensor v5.5.22.0, thermal controller v1.6.114).

Before (startup warnings in systemd journal):

journalctl -u sleepypod-sleep-detector:

Oct 28 00:00:33 eight-pod python[338]: 2026-10-28T00:00:33 [sleep-detector] WARNING Unknown record type 'lps' — passing through without normalization (sleep-detector)
Oct 28 00:00:33 eight-pod python[338]: 2026-10-28T00:00:33 [sleep-detector] WARNING Unknown record type 'frzWater' — passing through without normalization (sleep-detector)
Oct 28 00:01:30 eight-pod python[338]: 2026-10-28T00:01:30 [sleep-detector] WARNING Unknown record type 'sensHealth' — passing through without normalization (sleep-detector)

journalctl -u sleepypod (Next.js server):

Oct 28 00:00:43 eight-pod sh[333]: [sensorStream] unknown sensor frame type "frzWater" — broadcasting but not ingesting
Oct 28 00:01:30 eight-pod sh[333]: [sensorStream] unknown sensor frame type "sensHealth" — broadcasting but not ingesting

After (updated dialect.py deployed to /opt/sleepypod/modules/common/dialect.py and services restarted):

journalctl -u sleepypod-sleep-detector -b --since "1 minute ago":

Oct 28 01:21:27 eight-pod systemd[1]: Stopped SleepyPod Sleep Detector (Session Boundaries and Movement).
Oct 28 01:21:27 eight-pod systemd[1]: Started SleepyPod Sleep Detector (Session Boundaries and Movement).

systemctl status sleepypod-sleep-detector:

● sleepypod-sleep-detector.service - SleepyPod Sleep Detector (Session Boundaries and Movement)
     Loaded: loaded (/etc/systemd/system/sleepypod-sleep-detector.service; enabled; vendor preset: disabled)
     Active: active (running) since Wed 2026-10-28 01:21:27 UTC; 12s ago
   Main PID: 1215 (python)

All three daemons (sleepypod-sleep-detector, sleepypod-piezo-processor, sleepypod-environment-monitor) ingest frames cleanly with zero unknown record warnings.

Summary by CodeRabbit

  • New Features
    • Added support for receiving and filtering frzWater and sensHealth sensor data.
    • Added recognition for additional record types, including lps, tap-gesture, and alarm-info.

@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

@onemec is attempting to deploy a commit to the therealng's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9cac601-c431-4026-a45f-d25ef899ff6e
Commits

Reviewing files that changed from the base of the PR and between 47034d4 and 02eeee5.

Files selected for processing: 6
  • modules/common/dialect.py
  • modules/common/test_dialect.py
  • src/demo/sensorFrames.ts
  • src/hooks/useSensorStream.ts
  • src/streaming/piezoStream.ts
  • src/streaming/tests/piezoStream.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The change adds five record types to the Python dialect registry. It adds TypeScript frame definitions and sensor-list entries for frzWater and sensHealth, and tests subscription and frame delivery for those two types.

Changes: Sensor record type support

Layer / File(s) Summary
Register dialect record types
modules/common/dialect.py, modules/common/test_dialect.py
The known-type registry and its test now include sensHealth, frzWater, lps, tap-gesture, and alarm-info.
Define TypeScript sensor frame types
src/hooks/useSensorStream.ts, src/demo/sensorFrames.ts
The stream type definitions include FrzWaterFrame and SensHealthFrame. Sensor lists and the SensorFrame union include frzWater and sensHealth.
Recognize types in subscriptions
src/streaming/piezoStream.ts, src/streaming/tests/piezoStream.test.ts
The stream recognizes frzWater and sensHealth. The test checks subscription acknowledgements, frame delivery, and warning behavior for both types.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: ng

Merge Risk: Minimal · up to 02eee

The new types are recognized and can reach subscribers on the inspected paths. No merge-blocking issue is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately describes the core change: registering sensor record types as known types. It names three affected types and remains concise, although it does not mention tap-gesture, `alarm-in…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title accurately describes the core change: registering sensor record types as known types. It names three affected types and remains concise, although it does not mention tap-gesture, alarm-info, or the TypeScript updates.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 6 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@onemec

onemec commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

Future Feature Opportunities

By registering and typing frzWater and sensHealth in ALL_SENSOR_TYPES and useSensorStream, frontend components and backend services can now subscribe to them directly over the WebSocket stream (useSensorFrame('frzWater'), useSensorFrame('sensHealth')).

Keeping this PR strictly scoped to type registration and log-warning suppression (fix(biometrics)) keeps it clean and backward-compatible across older pod generations. Future feature PRs can build on top of these exposed frames:

  1. Capacitive Water Level Gauge (0–5)

    • Current: Core UI only exposes binary water state (ok vs low) polled from DAC DEVICE_STATUS.
    • frzWater payload: Exposes capLevel: 0–5, capValid: boolean, hasWater: boolean, isPriming: boolean, and needsPriming: boolean.
    • Potential Feature: A 5-bar water tank gauge and priming progress indicator in the UI / footer status.
  2. Explicit Cover Disconnect Alerting

    • Current: Disconnection is inferred indirectly from absent capSense or -32768 sentinel values.
    • sensHealth payload: Exposes explicit per-side connection flags (left.connected: boolean, right.connected: boolean, version: 1).
    • Potential Feature: Surface an immediate "Left/Right cover sensor disconnected" warning badge on the dashboard or /system health view.
  3. System → Health Live Stream Inspector

    • Mapping frzWater to the freezer stream group and sensHealth to presence in src/components/Sensors/streamGroups.ts will surface their live packet rate and last-seen timestamps in the diagnostic live stream inspector.

@onemec
onemec marked this pull request as ready for review October 28, 2026 01:37
@ng
ng added this pull request to the merge queue Oct 28, 2026
Merged via the queue into sleepypod:dev with commit 56e61fc Oct 28, 2026
14 of 15 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