fix: Allow firmware version as an optional field#670
Merged
allenporter merged 2 commits intoPython-roborock:mainfrom Dec 14, 2025
Merged
fix: Allow firmware version as an optional field#670allenporter merged 2 commits intoPython-roborock:mainfrom
allenporter merged 2 commits intoPython-roborock:mainfrom
Conversation
This field may not be returned by the API, in particular when the device is offline.
```
2025-12-14 18:09:25.550 ERROR (MainThread) [roborock.data.containers] Failed to convert devices with value [{'duid': 'yyyyyy', 'name': 'S6 Pure', 'localKey': 'xxxxxx', 'productId': 'zzzzzz', 'activeTime': NNNNNNN, 'timeZoneId': 'Europe/Moscow', 'iconUrl': '', 'share': False, 'online': False, 'pv': '1.0', 'tuyaMigrated': False, 'extra': '{}', 'deviceStatus': {}, 'silentOtaSwitch': False, 'f': False}] to type list[roborock.data.containers.HomeDataDevice]
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/roborock/data/containers.py", line 122, in from_dict
result[key] = RoborockBase._convert_to_class_obj(field_type, value)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/roborock/data/containers.py", line 73, in _convert_to_class_obj
return [RoborockBase._convert_to_class_obj(sub_type, obj) for obj in value]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/roborock/data/containers.py", line 81, in _convert_to_class_obj
return class_type.from_dict(value)
~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/usr/local/lib/python3.13/site-packages/roborock/data/containers.py", line 127, in from_dict
return cls(**result)
TypeError: HomeDataDevice.__init__() missing 1 required positional argument: 'fv'
```
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a deserialization error that occurs when the Roborock API returns device data without a firmware version field, which typically happens when a device is offline. The change makes the fv (firmware version) field optional in the HomeDataDevice class.
Key Changes
- Made the
fvfield optional by adding a default value ofNoneand moving it after required fields in theHomeDataDevicedataclass - Updated test snapshots to reflect the field reordering in serialized output
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| roborock/data/containers.py | Changed fv field from required to optional with default None, moved after product_id to maintain proper dataclass field ordering |
| tests/devices/snapshots/test_file_cache.ambr | Updated snapshot expectations to reflect fv field position change in serialized HomeDataDevice objects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Lash-L
previously approved these changes
Dec 14, 2025
Collaborator
Lash-L
left a comment
There was a problem hiding this comment.
unexpected! definitely fine with this being option as we don't use it anyways in the library. We might use it on the HA side though. So this may require a change to check if it is None.
b3c6511 to
813d675
Compare
Lash-L
approved these changes
Dec 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This field may not be returned by the API, in particular when the device is offline.
Issue home-assistant/core#158918