Closed LionMike closed 4 years ago
I cannot reproduce this problem. What kind of devices do you use? Does the log file report any error? Please make sure the key values are correct.
Device 1 is a Yuntong breaker, similar to a Sonoff. The other two are unbranded. XS-SSA01, similar to the round Gosund smart plug. I retrieved the local key via Burp Suite and Ucomen app on an iPad Air. As you can see they disconnect after about 30 seconds. Here is a sample of the log file: 2020-03-28 09:47:26.159 INFO : tuya-adapter: tuya-05200187dc4f2230074e Disconnected! 2020-03-28 09:47:26.435 INFO : tuya-adapter: tuya-04200045dc4f221e02b0 Connected! 2020-03-28 09:47:26.445 INFO : tuya-adapter: tuya-04200045dc4f221e02b0 Data { devId: '04200045dc4f221e02b0', dps: { '1': true, '2': 0 } } 2020-03-28 09:47:28.138 INFO : tuya-adapter: tuya-02200286dc4f221b34ee Connected! 2020-03-28 09:47:28.147 INFO : tuya-adapter: tuya-02200286dc4f221b34ee Data { devId: '02200286dc4f221b34ee', dps: { '1': true, '2': 0 } } 2020-03-28 09:48:01.442 INFO : tuya-adapter: tuya-04200045dc4f221e02b0 Error Error: Error from socket 2020-03-28 09:48:01.444 INFO : tuya-adapter: at Socket.client.on.err (/home/pi/.mozilla-iot/addons/tuya-adapter/node_modules/tuyapi/index.js:330:30)
I have only used ids and keys obtained through tuya-cli
tool as described in the README (this may be the problem?). I'm not 100% sure, but this seems to be a bug in the tuyapi, since the error appears to be thrown in their code. It is somewhat similar to this issue. What happens if you execute DEBUG=* tuya-cli get --id xxx --key xxx -a
(replacing xxx with your id and key values)?
Since I am running WebThings Gateway in a headless configuration I assume I would have to connect directly to the Raspberry Pi to do this? I am a newbie and not very good at coding.
Either this, or you may just as well run the tool on your local machine. You will have to install it through npm anyways: https://github.com/TuyaAPI/cli
I have just fixed a different bug in the connect mechanism. Could you clone the repository in its current state and try whether it may have fixed your bug as well?
I did as you asked and the devices are still connected. I added a smart bulb, but it only responds when configured as a plug/switch.
So besides the light bulb only responding when configured as a switch your devices do work properly now?
I almost would have expected that there will be some problems with other lightbulbs. Could you please send me the part of the logfile where it says something like
tuya-adapter: tuya-xxx Data { devId: 'xxx', dps: { '20': false, '21': 'white', ... } }
where xxx
is the id of your lightbulb?
I hope this helps.
tuya-21712103807d3a6d570c Data { devId: '21712103807d3a6d570c', 2020-03-29 13:16:33.927 INFO : tuya-adapter: dps: 2020-03-29 13:16:33.928 INFO : tuya-adapter: { '1': false, 2020-03-29 13:16:33.929 INFO : tuya-adapter: '2': 'white', 2020-03-29 13:16:33.931 INFO : tuya-adapter: '3': 255, 2020-03-29 13:16:33.932 INFO : tuya-adapter: '5': 'ff00000000ffff', 2020-03-29 13:16:33.933 INFO : tuya-adapter: '6': '00ff0000000000', 2020-03-29 13:16:33.934 INFO : tuya-adapter: '7': 'ffff500100ff00', 2020-03-29 13:16:33.935 INFO : tuya-adapter: '8': 'ffff8003ff000000ff000000ff000000000000000000', 2020-03-29 13:16:33.936 INFO : tuya-adapter: '9': 'ffff5001ff0000', 2020-03-29 13:16:33.938 INFO : tuya-adapter: '10': 'ffff0505ff000000ff00ffff00ff00ff0000ff000000' } }
Devices disconnect and reconnect randomly. Increasing connection timeout only helps momentarily.