Overhaul Roborock integration to use new devices based API#154837
Overhaul Roborock integration to use new devices based API#154837edenhaus merged 23 commits intohome-assistant:devfrom
Conversation
|
Hey there @Lash-L, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Roborock integration to use a new device-based API architecture, replacing the older coordinator and entity patterns with a more modern trait-based approach.
- Introduces new device manager and properties API structure
- Migrates from old coordinator patterns to new trait-based device interactions
- Replaces manual API calls with structured device properties and commands
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| homeassistant/components/roborock/init.py | Replaced old device setup with new device manager pattern |
| homeassistant/components/roborock/coordinator.py | Overhauled coordinator architecture with new trait-based API |
| homeassistant/components/roborock/vacuum.py | Updated vacuum entity to use new coordinator and device patterns |
| homeassistant/components/roborock/sensor.py | Migrated sensor entities to new coordinator structure |
| homeassistant/components/roborock/switch.py | Converted to trait-based switch implementations |
| homeassistant/components/roborock/time.py | Updated time entities to use trait-based patterns |
| homeassistant/components/roborock/number.py | Migrated number entities to new trait system |
| homeassistant/components/roborock/button.py | Updated button entities with new consumable trait approach |
| homeassistant/components/roborock/image.py | Simplified image entity to use new coordinator pattern |
| homeassistant/components/roborock/entity.py | Removed old entity base classes (no longer needed) |
| tests/components/roborock/conftest.py | Overhauled test fixtures to support new device structure |
| tests/components/roborock/test_*.py | Updated all test files to use new fake device patterns |
|
Because of the drastic changes in how we are communicating, I think we should close out all connection based issues. especially as these changes should help communication and recovery. Maybe you disagree, so lmk what you think In my opinion these should be closed by this pr (some of these have had partial fixes in the past, but users have had connection issues and the issues have remained open) |
This is a breaking change that required these changes: - Importing containers and data - Changes to some dataclass computed values This is also required for home-assistant#154837 which will switch to another API within the same library.
a79a094 to
a6c9429
Compare
Fix is cleaning Update images reorder setup functions Revert coordinator and entity inheritance changes Revert device changes Revert some changes to reduce diffs Revert changes in switch Revert time entity changes Update coordinator and fix image and select tests Update to new import paths Update to new import locations Update image tests Update binary sensor tests Update clean summary and remove unnecessary waits Make more init tests pass Update sensor and select tests and many coordinator improvements Use new diagnostics api Fix unique device identifiers in tests Remove _get_update_interval Fix room sensor test Update TODOs Refresh status before attempting home discovery Refresh all traits in coordinator Update coordinator behavior to handle busy device Add back partial failure behavior Remove todo and replace with create_home_data_from_api_client Reduce unnecessary diffs and improve failure handling Remove async-timeout forbidden package
2c537e0 to
ebad652
Compare
edenhaus
left a comment
There was a problem hiding this comment.
Thanks @allenporter 👍
Some small suggestions that can be discussed in follow ups/Discord.
| @@ -341,3 +246,5 @@ async def async_unload_entry(hass: HomeAssistant, entry: RoborockConfigEntry) -> | |||
| async def async_remove_entry(hass: HomeAssistant, entry: RoborockConfigEntry) -> None: | |||
| """Handle removal of an entry.""" | |||
| await async_remove_map_storage(hass, entry.entry_id) | |||
There was a problem hiding this comment.
As we don't use the old format anymore, should we remove it in a config entry migration instead?
In my opinion, this would be cleaner, and we could even remove old data, as I don't expect that any current user will remove the config entry soon
| return self._devices | ||
|
|
||
|
|
||
| def make_fake_switch(obj: Any) -> Any: |
There was a problem hiding this comment.
I don't like the Any here and in the other functions, as it makes it hard for others to know which functions/attributes the object should have
|
|
||
| def create_v1_properties(network_info: NetworkInfo) -> Mock: | ||
| """Create v1 properties for each fake device.""" | ||
| v1_properties = Mock() |
There was a problem hiding this comment.
Can we set the spec to the specific object?
Proposed change
This is a large PR rewriting the integration and is a work in progress. This is expected to improve reliability since it uses a single MQTT session for all devices, and improves startup time by caching connection information so that we can connect to devices locally without hitting the cloud at all.
This moves a significant portion of the integration code behind the API boundary, reducing the amount of protocol specific details in the integration. This PR attempts to minimize diffs where possible, leaving some opportunities for future cleanup to reduce the amount of integration code further.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: