Skip to content

Add sensor entities for Roborock q10 s5+#166120

Merged
lboue merged 61 commits intohome-assistant:devfrom
lboue:feat/roborock-q10-s5-plus-vacuum-sensors
Apr 6, 2026
Merged

Add sensor entities for Roborock q10 s5+#166120
lboue merged 61 commits intohome-assistant:devfrom
lboue:feat/roborock-q10-s5-plus-vacuum-sensors

Conversation

@lboue
Copy link
Copy Markdown
Contributor

@lboue lboue commented Mar 21, 2026

Proposed change

Expands sensor coverage for Roborock Q10 devices (B01 protocol) by exposing all status fields available in python-roborock 4.26.3.

New sensor entities per Q10 device:

Sensor Translation key Unit
Status status enum
Battery %
Cleaning time cleaning_time s
Cleaning area cleaning_area
Main brush time used main_brush_life h
Side brush time used side_brush_life h
Filter time used filter_life h
Sensor time used sensor_life h
Total cleaning area total_cleaning_area
Total cleaning time total_cleaning_time min
Total cleaning count total_cleaning_count
Cleaning progress clean_percent %

Implementation notes:

  • Coordinator: RoborockB01Q10UpdateCoordinator._async_update_data simply calls await self.api.refresh() (fire-and-forget). Q10 is push-based: entities are registered unconditionally and their state is populated as MQTT push updates arrive.
  • Status enum: The Q10 status sensor reuses the existing status translation key — all YXDeviceState values produced by the Q10 are a subset of the states already defined there, so no dedicated key is needed.
  • Consumable sensors (*_life): The device reports hours of usage (e.g. dpMainBrushLife: 81 = 81 h used), not a remaining-life percentage. These sensors are modelled as SensorDeviceClass.DURATION with native_unit_of_measurement=UnitOfTime.HOURS.

Type of change

  • New feature (which adds functionality to an existing integration)

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

lboue and others added 4 commits March 21, 2026 12:40
Add new sensor entities for Roborock Q10 devices:
- main_brush_life, side_brush_life, filter_life, sensor_life (remaining %)
- total_cleaning_area, total_cleaning_time, total_cleaning_count
- clean_percent (current cleaning progress)

Also wait for the first MQTT push during coordinator setup so that sensor
state is populated immediately after async_config_entry_first_refresh,
consistent with V1/Q7 coordinator behavior. A 10s timeout handles the
offline case gracefully.

Update conftest mock to trigger status listeners on refresh() so tests
resolve instantly without timeout.
@home-assistant
Copy link
Copy Markdown

Hey there @Lash-L, @allenporter, mind taking a look at this pull request as it has been labeled with an integration (roborock) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of roborock can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign roborock Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands the Roborock integration’s Q10 (B01 protocol) support by adding additional diagnostic sensor entities backed by python-roborock’s newly exposed Q10 status fields, and adjusts the Q10 coordinator’s first refresh behavior to wait for an initial MQTT push so entities can start with populated status where possible.

Changes:

  • Add Q10-specific sensor descriptions/entities for consumables life and cleaning totals/progress.
  • Update the Q10 coordinator to wait (with timeout) for the first push update during the initial refresh.
  • Extend translations and test fixtures/snapshots to cover the new Q10 sensors.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
homeassistant/components/roborock/coordinator.py Waits for initial Q10 MQTT push on first refresh (with timeout) to improve startup state population.
homeassistant/components/roborock/sensor.py Introduces Q10 sensor entity definitions and registers them for Q10 coordinators.
homeassistant/components/roborock/strings.json Adds translation strings for new Q10 sensor names and additional Q10 status enum values.
tests/components/roborock/conftest.py Adjusts Q10 trait mocking to simulate an immediate push update during refresh in tests.
tests/components/roborock/test_init.py Updates expected device entity sets to include Q10 sensor entities.
tests/components/roborock/snapshots/test_sensor.ambr Updates sensor registry/state snapshots to include the new Q10 sensors.

