-
-
Notifications
You must be signed in to change notification settings - Fork 80
Handle numeric manufacturer on HassDevice Deserialization #1348
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
Handle numeric manufacturer on HassDevice Deserialization #1348
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1348 +/- ##
====================================
- Coverage 82% 82% -1%
====================================
Files 198 199 +1
Lines 3892 3909 +17
Branches 438 443 +5
====================================
+ Hits 3207 3216 +9
- Misses 517 523 +6
- Partials 168 170 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR fixes deserialization issues when Home Assistant devices have numeric values for string properties like manufacturer, ID, area_id, and labels. It introduces a new EnsureArrayOfStringConverter to handle array properties that may contain mixed string/numeric values.
- Added
EnsureArrayOfStringConverterto handle arrays with mixed string/numeric elements - Applied
EnsureStringConverterto all string properties inHassDevicefor consistency - Applied
EnsureArrayOfStringConverterto theLabelsproperty - Updated tests to verify numeric manufacturer and mixed-type labels are properly converted
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Client/NetDaemon.HassClient/Internal/Json/EnsureArrayOfStringConverter.cs |
New JSON converter that handles arrays of strings/numbers and single values, converting everything to string lists |
src/Client/NetDaemon.HassClient/Common/HomeAssistant/Model/HassDevice.cs |
Applied converters to all string and string array properties; reformatted for consistency with attributes on separate lines |
src/Client/NetDaemon.HassClient.Tests/Json/HassDeviceConverterTests.cs |
Enhanced tests to verify numeric manufacturer and mixed-type labels are properly deserialized to strings |
Breaking change
Proposed change
Fix deserialzing devices that have a numeric manufacturer
Type of change
Additional information
Checklist
If user exposed functionality or configuration are added/changed: