Skip to content

feat: add get_setting command and run it on startup - #4

Merged
Lash-L merged 1 commit into
mainfrom
initial_get_setting_command
Jul 9, 2026
Merged

feat: add get_setting command and run it on startup#4
Lash-L merged 1 commit into
mainfrom
initial_get_setting_command

Conversation

@Lash-L

@Lash-L Lash-L commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added camera request/response support, including sending commands and waiting for replies.
    • Added a camera settings request flow and support for receiving settings updates from response topics.
    • Camera connections now subscribe to both event and response channels, enabling richer live interactions.
  • Bug Fixes

    • Improved handling of settings-related messages so camera state updates are recognized more reliably.
    • Better error reporting when a camera client is unavailable.

@Lash-L
Lash-L requested review from afgarcia86 and Copilot July 7, 2026 14:36
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: 146d8881-f8bf-46e2-a19c-49153312c333

📥 Commits

Reviewing files that changed from the base of the PR and between 39a9ce3 and cf4e9fe.

📒 Files selected for processing (9)
  • harbor/__init__.py
  • harbor/core.py
  • harbor/data/mqtt_models.py
  • harbor/devices/camera.py
  • harbor/events.py
  • harbor/mqtt.py
  • tests/test_core.py
  • tests/test_mqtt.py
  • tests/test_subscription.py

📝 Walkthrough

Walkthrough

This PR adds a request/response command layer for Harbor cameras over MQTT, including a GetCameraSettingsRequest model, aliased SettingsEvent fields, pending-response tracking with sequence IDs, new HarborMQTTClient and Harbor public APIs, topic/event parsing updates for response topics, and corresponding tests.

Changes

Camera get-settings request/response feature

Layer / File(s) Summary
Settings data models
harbor/data/mqtt_models.py, harbor/__init__.py
Adds GetCameraSettingsRequest, aliases SettingsEvent.is_updating/triggered_by to isUpdating/triggeredBy, enables populate_by_name, and exports the new model.
MQTT request/response infrastructure
harbor/mqtt.py
Adds pending-response futures keyed by seq, _generate_seq(), publish, publish_command, request_command, get_settings, initial command publishing, and teardown handling that fails pending futures.
Topic and event parsing updates
harbor/devices/camera.py, harbor/events.py
Subscribes to responses/# topics and updates parse_topic/parse_message to recognize responses root and get_settings event key.
Harbor core public APIs
harbor/core.py
Adds publish_camera_command, request_camera_command, get_camera_settings, wires DEFAULT_INITIAL_COMMANDS and response topic subscription, and raises KeyError for missing clients.
Tests
tests/test_core.py, tests/test_mqtt.py, tests/test_subscription.py
Adds tests covering initial commands, request/response round trips, get-settings payload shape, and settings event state updates.

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
Loading

Poem

A rabbit hops through topics new,
"Responses/#" and "seq" ring true,
Settings fetched with futures bright,
Commands published left and right,
🐇 Thump thump — the client waits, then celebrates! 🎉


Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 by seq, and a get_settings helper) and run initial commands on connect.
  • Extend topic parsing/subscriptions to include cameras/<serial>/responses/# and treat responses/get-settings as a SettingsUpdate.
  • 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.

Comment thread harbor/mqtt.py
Comment on lines 67 to +68
await self.message_handler(topic, payload)
self._resolve_pending_response(topic, payload)
@Lash-L
Lash-L merged commit 5a1deca into main Jul 9, 2026
9 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.

3 participants