Comment thread homeassistant/components/roborock/coordinator.py Outdated
Comment thread homeassistant/components/roborock/coordinator.py Outdated
Comment thread homeassistant/components/roborock/sensor.py Outdated
Comment thread homeassistant/components/roborock/coordinator.py Outdated
lboue and others added 2 commits March 21, 2026 20:09
Adds icons for the following entities:
- battery: Battery level indicator
- cleaning_time: Current cleaning time
- mop_clean_remaining: Remaining mop drying time
- brush_remaining: Remaining brush time (DYAD)
- main_brush_life: Main brush life percentage (Q10)
- side_brush_life: Side brush life percentage (Q10)
- filter_life: Filter life percentage (Q10)
- sensor_life: Sensor life percentage (Q10)
- mop_life_time_left: Mop lifetime remaining (B01)
- times_after_clean: Total cleaning count (ZEO)
- q7_status: Q7 device status (B01)
Copilot AI review requested due to automatic review settings March 21, 2026 19:27
lboue added 2 commits March 21, 2026 20:28
Stop waiting for an arbitrary first MQTT status message in the Q10
coordinator initial refresh path, and keep Q10 sensors registered
unconditionally with push-based updates as values arrive.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

homeassistant/components/roborock/coordinator.py:631

  • The first-refresh wait uses a hard-coded 10 second timeout. Please replace this with a named constant (ideally alongside the existing interval constants) so it’s easier to tune and understand, and so the same value can be reused consistently in tests/docs.
        """Get the unique id of the device as specified by Roborock."""
        return self._device.duid

    @cached_property
    def duid_slug(self) -> str:
        """Get the slug of the duid."""
        return slugify(self.duid)

homeassistant/components/roborock/coordinator.py:621

  • This comment mentions waiting so that “sensor value_fn filters work correctly at setup time”, but Q10 sensors are now registered unconditionally (no value_fn filtering). Consider updating the comment to reflect the current motivation (e.g., ensuring the initial Q10 status is populated for entities like the vacuum/status enum), to avoid future confusion.
                translation_domain=DOMAIN,
                translation_key="request_fail",
            ) from ex

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread homeassistant/components/roborock/coordinator.py
Comment thread homeassistant/components/roborock/sensor.py Outdated
Comment thread tests/components/roborock/conftest.py Outdated
Comment thread homeassistant/components/roborock/icons.json Outdated
@lboue lboue requested a review from allenporter March 21, 2026 21:29
@lboue lboue marked this pull request as ready for review March 21, 2026 21:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@lboue lboue marked this pull request as ready for review April 3, 2026 20:59
@home-assistant home-assistant bot requested a review from allenporter April 3, 2026 20:59
"default": "mdi:brush"
},
"cleaning_time": {
"default": "mdi:clock-outline"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you decide between mdi:brush vs mdi:clock-outline here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duration of the last cleaning depends on the vacuum cleaner as a whole, not just the brush.

Comment thread homeassistant/components/roborock/strings.json Outdated
Comment thread tests/components/roborock/conftest.py Outdated
Comment thread tests/components/roborock/conftest.py Outdated
@home-assistant home-assistant bot marked this pull request as draft April 5, 2026 05:28
Luligu added 4 commits April 6, 2026 14:39
The previous refresh_side_effect did a circular DPS round-trip (reading
existing properties, converting to DPS, then re-applying the same values)
that served no purpose — no test asserted any state change from it.
All Q10 status states are a subset of those already defined in the
`status` translation key, so there's no need for a separate `q10_status`
key in strings.json and icons.json.
The *_life sensors (main_brush_life, side_brush_life, filter_life,
sensor_life) report hours of usage, not a percentage. Update units to
UnitOfTime.HOURS with device_class DURATION, fix misleading names in
strings.json, and remove explicit icons so HA uses the DURATION default
(mdi:timer) to visually distinguish them from *_time_left sensors.
Add realistic mock values (in hours) for main_brush_life, side_brush_life,
filter_life and sensor_life matching real device data, so tests validate
actual sensor states instead of unknown.
Copilot AI review requested due to automatic review settings April 6, 2026 13:08
CLEAN_TIME is reported in seconds by the device (1812 = ~30 min).
Update native unit to seconds with suggested display in minutes.
Update mock value to 1800 s (30 min) to match real device data.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread homeassistant/components/roborock/sensor.py
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@lboue lboue marked this pull request as ready for review April 6, 2026 13:32
@home-assistant home-assistant bot requested a review from allenporter April 6, 2026 13:32
Comment thread homeassistant/components/roborock/icons.json Outdated
Copilot AI review requested due to automatic review settings April 6, 2026 14:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@lboue lboue merged commit 49f5557 into home-assistant:dev Apr 6, 2026
37 checks passed
@lboue lboue deleted the feat/roborock-q10-s5-plus-vacuum-sensors branch April 6, 2026 15:13
@github-actions github-actions bot locked and limited conversation to collaborators Apr 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants