Skip to content

feat(v1): expose DND action flags from get_dnd_timer - #1087

Open
hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/feat/dnd-action-readback
Open

hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/feat/dnd-action-readback

Conversation

@hCoureau

Copy link
Copy Markdown
Contributor

What

get_dnd_timer replies can include an actions object with the per-option DND flags (resume, vol, led, dust, dry), but DnDTimer dropped it on parse. This adds:

  • DnDTimerActions(RoborockBase) with the five flags, kept as the raw int | None values the device reports (1 = option enabled during DND, 0 = disabled).
  • An optional DnDTimer.actions: DnDTimerActions | None = None field, which also surfaces as DoNotDisturbTrait.actions.

Why

Consumers can see which DND options are active (quieten voice, dim lights, disable auto-empty and so on) without making a separate request. This is read-only. set_dnd_timer/enable still send as_list() ([start_hour, start_minute, end_hour, end_minute]), so the write path is unchanged.

Compatibility

The new field is appended last with a None default. Existing keyword or positional construction of DnDTimer still works, and replies without actions parse to actions=None. The only snapshot change is the extra actions=None in the DoNotDisturbTrait repr.

Testing

  • tests/devices/traits/v1/test_dnd.py: new parametrized test_get_dnd_timer_actions that refreshes the trait from get_dnd_timer replies with several action-flag combinations, plus a reply with no actions. The reply shape follows a Qrevo 2 Pro (roborock.vacuum.a294) response, as noted in the test. sample_dnd_timer now carries actions, so the existing set_dnd_timer test also confirms the flags are left out of the write params.
  • uv run ruff check, uv run ruff format --check, uv run mypy roborock tests (only the existing tests/map/test_b01_q10_render.py:502 error, also on main), and uv run pytest -n auto: 2821 passed, 46 xfailed.

🤖 Generated with Claude Code

get_dnd_timer replies can include an actions object (resume, vol, led,
dust, dry) that DnDTimer dropped. Keep it as DnDTimerActions with the
reported integer values; the timer setters are unchanged.
@hCoureau
hCoureau force-pushed the submit/feat/dnd-action-readback branch from 1afa31b to 6bb585e Compare November 23, 2026 23:28
class DnDTimerActions(RoborockBase):
"""Action flags reported with the DND timer, kept as the raw integers."""

resume: int | None = None

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.

Can we expose these as booleans?

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Automated code review by Claude Opus 5.5 in Claude Code using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).

Summary

Reviewed 6bb585e. The PR is small and well scoped. It is read-only, the write path (as_list()) is unchanged, and the protocol claims match the Roborock app. The one blocker is the maintainer's open "changes requested" review asking for the flags to be booleans, which has not been addressed yet.

Verdict: Does not pass /review.

Protocol claims checked against the decompiled app (RR_API, Qrevo 2 Pro Series bundle, hermes/no_package/Qrevo 2 Pro Series/output/):

  • get_dnd_timer returns result[0] with start_hour / start_minute / end_hour / end_minute plus a nested actions object. Confirmed: module_3665.js:1427-1449 reads r1.result[0], then actions.resume/vol/led/dust/dry.
  • The field names are resume, vol, led, dust and dry. Confirmed: module_3665.js:296 (default state) and :462-503 (settings list keys).
  • Their meanings. Confirmed by the strings in module_1519.js that those keys use (localization_strings_Setting_DoNotDisturbPage_3..7): resume is "Disable Auto Top-up", vol is "Quieten Voice Alerts", led is "Dim Indicator Lights", dust is "Disable Auto Emptying" and dry is "Disable Auto Drying". The docstrings match.
  • The values are 0/1 (1 means the option is on during DND). Confirmed: module_3665.js:640-672 builds each flag as 0 or 1 before set_dnd_timer_actions (module_441.js:2991).
  • The app only parses actions when isSupportCustomDnd() is true (module_3665.js:1431). The PR keeps the field optional and ungated for read-only decoding, which fits the skill's "avoid over-gating telemetry" rule. Nothing to change.

Priority 1: Public Trait APIs & Consumer Contracts

  1. roborock/data/v1/v1_containers.py:285-294: expose the flags as bool | None, not raw int | None (blocking, maintainer request). allenporter's review asks for booleans. With raw ints, every consumer has to write == 1, and the trait leaks the wire encoding through its public API. The ints carry nothing beyond on/off: the app only ever writes 0 or 1. RoborockBase.from_dict already turns 1 into True for a bool field, so no custom parsing is needed:
    -    resume: int | None = None
    +    resume: bool | None = None
    Make the same change for vol, led, dust and dry, and update the docstrings ("True when ...") and the expected values in tests/devices/traits/v1/test_dnd.py (DnDTimerActions(resume=True, vol=True, ...)). Then update the class docstring "kept as the raw integers" and the commit body to match.

Tests & PR hygiene

  • Tests sit in the mirror suite, are parametrized and use the shared mock_rpc_channel fixture. Nothing to add.
  • Local run on 6bb585e: pytest 2821 passed, 46 xfailed. ruff check is clean. mypy shows only errors that are already on main or come from the environment (tests/map/test_b01_q10_render.py:502, plus missing stubs). CI is green, and the PR merges cleanly with main.

This is an automated review and can be incorrect, so please reply if any finding looks wrong.

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

/review run Code review skill (/review) has been run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants