-
-
Notifications
You must be signed in to change notification settings - Fork 76
Fix DeviceInfo round-trip serialization after areas/devices fields additions #1229
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1229 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 2965 2970 +5
=========================================
+ Hits 2965 2970 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #1229 will not alter performanceComparing Summary
|
Caution Review failedThe pull request is closed. """ WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DeviceInfo
participant AreaInfo
User->>DeviceInfo: Create from dict (with area field)
DeviceInfo->>AreaInfo: AreaInfo.convert(value)
alt value is dict
AreaInfo->>AreaInfo: from_dict(value)
else value is protobuf
AreaInfo->>AreaInfo: from_pb(value)
end
AreaInfo-->>DeviceInfo: AreaInfo instance
DeviceInfo-->>User: DeviceInfo instance with area
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✨ Finishing Touches
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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
What does this implement/fix?
This PR fixes an issue with
DeviceInfo
round-trip serialization that was introduced when theareas
,devices
, andarea
fields were added in #1146.When using
DeviceInfo.to_dict()
followed by creating a newDeviceInfo
instance from that dictionary (a common pattern for mocking in tests), the code would fail with anAttributeError
because thearea
field converter expected a protobuf object but received a dictionary.The fix adds a
convert
method toAreaInfo
that properly handles both dictionary and protobuf inputs, similar to how theconvert_list
methods already work for the list fields.Types of changes
Related issue or feature (if applicable):
Pull request in esphome (if applicable):
Checklist:
tests/
folder).