Skip to content

Fix 0138 AckResponse#424

Merged
bouwew merged 5 commits intomainfrom
pw_usb_0138
Mar 9, 2026
Merged

Fix 0138 AckResponse#424
bouwew merged 5 commits intomainfrom
pw_usb_0138

Conversation

@bouwew
Copy link
Contributor

@bouwew bouwew commented Mar 9, 2026

Summary by CodeRabbit

  • Documentation

    • Added clarifying comments to response type definitions.
  • Refactor

    • Adjusted relay initialization request/response handling and related public type annotations for consistency.
  • Tests

    • Simplified/disabled parts of the relay initialization test flow.
  • Chore

    • Bumped project version and added changelog entry for v0.47.5.

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5bc40e17-02a4-4a27-8927-79dca3007157

📥 Commits

Reviewing files that changed from the base of the PR and between ffe93e4 and 4f17843.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • pyproject.toml
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Changed CircleRelayInitStateRequest to expect NodeAckResponse and use reply identifier b"0100"; refined PlugwiseRequest type hints to allow None; added inline comments to response enums; commented out relay-init subscription/assertions in a test; bumped package version and changelog.

Changes

Cohort / File(s) Summary
CircleRelayInitStateRequest
plugwise_usb/messages/requests.py
Switched expected response from CircleRelayInitStateResponse to NodeAckResponse; updated _reply_identifier from b"0139" to b"0100" (with PW version mapping comments); adjusted send() return type and runtime type checks accordingly.
PlugwiseRequest base types
plugwise_usb/messages/requests.py
Refined type annotations: PlugwiseRequest._reply_identifier from bytes to `bytes
Response enum docs
plugwise_usb/messages/responses.py
Added inline semantic comments to StickResponseType (ACCEPT, FAILED) and NodeAckResponseType (DEFAULT_ACK, DEFAULT_FAIL) members; no value changes.
Tests (relay-init)
tests/test_usb.py
Commented out RELAY_INIT subscription, related assertions, state-transition checks, and unsubscribe in test_node_relay_and_power, effectively disabling relay-init validation in that test.
Changelog & version
CHANGELOG.md, pyproject.toml
Added changelog entry for v0.47.5 and bumped project version from 0.47.4 to 0.47.5.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • dirixmjm
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix 0138 AckResponse' directly corresponds to the main changes: updating CircleRelayInitStateRequest's reply_identifier from b'0139' to b'0100' and changing the response type from CircleRelayInitStateResponse to NodeAckResponse. The title is specific, concise, and accurately reflects the primary objective of this fix.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pw_usb_0138

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 and usage tips.

@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.01%. Comparing base (a2ede89) to head (4f17843).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #424      +/-   ##
==========================================
- Coverage   82.08%   82.01%   -0.08%     
==========================================
  Files          36       36              
  Lines        8189     8177      -12     
==========================================
- Hits         6722     6706      -16     
- Misses       1467     1471       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai bot requested a review from dirixmjm March 9, 2026 10:28
@bouwew bouwew changed the title Fix 0139 AckResponse Fix 0138 AckResponse Mar 9, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

Copy link

@coderabbitai coderabbitai bot left a comment

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)
plugwise_usb/messages/requests.py (1)

1513-1541: ⚠️ Potential issue | 🔴 Critical

Keep the relay-init read path on CircleRelayInitStateResponse.

CircleRelayInitStateRequest still models both get and set, but this change hard-codes _reply_identifier/send() to b"0100"/NodeAckResponse. The caller in plugwise_usb/nodes/circle.py, Lines 1140-1149, still reads response.relay.value, and NodeAckResponse has no relay; subscribing only to b"0100" also causes any later b"0139" state payload to be ignored. Keep CircleRelayInitStateResponse for the query path, or split get/set into separate request types so the ack-only flow does not replace the payload-bearing response.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@plugwise_usb/messages/requests.py` around lines 1513 - 1541, The request
class CircleRelayInitStateRequest currently hardcodes _reply_identifier to
b"0100" and send() to expect NodeAckResponse, which breaks the read/query path
that returns a CircleRelayInitStateResponse with a relay field; change the logic
to select the expected reply based on the operation (the Int field set_or_get):
if set_or_get == 1 (configure/set) keep the ack-only behavior (expect
NodeAckResponse and use _reply_identifier b"0100"), but if set_or_get == 0
(get/query) allow/expect the payload-bearing CircleRelayInitStateResponse (reply
id b"0139") and return that so callers can access response.relay.value;
implement this by either restoring/using b"0139" for the query path or by
accepting both reply identifiers and branching in send() to parse/return the
correct response class (references:
CircleRelayInitStateRequest._reply_identifier,
CircleRelayInitStateRequest.send(), the set_or_get Int field, NodeAckResponse,
CircleRelayInitStateResponse).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@plugwise_usb/messages/requests.py`:
- Around line 1513-1541: The request class CircleRelayInitStateRequest currently
hardcodes _reply_identifier to b"0100" and send() to expect NodeAckResponse,
which breaks the read/query path that returns a CircleRelayInitStateResponse
with a relay field; change the logic to select the expected reply based on the
operation (the Int field set_or_get): if set_or_get == 1 (configure/set) keep
the ack-only behavior (expect NodeAckResponse and use _reply_identifier
b"0100"), but if set_or_get == 0 (get/query) allow/expect the payload-bearing
CircleRelayInitStateResponse (reply id b"0139") and return that so callers can
access response.relay.value; implement this by either restoring/using b"0139"
for the query path or by accepting both reply identifiers and branching in
send() to parse/return the correct response class (references:
CircleRelayInitStateRequest._reply_identifier,
CircleRelayInitStateRequest.send(), the set_or_get Int field, NodeAckResponse,
CircleRelayInitStateResponse).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bb40f92-3f3d-4519-b66b-ce671c0651f9

📥 Commits

Reviewing files that changed from the base of the PR and between a2ede89 and ffe93e4.

📒 Files selected for processing (3)
  • plugwise_usb/messages/requests.py
  • plugwise_usb/messages/responses.py
  • tests/test_usb.py

@bouwew bouwew marked this pull request as ready for review March 9, 2026 17:29
@bouwew bouwew requested a review from a team as a code owner March 9, 2026 17:29
@bouwew bouwew merged commit 8170aaa into main Mar 9, 2026
15 of 17 checks passed
@bouwew bouwew deleted the pw_usb_0138 branch March 9, 2026 17:29
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.

1 participant