fix: avoid START_PAUSE overwriting return/start on shared DPS models#486
Open
Z3R0-DB wants to merge 1 commit into
Open
fix: avoid START_PAUSE overwriting return/start on shared DPS models#486Z3R0-DB wants to merge 1 commit into
Z3R0-DB wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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_PAUSEto the payload when it shares a DPS code withRETURN_HOMEorMODE, 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()andasync_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="}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.