-
Notifications
You must be signed in to change notification settings - Fork 2
Fix for #312, link to plugwise_usb v0.44.14 #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds an "Ongoing" subsection to CHANGELOG, bumps the plugwise-usb dependency and integration/project versions (manifest.json and pyproject.toml), and changes async_remove_config_entry_device to derive the node MAC from device identifiers, call unregister_node(mac), log NodeError as a warning while allowing registry removal, or return False if no removable identifier is found. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant HA as Home Assistant
participant Int as plugwise_usb integration
participant Lib as plugwise-usb library
HA->>Int: async_remove_config_entry_device(device_entry)
Int->>Int: inspect device_entry.identifiers\nfind first DOMAIN id not in {mac_stick, mac_coordinator}
alt found removable identifier
Int->>Lib: unregister_node(mac)
alt success
Lib-->>Int: success
Int-->>HA: return True (allow removal)
else NodeError
Lib--x Int: raises NodeError
Note right of Int #FFF3CD: log warning\nreturn True (allow removal)
end
else no removable identifier
Int-->>HA: return False (prevent removal)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
custom_components/plugwise_usb/__init__.py (1)
182-199: Fix undefinedidentifierand correctly extract MACIn
custom_components/plugwise_usb/__init__.pyat lines 182–199, the comprehension variableidentifierdoes not leak into the outer scope, leading to a NameError and preventing any device removal. Replace the block so it:
- Uses a local name (e.g.
id_) in the any()/next() comprehensions- Determines removability by checking against
api_stick.mac_stickandapi_stick.mac_coordinator- Extracts
macvianext((id_[1] for id_ in device_entry.identifiers if id_[0] == DOMAIN), None), logs and returns False if missing- Calls
await api_stick.unregister_node(mac), catching bothNodeErrorandStickError
🧹 Nitpick comments (1)
CHANGELOG.md (1)
5-9: Changelog entry OK; add release line on tag“Ongoing” section is fine during development. On release, add a dated “v0.55.11 - 2025-08-31” header above and move these bullets under it for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
CHANGELOG.md(1 hunks)custom_components/plugwise_usb/__init__.py(1 hunks)custom_components/plugwise_usb/manifest.json(1 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
custom_components/plugwise_usb/__init__.py
189-189: Undefined name identifier
(F821)
🔇 Additional comments (1)
custom_components/plugwise_usb/manifest.json (1)
12-12: Pin bumped to plugwise-usb 0.44.14 — verify availability and changelog alignmentLooks good. Please double-check that 0.44.14 is published and includes the device-removal fix referenced in this PR, and run hassfest after bumping to ensure manifest compliance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
custom_components/plugwise_usb/__init__.py (1)
191-195: Optionally also handle StickError on unregister to avoid blocking removal on USB issues
unregister_nodemay raise stick-level errors; aligning handling with other calls (e.g., set_energy_intervals) avoids blocking registry removal when the stick errors out.- except NodeError: - _LOGGER.warning("Plugwise node %s unregistering failed with NodeError", mac) + except (NodeError, StickError) as exc: + _LOGGER.warning("Plugwise node %s unregistering failed: %s", mac, exc) return True # Must return True for device_registry removal to happen!
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
custom_components/plugwise_usb/__init__.py(1 hunks)
🧰 Additional context used
🪛 Ruff (0.12.2)
custom_components/plugwise_usb/__init__.py
189-189: Undefined name identifier
(F821)
dirixmjm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't beat a good nights sleep!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
custom_components/plugwise_usb/__init__.py (1)
191-201: Simplify: computemacupfront and removeremovableflagCleaner control flow, avoids state coupling between
removableandmac.Alternative refactor:
- if removable: - try: - await api_stick.unregister_node(mac) - except NodeError as exc: - _LOGGER.warning("Plugwise node %s unregistering failed: %s", mac, exc) - return True # Must return True for device_registry removal to happen! - - _LOGGER.debug("Plugwise device %s successfully removed", mac) - return True - - return False + mac = next( + ( + id_[1] + for id_ in device_entry.identifiers + if id_[0] == DOMAIN + and id_[1] not in {str(api_stick.mac_stick), str(api_stick.mac_coordinator)} + ), + None, + ) + if not mac: + return False + try: + await api_stick.unregister_node(mac) + except NodeError as exc: + _LOGGER.warning("Plugwise node %s unregistering failed: %s", mac, exc) + return True # Must return True for device registry removal to happen! + _LOGGER.debug("Plugwise device %s successfully removed", mac) + return True
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
custom_components/plugwise_usb/__init__.py(1 hunks)custom_components/plugwise_usb/manifest.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- custom_components/plugwise_usb/manifest.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Setup for HA-core (release/master)
🔇 Additional comments (1)
custom_components/plugwise_usb/__init__.py (1)
194-196: Confirm exception coverage forunregister_nodein 0.44.14If
unregister_nodecan also raiseStickError(transport/USB issues), we should catch it similarly to ensure device-registry removal proceeds for dead devices.Would you confirm from plugwise-usb v0.44.14 docs/impl whether
unregister_nodemay raiseStickError? If yes, extend the except clause to(NodeError, StickError).
1b4f1b4 to
9866171
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
custom_components/plugwise_usb/__init__.py (1)
182-191: Identifier-based MAC selection looks correct; add mac initialization to avoid “possibly undefined” and improve readabilityInitialize
macbefore the loop to satisfy linters/type-checkers and make intent explicit. Optionally unpack the identifier tuple for clarity.- removable = False - for identifier in device_entry.identifiers: + removable = False + mac = None + for identifier in device_entry.identifiers: if ( identifier[0] == DOMAIN and identifier[1] not in (str(api_stick.mac_stick), str(api_stick.mac_coordinator)) ): mac = identifier[1] removable = True break
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
custom_components/plugwise_usb/__init__.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Setup for HA-core (release/master)
the device might only exist in HA
e2fd467 to
3784155
Compare
8242a73 to
f172dbc
Compare
|



This should fix the failure of deleting a dead device.
Summary by CodeRabbit
Bug Fixes
Chores
Documentation