codetheweb / tuyapi

🌧 An easy-to-use API for devices that use Tuya's cloud services. Documentation: https://codetheweb.github.io/tuyapi.
MIT License
2.04k stars 332 forks source link

Getting find() timed out messages with correct creds #600

Closed tinychaos42 closed 1 year ago

tinychaos42 commented 1 year ago

The bug / issue

Got a smart switch through Smart Life. Registered the right things on Tuya IOT platform. Entered the right credentials into tuya-smart-device node in Node-RED. Can confirm that the switch is working through IOS app as well as Tuya debug mode, but when the node is running in Node-RED, I am getting

27 Sep 19:21:01 - [error] [tuya-smart-device:Switch] find() timed out. Is the device powered on and the ID or IP correct?
27 Sep 19:21:01 - [info] [tuya-smart-device:Switch] findDevice(): Cannot find the device, re-trying...
27 Sep 19:21:02 - [info] [tuya-smart-device:Switch] findDevice(): Initiating the find command

To Reproduce Steps to reproduce the behavior:

  1. Configure Smart Life device
  2. Configure Smart Life device through Tuya IOT Platform, fetch credentials (key/secret etc)
  3. Configure and use tuya-cli to fetch ID and key for the switch (tried with IP as well as with ID)
  4. See error

Expected behavior I'd expect the node to connect and eventually me being able to flip the swithc on and off

Debug Output

27 Sep 19:23:35 - [error] [tuya-smart-device:Switch] find() timed out. Is the device powered on and the ID or IP correct?
27 Sep 19:23:35 - [info] [tuya-smart-device:Switch] findDevice(): Cannot find the device, re-trying...
27 Sep 19:23:36 - [info] [tuya-smart-device:Switch] findDevice(): Initiating the find command

Desktop:

Additional context New to the whole spiel of Node-Red, Tuya, etc, so apologies if I filed this in the wrong place.

tinychaos42 commented 1 year ago

If I add in the IP as well as changing the protocol to 3.3 , I am getting the following log:

27 Sep 19:29:33 - [info] [tuya-smart-device:Switch] startComm(): Connecting to Tuya with params {"id":"YYYYYYY","key":"XXXXXXX","ip":"188.x.x.x","issueGetOnConnect":false,"nullPayloadOnJSONError":false,"version":"3.3"} , findTimeout :  10000 , retryTimeout:  1000 
27 Sep 19:29:33 - [info] [tuya-smart-device:Switch] findDevice(): Initiating the find command
27 Sep 19:29:33 - [info] [tuya-smart-device:Switch] findDevice(): Found device, going to connect
27 Sep 19:29:38 - [info] [tuya-smart-device:Switch] Error from tuyaDevice. shouldTryReconnect = true, error  = {}
27 Sep 19:29:38 - [error] [tuya-smart-device:Switch] Error: connection timed out
27 Sep 19:29:38 - [info] [tuya-smart-device:Switch] Will try to reconnect after 1000 milliseconds
27 Sep 19:29:38 - [info] [tuya-smart-device:Switch] connectDevice(): An error had occurred with tuya API on connect method : {}
27 Sep 19:29:38 - [info] [tuya-smart-device:Switch] connectDevice(): retrying the connect
27 Sep 19:29:39 - [info] [tuya-smart-device:Switch] Retrying connection...
27 Sep 19:29:44 - [info] [tuya-smart-device:Switch] Error from tuyaDevice. shouldTryReconnect = true, error  = {}
tinychaos42 commented 1 year ago

Closing: installed the device through tuya app, got credentials through tuya iot website and it's working fine with a tuya based nodered module