Raise an issue when the Roborock local api is unavailable.#154576
Raise an issue when the Roborock local api is unavailable.#154576allenporter merged 9 commits intohome-assistant:devfrom
Conversation
|
Hey there @allenporter, 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 raises a Repairs issue when the Roborock integration falls back to the cloud API, guiding users to adjust their network setup to enable local access.
- Add issue creation/deletion in the coordinator when local API fails/succeeds.
- Add localized strings for the new issue.
- Add tests verifying issue creation and cleanup when switching between cloud and local API.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| homeassistant/components/roborock/coordinator.py | Creates a Repairs issue when the integration uses the cloud API and deletes it when local API is reachable again. |
| homeassistant/components/roborock/strings.json | Adds title and description for the new Repairs issue. |
| tests/components/roborock/test_coordinator.py | Adds a test to assert issue creation for cloud fallback and removal after returning to local API. |
| with patch( | ||
| "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.ping", | ||
| side_effect=RoborockException(), | ||
| ): |
There was a problem hiding this comment.
RoborockLocalClientV1.ping is awaited in the coordinator; patching it without an AsyncMock can cause await errors. Use an AsyncMock for the side effect and import AsyncMock: with patch('homeassistant.components.roborock.coordinator.RoborockLocalClientV1.ping', new=AsyncMock(side_effect=RoborockException()))
| with patch( | ||
| "homeassistant.components.roborock.coordinator.RoborockLocalClientV1.ping" | ||
| ): |
There was a problem hiding this comment.
This patch replaces an awaited coroutine with a regular MagicMock, which will raise 'object MagicMock can't be used in 'await' expression'. Patch with an AsyncMock that returns None: with patch('homeassistant.components.roborock.coordinator.RoborockLocalClientV1.ping', new=AsyncMock(return_value=None))
There was a problem hiding this comment.
I don't think these are necessary, but if a core dev wants me to I will make these changes to AsyncMock
Co-authored-by: Josef Zweck <josef@zweck.dev>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
allenporter
left a comment
There was a problem hiding this comment.
This is a great change, thank you for doing this.
I think it would be useful to also have something in the integration documentation with additional detail about what this error means and how a user can fix it, since many users may not know practically what to do. Want to send a PR for that and add a more info link to the integration docs in the repair issue text?
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Co-authored-by: Allen Porter <allen.porter@gmail.com>
|
Almost certainly will conflict with #154837 |
Breaking change
Proposed change
Right now we simply put a warning in the logs. I think a lot of users miss this and leave their integration in a less than ideal state. This hopefully will make it clear to them that they should make changes to their networking setup.
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: