Skip to content

fix(v1): refresh status after fan or water pushes - #1067

Open
infy1995 wants to merge 5 commits into
Python-roborock:mainfrom
infy1995:claude/v1-push-refresh
Open

infy1995 wants to merge 5 commits into
Python-roborock:mainfrom
infy1995:claude/v1-push-refresh

Conversation

@infy1995

Copy link
Copy Markdown
Contributor

What

Two fixes for how V1 data protocol pushes update the status trait:

  1. On water-slide devices, a pushed water_box_mode that the slider cannot name is ignored. The robot pushes the old level codes (201/202/203, and 208 for the top of the slider), while get_status returns slider codes (200, 221-250). Storing the pushed code left water_mode_name as None ("unknown") until the next poll. Codes 200, 204, 209 and 221-250 are still applied, and devices without a water slider are unchanged.
  2. After a push that contains fan_power or water_box_mode, PropertiesApi reads the status back once, about one second later (StatusTrait.refresh_and_notify()). Status listeners are notified only if the status changed. This corrects the water level and mop_mode shortly after a mode change made elsewhere (for example leaving SmartPlan or switching vacuum and mop to vacuum), which mop_mode never gets from a push.

Why

Measured on a Saros 10R: after changing water in the Roborock app, Home Assistant showed "unknown" for a few seconds, and the cleaning mode stayed stale after a mode change. Push log: 124=202 was followed by a get_status that returned 235, 124=203 by 246.

Behavior notes

  • At most one read-back per one-second window: pushes inside the window share it, and a push that arrives during a running read-back schedules another. Pushes without fan_power or water_box_mode cause no request.
  • PropertiesApi.close() cancels pending and running read-backs. A RoborockException from the read-back is logged and does not stop later ones.
  • A response that is already in flight can briefly overwrite a newer pushed value; the scheduled follow-up read-back corrects it.
  • A change of only the mop route is never pushed by the robot, so route-only changes still wait for the client's next poll.
  • New tests are in tests/devices/traits/v1/test_status.py and in tests/devices/traits/v1/test_init.py (new, the mirror file for traits/v1/__init__.py; nothing covered the push handler before).

Conflicts with open PRs

Test-merged with every open PR that touches the same files:

Checks

uv run pre-commit run --all-files (ruff, mypy, codespell) passes, and tests/devices passes (961 tests).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant