feat: add get_setting command and run it on startup - #4
Conversation
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR adds a request/response command layer for Harbor cameras over MQTT, including a ChangesCamera get-settings request/response feature
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Harbor
participant HarborMQTTClient
participant MQTTBroker
participant Camera
Harbor->>HarborMQTTClient: get_camera_settings(serial, timeout)
HarborMQTTClient->>HarborMQTTClient: _generate_seq()
HarborMQTTClient->>MQTTBroker: publish(cameras/serial/get-settings, seq+client+triggeredBy)
MQTTBroker->>Camera: deliver get-settings command
Camera->>MQTTBroker: publish responses/get-settings with echoed seq
MQTTBroker->>HarborMQTTClient: _handle_message(response)
HarborMQTTClient->>HarborMQTTClient: _resolve_pending_response(seq)
HarborMQTTClient-->>Harbor: SettingsEvent
Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
There was a problem hiding this comment.
Pull request overview
Adds first-class support for the camera get-settings command and ensures it is issued automatically after MQTT connection so camera state (e.g., friendly name and runtime state) is populated early.
Changes:
- Add request/response command support to
HarborMQTTClient(publish helpers, request correlation byseq, and aget_settingshelper) and run initial commands on connect. - Extend topic parsing/subscriptions to include
cameras/<serial>/responses/#and treatresponses/get-settingsas aSettingsUpdate. - Add test coverage for settings response parsing, command request/response correlation, and Harbor’s default initial commands.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_subscription.py | Adds coverage that responses/get-settings parses into SettingsUpdate and updates camera state/display name. |
| tests/test_mqtt.py | Adds tests for command publishing, seq-based response matching, get_settings() payload shape, and initial command publishing. |
| tests/test_core.py | Verifies Harbor-created camera clients default to DEFAULT_INITIAL_COMMANDS. |
| harbor/mqtt.py | Implements command publishing + request/response correlation, get-settings helper, and runs initial commands on connect. |
| harbor/events.py | Allows parsing responses/* topics and maps get_settings to SettingsUpdate. |
| harbor/devices/camera.py | Subscribes cameras to responses/# in addition to events/#. |
| harbor/data/mqtt_models.py | Adds request/response models and alias handling for camelCase fields. |
| harbor/core.py | Ensures responses topics are subscribed and exposes command APIs on Harbor. |
| harbor/init.py | Exposes GetCameraSettingsRequest in the public package surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await self.message_handler(topic, payload) | ||
| self._resolve_pending_response(topic, payload) |
Summary by CodeRabbit
New Features
Bug Fixes