-
Notifications
You must be signed in to change notification settings - Fork 4
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
⚡ Improve TP-Link driver interaction #86
Comments
I've tried several changes, none could make it respond faster. I've even seen the Python script experience the delays, so now I'm thinking the software in the dimmer is slow or just poorly written. |
The sequence numbers between the two are very different. This is because the driver first sends a "get info" command to the dimmer to get the current state. Getting the current state is usually a very fast operation. |
@Thomasdezeeuw, could this issue be caused by the |
It's hard to tell without knowing the code, but if you remove the following line: https://github.com/tokio-rs/tokio/blob/f8fe0ffb23c2279708cb5dada7c88defdae60845/tokio/src/io/poll_evented.rs#L210, you can test it |
I'll do more testing, but I tried to reproduce the problem that started this issue and I can't get it to delay as long as it did. I'm still seeing 200+ms delays, but not 3 seconds. So either the firmware was updated or the changes to |
Although these aren't speedy devices (we won't get them to update at 20Hz), the driver is working much better. The only differences are the changes made in |
The TP-Link driver "works", but it has a latency that I can't figure out.
I own 3 HS220 dimmers from Kasa. The DrMem driver can control them, but it can take up to 3 seconds for a change to occur. I believe it should be much quicker.
I based the design of the driver from information gleaned from tplink_smartplug.py and tplink-smarthome-commands.txt.
When the driver sends the command, it takes up to 3 seconds before a reply is received. What's confusing is that the Python script (mentioned above) almost always gets a reply in less than 10 ms! As of the latest commit, the DrMem driver sends the EXACT same request packet as the Python script, and yet it consistently gets a delayed response.
This is a
tcpdump
of the DrMem driver trying to turn on the LED indicator:and this is the Python script:
The TP-Link protocol uses a weak, XOR form of encryption so you can't read the JSON payload. However, you can see that the DrMem packet contents is the same as Python's. And you can see the replies are the same. It's just DrMem's interaction always has that middle reply from the dimmer that never gets sent when it's from Python.
Both, the Python script and DrMem, are running on the same machine -- so it's not an OS difference.
Right now, I need to work on other items in DrMem. This driver works -- even though it takes a awhile for it to perform a command. Maybe someone can see what I'm missing or come up with a test to make this work.
The text was updated successfully, but these errors were encountered: