Skip to content

Conversation

@allenporter
Copy link
Contributor

@allenporter allenporter commented Dec 7, 2025

Update the a01 internal values to be json strings inside the dictionary. This matches the old API behavior.

Issue #623

Copilot AI review requested due to automatic review settings December 7, 2025 04:56
Copy link
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

This PR fixes the A01 protocol encoding to match the old API behavior by encoding all values as JSON strings. Previously, values were passed through as-is; now they are wrapped with json.dumps() to ensure protocol compatibility.

  • Applied json.dumps() to all values in the dps dictionary within encode_mqtt_payload()
  • Updated existing tests to expect JSON-stringified values
  • Added a new test to verify list values are properly encoded as strings

Reviewed changes

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

File Description
roborock/protocols/a01_protocol.py Modified encode_mqtt_payload() to apply json.dumps() to all values, converting them to JSON strings before encoding
tests/protocols/test_a01_protocol.py Updated test expectations to reflect JSON string encoding, added imports for manual payload decoding, and added new test case for list conversion

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

@Lash-L
Copy link
Collaborator

Lash-L commented Dec 7, 2025

Test are failing

Lash-L
Lash-L previously approved these changes Dec 7, 2025
@allenporter allenporter marked this pull request as draft December 7, 2025 18:14
@allenporter
Copy link
Contributor Author

I want to come back to this with better tests

Update the a01 internal values to be json strings inside the dictionary. This matches the old API behavior.
Copy link
Contributor Author

@allenporter allenporter left a comment

Choose a reason for hiding this comment

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

OK, tests are not updated to catch the bug.

(The original change added double encoding to the old API and the encoding was not tested)

@allenporter allenporter marked this pull request as ready for review December 7, 2025 18:33
@allenporter allenporter merged commit 7301a2a into Python-roborock:main Dec 7, 2025
7 checks passed
allenporter added a commit to allenporter/python-roborock that referenced this pull request Dec 7, 2025
The bug was introduced in Python-roborock#645.

Add tests that exercise the actual request encoding. This changes the ID QUERY value encoding by passing in a function, which is another variation on the first version of Python-roborock#645 where the json encoding happened inside the decode function.
allenporter added a commit that referenced this pull request Dec 8, 2025
* fix: Fix exception when sending dyad/zeo requests

The bug was introduced in #645.

Add tests that exercise the actual request encoding. This changes the ID QUERY value encoding by passing in a function, which is another variation on the first version of #645 where the json encoding happened inside the decode function.

* chore: fix tests to be focused on value encoder

* chore: fix lint
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