feat: fix a01 and b01 response handling in new api#453
feat: fix a01 and b01 response handling in new api#453allenporter merged 6 commits intoPython-roborock:mainfrom
Conversation
ea1587b to
7a2b8e2
Compare
| if not finished.is_set(): | ||
| finished.set() | ||
|
|
||
| unsub = await mqtt_channel.subscribe(find_response) |
There was a problem hiding this comment.
Okay maybe i'm just getting confused by the asyncness and maybe that is leading to my confusion with the returns above as well.
My first thought when I was reading this was that we are adding a subscription everytime that we send a message. Then when a message goes through, we are going through all of the subscriptions and if they aren't a match, we end up returning None on them.
However, looking at it, it seems that subscribe holds exactly one callback, so if I had three different send_commands I wanted to send at once - wouldn't that override the subscription callback for each one? Or does the lock within roborock_session prevent that - if that's the case, doesn't that dramatically increase the amount of time that I will be waiting to get a response?
Maybe it's okay, as if you are using the api correctly, all IDs that you are querying should be done with one function call - but there could be commands that we don't utilize in A01 that should have responses as well
There was a problem hiding this comment.
You're right, the code I was using for mqtt session changed a bunch of times, but i reverted it for this PR.
The intent was to use a version that allowed any number of callbacks. I think a version fo this was reverted so this no longer makes sense.
There was a problem hiding this comment.
Updated this to remove the limitation of a single subscribe call for the mqtt channel. This matches the behavior of local channel.
This builds on #452 by removing additional response decoding in
RoborockMessage, separating out the different protocols better. This now has separate RPC logic for a01, b01, and v1. This removes thePendingRpcabstraction that was just added since it is no longer necessary since we can handle all responses within a single function call using a subscribe callback.