Skip to content

feat: add some extra commands - #6

Merged
Lash-L merged 2 commits into
mainfrom
extra_commands
Jul 22, 2026
Merged

feat: add some extra commands#6
Lash-L merged 2 commits into
mainfrom
extra_commands

Conversation

@Lash-L

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

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added controls to turn cameras on or off and enable or disable night mode.
    • Camera settings now update device state automatically after changes or settings refreshes.
    • Added a public command error for rejected camera-control requests.
  • Bug Fixes

    • Successful camera commands are no longer reported as failed when a follow-up settings refresh times out.
    • Preserved existing control-state values when settings responses omit them.

@Lash-L
Lash-L requested a review from afgarcia86 July 18, 2026 15:04
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Lash-L, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e84f3b52-953a-4a9c-abdf-5e7f90df7c38

📥 Commits

Reviewing files that changed from the base of the PR and between 2336f2c and 849a389.

📒 Files selected for processing (1)
  • harbor/exceptions.py
📝 Walkthrough

Walkthrough

Adds camera on/off and night-mode controls through MQTT and the high-level Harbor API. Control commands refresh camera settings, settings events update device state, command errors are exported, and tests cover delegation, state mapping, refresh failures, and rejected commands.

Changes

Camera control

Layer / File(s) Summary
Settings event state updates
harbor/events.py, harbor/devices/camera.py, tests/test_camera_state.py
Typed settings payloads update normalized camera_on and night_mode state while preserving values omitted from later responses.
MQTT camera control commands
harbor/mqtt.py, tests/test_mqtt.py
Adds stream and night-mode commands, settings refresh after successful control operations, HarborCommandError for rejected commands, and coverage for command payloads and failures.
Public camera control API
harbor/__init__.py, harbor/core.py, tests/test_core.py
Exposes HarborCommandError and adds high-level camera control wrappers that forward arguments to the MQTT client.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested reviewers: afgarcia86

Poem

I twitch my nose; the night turns bright,
Streams pause and wake beneath the moonlight.
Settings hop through every state,
Errors wear names and guard the gate.
A carrot cheers each tested flight! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is generic and does not specify the main change, so it is hard to tell what commands were added. Rename it to mention the actual feature, e.g. "feat: add camera on and night mode commands".
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 89.66% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch extra_commands

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.

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
harbor/events.py (1)

344-362: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Do not classify command acknowledgements as camera events.

Replies for pause-stream, unpause-stream, and update-night-mode reach this fallback and become CameraEventUpdates. Each command therefore adds a false entry to state.events and emits a device update, including rejected commands. Return unmatched /responses/ topics as raw events before the generic camera-event fallback.

Proposed fix
+    if source_type == "camera" and "/responses/" in topic:
+        return RawEventUpdate(payload=raw_payload, **base_kwargs)
+
     if source_type == "camera":
         active_seconds = extract_event_duration_seconds(raw_payload)

Add a regression test parsing a control response and asserting it is not a CameraEventUpdate.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@harbor/events.py` around lines 344 - 362, Before the generic camera-event
fallback in the camera handling flow, detect unmatched /responses/ topics and
return them as raw events, including rejected command responses. Preserve
existing motion_detection validation and normal camera-event handling, and add a
regression test covering a control response that asserts it is not classified as
CameraEventUpdate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@harbor/events.py`:
- Around line 344-362: Before the generic camera-event fallback in the camera
handling flow, detect unmatched /responses/ topics and return them as raw
events, including rejected command responses. Preserve existing motion_detection
validation and normal camera-event handling, and add a regression test covering
a control response that asserts it is not classified as CameraEventUpdate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76595876-d7c1-400d-9915-cb63ef8e0e4e

📥 Commits

Reviewing files that changed from the base of the PR and between 2175a3e and 2336f2c.

📒 Files selected for processing (8)
  • harbor/__init__.py
  • harbor/core.py
  • harbor/devices/camera.py
  • harbor/events.py
  • harbor/mqtt.py
  • tests/test_camera_state.py
  • tests/test_core.py
  • tests/test_mqtt.py

@Lash-L
Lash-L merged commit 336f0fc into main Jul 22, 2026
8 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