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

Eliminate no delay writes #310

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Lurker00
Copy link

After reading your comment, I've analyzed the source code and found out, that:

I can understand a need for sending requests without a delay only in the case of subsequent requests with no delay between them. So, I'm confident that the first call can be performed with the delay. Moreover, it is exactly the call that caused me problems.

I don't quite understand if the second call to status() (several calls in the loop, actually) may need to have no delays in between. I doubt it. But I'm confident that the first write can be done without a delay. So, I introduced delay parameter to status(), and now it can be False only being called from detect_available_dps(). But I'd prefer to delete command_delay parameter from transport_write() as not actually used and as dangerous.

Forgetting about detect_available_dps(), now I'm confident that the heartbeat does not require additional synchronization before sending requests. But I delayed the first heartbeat to let LocalTuya start faster and smoother.

The 3rd commit (d1b07db) reverted traces of my experiment to ensure that status() is called only in two places: I've removed default parameters values to let python compiler to catch other calls, if any.

In brief:

  • The 1st commit (d2bf8ce) almost fixes my problem. I'm sure this line order is good anyway.
  • The 2nd commit (af1a73a) fixes my problem and reduces the chance of a similar problem in case of (rare?) user setup when detect_available_dps() is called periodically.
  • I prefer to eliminate command_delay parameter from transport_write() and then revert my second commit.

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.

None yet

1 participant