8000 feat: Update device manager and device to establish an MQTT subscription by allenporter · Pull Request #409 · Python-roborock/python-roborock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Update device manager and device to establish an MQTT subscription #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

allenporter
Copy link
Contributor
@allenporter allenporter commented Jul 1, 2025

Update the device manager and device to establish an Mqtt "channel" which is the device-specific subscription in the mqtt session. The channel will be used for decoding messages and sending/receiving RPCs.

Lots of future work needed here including:

  • Handle non-mqtt devices
  • Add message decoding
  • Add message encoding and receiving of RPCs
  • Local connections

@allenporter allenporter marked this pull request as draft July 1, 2025 15:33
@allenporter allenporter marked this pull request as ready for review July 2, 2025 05:01
@allenporter allenporter requested review from Copilot and Lash-L July 2, 2025 05:09
Copy link
@Copilot 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

Adds MQTT subscription support per device by introducing an MQTT “channel” abstraction, integrating it into both the device manager and individual device objects, and updating the CLI to leverage the new manager.

  • Introduce MqttChannel for subscribing/unsubscribing to device-specific topics
  • Wire up MQTT sessions in DeviceManager and RoborockDevice to manage connections and clean up on close
  • Refactor the CLI to use create_device_manager and ensure graceful shutdown of MQTT

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/devices/test_mqtt_channel.py Add tests for MqttChannel.subscribe behavior
tests/devices/test_device_manager.py Ensure close() is called on the manager in tests
tests/devices/test_device.py Test RoborockDevice.connect / close integration with channel
roborock/devices/mqtt_channel.py New class to wrap MQTT subscribe/unsubscribe for a device
roborock/devices/device_manager.py Pass through MQTT session, establish channels on discovery, add close()
roborock/devices/device.py Add connect/close methods to manage MQTT subscriptions
roborock/cli.py Refactor CLI to use create_device_manager and clean shutdown
Comments suppressed due to low confidence (2)

roborock/devices/device_manager.py:96

  • The constructor for RoborockApiClient originally accepted (email, user_data). Confirm that dropping user_data matches the new API signature or update accordingly.
    client = RoborockApiClient(email)

tests/devices/test_mqtt_channel.py:47

  • Add a test case to verify that calling subscribe twice raises the expected ValueError when already subscribed, as described in the method docstring.
async def test_mqtt_channel() -> None:

roborock/devices/mqtt_channel.py Outdated Show resolved Hide resolved
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
0