Skip to content

fix: avoid START_PAUSE overwriting return/start on shared DPS models#486

Open
Z3R0-DB wants to merge 1 commit into
damacus:mainfrom
Z3R0-DB:Fix/t2277-shared-dps-return-home
Open

fix: avoid START_PAUSE overwriting return/start on shared DPS models#486
Z3R0-DB wants to merge 1 commit into
damacus:mainfrom
Z3R0-DB:Fix/t2277-shared-dps-return-home

Conversation

@Z3R0-DB
Copy link
Copy Markdown

@Z3R0-DB Z3R0-DB commented May 26, 2026

Summary
This fixes a payload collision for models where START_PAUSE shares the same DPS code as MODE or RETURN_HOME (notably T2277).

When the vacuum is paused, pressing Return Home (and therefore Stop, which calls Return Home) could resume cleaning instead of returning to dock.

Root cause
In vacuum.py:878 and vacuum.py:902, command payloads appended START_PAUSE unconditionally when a non-default start value existed.

For T2277, START_PAUSE and RETURN_HOME both use DPS 152, so adding START_PAUSE overwrote the already-built return-home payload key, turning a return action into resume.

Changes

Guarded START_PAUSE append in return-to-base flow so it is only added when START_PAUSE DPS code differs from RETURN_HOME DPS code.
Applied the same guard in start flow so START_PAUSE does not overwrite MODE when they share a DPS code.
Added regression tests for T2277 shared-DPS behavior:
test_vacuum_commands.py:118 verifies async_return_to_base keeps payload 152: AggG.
test_vacuum_commands.py:144 verifies async_start keeps payload 152: BBoCCAE=.
Validation

python -m pytest test_vacuum_commands.py -q
Result: 15 passed
python -m pytest test_t2277_command_mappings.py -q
Result: 20 passed
Impact
This preserves existing behavior for boolean-toggle models that use separate START_PAUSE DPS codes, while fixing resume-on-return regressions for shared-DPS models.

Copilot AI review requested due to automatic review settings May 26, 2026 04:36
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR prevents command payloads from being unintentionally overwritten when multiple RoboVac commands share the same Tuya DPS code (notably on model T2277), and adds regression tests to lock in the behavior.

Changes:

  • Avoid adding START_PAUSE to the payload when it shares a DPS code with RETURN_HOME or MODE, preventing the later assignment from overwriting the intended command.
  • Add async tests verifying the correct single-field payload is sent for async_return_to_base() and async_start() on T2277.

Reviewed changes

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

File Description
custom_components/robovac/vacuum.py Skips START_PAUSE in combined payloads when it would overwrite RETURN_HOME/MODE due to shared DPS codes.
tests/test_vacuum/test_vacuum_commands.py Adds regression tests ensuring the payload isn’t overwritten on shared-DPS models (T2277).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +878 to +882
return_home_code = self.get_dps_code("RETURN_HOME")
start_pause_code = self.get_dps_code("START_PAUSE")
start_value = self.vacuum.getRoboVacCommandValue(RobovacCommand.START_PAUSE, "start")
if start_value != "start":
payload[self.get_dps_code("START_PAUSE")] = start_value
if start_value != "start" and start_pause_code != return_home_code:
payload[start_pause_code] = start_value
Comment on lines +902 to +906
mode_code = self.get_dps_code("MODE")
start_pause_code = self.get_dps_code("START_PAUSE")
start_value = self.vacuum.getRoboVacCommandValue(RobovacCommand.START_PAUSE, "start")
if start_value != "start":
payload[self.get_dps_code("START_PAUSE")] = start_value
if start_value != "start" and start_pause_code != mode_code:
payload[start_pause_code] = start_value
entity = RoboVacEntity(model_data)
await entity.async_return_to_base()

robovac.async_set.assert_called_once_with({"152": "AggG"})
entity = RoboVacEntity(model_data)
await entity.async_start()

robovac.async_set.assert_called_once_with({"152": "BBoCCAE="})
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.

2 participants