Skip to content

Backend#6

Draft
tkogut wants to merge 2 commits intofeature/network-access-enhancementfrom
cursor/backend-e158
Draft

Backend#6
tkogut wants to merge 2 commits intofeature/network-access-enhancementfrom
cursor/backend-e158

Conversation

@tkogut
Copy link
Owner

@tkogut tkogut commented Jan 14, 2026

Add MQTT history module for storing weight readings and device status, and fix outdated lib.rs tests.

The existing lib.rs tests were failing due to changes in the DeviceConfig structure, which prevented the new history module tests from running successfully. These tests were updated to reflect the current DeviceConfig structure, ensuring a clean test run for the new module.


Open in Cursor Open in Web

…storage

- Create mqtt/history.rs with MqttHistoryStore for in-memory storage
- Support weight readings history with pagination and time-based filtering
- Support device status history tracking
- Add automatic cleanup of old entries (configurable max age and max entries)
- Implement thread-safe storage using RwLock for concurrent access
- Add 7 unit tests for history module functionality
- Fix outdated DeviceConfig tests in lib.rs to match new structure
- Create coordination/backend-status.json for task tracking

Task B1 completed.

Co-authored-by: roostertk <roostertk@tutamail.com>
@cursor
Copy link

cursor bot commented Jan 14, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@vercel
Copy link

vercel bot commented Jan 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
bridge-scale-cmd-rust Ready Ready Preview, Comment Jan 14, 2026 6:26pm

B2: Integrate MqttHistoryStore with MQTT subscriber
- Add start_mqtt_subscriber_with_history() function
- Automatically store weight readings and device status from MQTT messages
- Subscribe to scaleit/weight/+ and scaleit/status/+ topics when history enabled
- Update AppState to hold optional history store reference

B3: Add REST API endpoints for MQTT history queries
- GET /api/mqtt/history/{device_id} - paginated weight readings history
- GET /api/mqtt/history/{device_id}/latest - most recent reading
- GET /api/mqtt/history/{device_id}/status - device status history
- GET /api/mqtt/history/{device_id}/stats - device statistics
- GET /api/mqtt/devices - list devices with history
- GET /api/mqtt/status - MQTT integration status
- DELETE /api/mqtt/history/{device_id} - clear device history

All 27 tests passing.

Co-authored-by: roostertk <roostertk@tutamail.com>
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