Closed leoheck closed 2 years ago
Try passing in the IP of your device as an argument as well and see if that fixes it.
Hi @codetheweb I was trying that, and it was not working too. Let me check again what was the issue I was having with the ip. Ah, by tha way I was using the ip gotten from inside the Tuya's app. It was not a local ip.
This is what happens when I use the public ip.
➜ DEBUG=* tuya-cli get --ip [IP_HERE] --id [ID_HERE] --key [KEY_HERE] --full
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to [IP_HERE]... +6ms
TuyAPI Error event from socket. [IP_HERE] Error: connect ECONNREFUSED [IP_HERE]:6668
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1138:16) {
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '[IP_HERE]',
port: 6668
} +13ms
events.js:291
throw er; // Unhandled 'error' event
^
Error: Error from socket: connect ECONNREFUSED [IP_HERE]:6668
at Socket.<anonymous> (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:515:30)
at Socket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on TuyaDevice instance at:
at Socket.<anonymous> (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:515:16)
at Socket.emit (events.js:314:20)
[... lines matching original stack trace ...]
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Ah, using local ip i am seeing this
➜ DEBUG=* tuya-cli get --ip [LOCAL_IP_HERE] --id [ID_HERE] --key [KEY_HERE] --full
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to [LOCAL_IP_HERE]... +2ms
TuyAPI Socket connected. +851ms
TuyAPI GET Payload: +3ms
TuyAPI {
TuyAPI gwId: '[ID_HERE]',
TuyAPI devId: '[ID_HERE]',
TuyAPI t: '[T_HERE]',
TuyAPI dps: {},
TuyAPI uid: '[ID_HERE]'
TuyAPI } +0ms
TuyAPI Received data: [RECEIVED_DATA] +102ms
TuyAPI Parsed: +5ms
TuyAPI {
TuyAPI payload: '7�q6��\u0002�^f$�R\u0013\u1011D\u001cFw�a�RF{?�\u0006����',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +1ms
TuyAPI Received DATA packet +1ms
TuyAPI Disconnect +1ms
7�q6���^f$�RDFw�a�RF{?�����
TuyAPI Socket closed: [LOCAL_IP_HERE] +4ms
The issue now with this is that I have 3 tuya devices on my network. But I have no ideia how do I identify each IP. The app does not show the Macaddress for this bulb. Do you know any way to identify the local ip of each device?
For the set operation I am seeing this:
➜ DEBUG=* tuya-cli set --ip [LOCAL_IP_HERE] --id [ID_HERE] --key [KEY_HERE] --dps 1 --set "true"
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to [LOCAL_IP_HERE]... +3ms
TuyAPI Socket connected. +307ms
TuyAPI SET Payload: +3ms
TuyAPI {
TuyAPI devId: '[ID_HERE]',
TuyAPI gwId: '[ID_HERE]',
TuyAPI uid: '',
TuyAPI t: 1633458303,
TuyAPI dps: { '1': true }
TuyAPI } +0ms
TuyAPI Received data: [RECEIVED_DATA] +100ms
TuyAPI Parsed: +3ms
TuyAPI {
TuyAPI payload: '7�q6��\u0002�^f$�R\u0013\u1011D\u001cFw�a�RF{?�\u0006����',
TuyAPI leftover: false,
TuyAPI commandByte: 7,
TuyAPI sequenceN: 1
TuyAPI } +1ms
TuyAPI Received DATA packet +1ms
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ('Timeout waiting for status response from device id: [ID_HERE]')
at TuyaDevice.emit (events.js:303:17)
at /usr/local/lib/node_modules/@tuyapi/cli/node_modules/tuyapi/index.js:369:12
at Timeout._onTimeout (/usr/local/lib/node_modules/@tuyapi/cli/node_modules/p-timeout/index.js:25:13)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
code: 'ERR_UNHANDLED_ERROR',
I had to find the right IP. And some devices were missing. Specially the one I wanted to control.
Then I installed tinytuya, and with this scan python3 -m tinytuya scan
I was able to identify my specific bulb. Because it was the only one that had the information displayed.
So, I managed to make it work. Now, it could have a way to identify the ip of the bulb with the list command if possible.
I don't think Tuya provides the local IP of devices for that API call.
I don't think Tuya provides the local IP of devices for that API call.
Yeah, but how do you get it for your devices? Any idea?
As stated in the TuyAPI readme, I'm not currently using any of this on a day-to-day basis. Having said that, some form of IP scanning with nmap or the like usually works pretty well.
TuyAPI should be able to automatically find your devices assuming they're not on different subnets and nothing weird is going on with your network.
Cool. Thanks, codetheweb.
Reporting issues I am seeing.
GET
SET
[SOLVED] the commands need the
ip
, it is not optional. And it has to be the local IP, not the one found on Tuya's APP. Sometime the device has the macaddress listed on Tuya's App what makes the disover of the IP easy. Sometimes it does not have what was on my case.