Skip to content
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

Fix protocol freezes due to sequence id #813

Open
AlexxIT opened this issue Sep 9, 2020 · 1 comment
Open

Fix protocol freezes due to sequence id #813

AlexxIT opened this issue Sep 9, 2020 · 1 comment
Labels

Comments

@AlexxIT
Copy link

AlexxIT commented Sep 9, 2020

I am developing a component for integrating Xiaomi Gateway 3 and understood how sequence id (start_id and _id) works.

I think the problem does not concern only Gateway, but applies to all devices with the miio protocol.

If the device receives the same sequence id in a short time, it will not respond to the request. Device remembers the last few sequence id and therefore increasing the value by 100 does not fix problem. Setting start_id = 1000 or any other value will not help either. 1000, 1100, 1200... Chances are very high that the numbers are repeated. It happens when Home Assistant restarts frequently.

The mobile application (Mi Home) also maintains its own counter from 0 and they overlap each other. As a result, both the mobile application and the Home Assistant component are freezes.

There are two ways out:

  1. Bind start_id to time. For example, the number of seconds from the beginning of the hour. But then the two versions of the component can interfere with each other.

  2. Add random to the start value. And random when an error occurs. At the same time, increase the maximum sequence to a million from 9999. The Gateway is doing fine. I do not know how other devices will behave.

I chose the second option. The code can be viewed here.

@AlexxIT AlexxIT added the bug label Sep 9, 2020
@fs79
Copy link
Contributor

fs79 commented Sep 13, 2020

Hi @AlexxIT ,

I´m using the Xiaomi Mi Robot Mop Pro which behaves not stable when I send commands via cli.
Takes ages that commands are executed. Sometimes its fast.
Could be the same cause you try to fix.

I think the problem does not concern only Gateway, but applies to all devices with the miio protocol.

How can I try to use this fix for "viomivacuum" type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants