subzero79 / node-red-contrib-tuya-local

NodeRED node to control tuya devices locally. Based on tuyapi module
29 stars 17 forks source link

At times devices go into a connecting state? For no apparent reason? #29

Open Nodi-Rubrum opened 4 years ago

Nodi-Rubrum commented 4 years ago

At times devices go into a connecting state? For no apparent reason? I have good, strong WiFi, ip addresses are not changing under the hood (say from DHCP range changes), the network is stable. Nor do I see the devices disconnecting and connecting from the tuya app on my phone. So I suspect your implementation is doing something? Or the TUYA remote connect is doing something? How would you suggest I track down why this is happening, would like to get the NR connected devices consistent and stable similar to how they are in my phone configuration.

For example... I get this error on just some of my smart plugs... "Error: Error from socket device: Smart YX-WS01"

Model is "Smart Plug YX-WS01" TUYA product id is "cET7nrXx83igNwGF"

subzero79 commented 4 years ago

Maybe are you using also the app at the same time? Also make sure you are not duplicating the nodes for the same plug

Nodi-Rubrum commented 4 years ago

Not duplicating... and the app has never impacted the other nodes/devices I have already setup. It is only this latest set of devices that seem to be an issue. I have 3 other vendors that work fine. The tuya app uses the same ids and keys, so there should not be a conflict. These new plugs work fine in the app, as do the over vendors I have setup. It is only your tuya.local implementation that seems to fail to work with these plugs. Does the error message not suggest to you some indicating of what is going on? The connection failure is immediate, it does not appear that the connection request ever gets to the remote server for validation. The second I send the connect request it comes back immediately. This not the typical behavior I have seen in the past.

Nodi-Rubrum commented 4 years ago

Does your code have a verbose mode, or could it provide feedback via the node red log? Could there be a API version mismatch issue? I should have qualified, these newer plugs never get a valid connection, they just retry over and over. I realize the title of this issue suggests otherwise.

I think I will write a bit of python to test the connection of these new plugs to the tuya api, where I can try to get more details but why the connections are failing.

subzero79 commented 4 years ago

Then you should maybe run a nodejs small app script using the latest tuyapi library to test. The tuyapi library i think is outdated on this node. As I mentioned in other issues I don’t have tuya hw anymore as I flashed all of them with esphome. I am looking if someone wants to take over the code and keep maintaining it or maybe redo it completely.

Also if you’re not aware the tcp socket established to the socket can only be one simultaneously that’s a fw limitation. That’s why I ask about the app. Check if there is also a fw difference in between working sockets and the new ones. There might be issues there that need to be addressed by the tuyapi library.

Nodi-Rubrum commented 4 years ago

Ah, yeah, thinking along the same lines... try JS or python to parse out what might be going on. Right, I am not actually invoking the connections at the same time. Just that they are configured at the same time. What is odd, is the other plugs I have don't have any issue with my current setup, they are configured in phone app and NR and work fine. But there could be a difference in the hardware, true. And I can always kill the phone application setup as part of the testing. Is there a reference what which API versions support what generation of plugs? I can't seem to find anything about what version of the API was released when, that might also help.