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

Tuyapi timeouts after finding device #545

Open Tiqan opened 2 years ago

Tiqan commented 2 years ago

I am trying to connect to the device and then I always get a Timeout

`const TuyAPI = require('tuyapi');

const device = new TuyAPI({ ip: 'xxx.xxx.xxx.xx', id: 'xxxxxxxxxxxxxxxxxxx', key: 'xxxxxxxxxxxxxxxx', version: '3.3', issueRefreshOnConnect: true});

// Find device on network device.find().then(() => { // Connect to device device.connect(); });

// Add event listeners device.on('connected', () => { console.log('Connected to device!'); });

device.on('disconnected', () => { console.log('Disconnected from device.'); });

device.on('error', error => { console.log('Error!', error); });

device.on('dp-refresh', data => { console.log('DP_REFRESH data from device: ', data); });

device.on('data', data => { console.log('DATA from device: ', data);

});

// Disconnect after 10 seconds setTimeout(() => { device.disconnect(); }, 1000);`

image

nickdos commented 2 years ago

I experienced the same thing. I tried it again today after installing the latest HACS update and directly after a restart and adding the device worked this time. Maybe try again after a restart?

codetheweb commented 2 years ago

Check if the correct port is open on your target device with telnet [ip] 6668.

Also, try running your script with the debug env var set (DEBUG=*).