tuyapi
tuyapi copied to clipboard
Tuyapi returns junk data
Describe the bug TuyAPI returns junk data and is unable to control the device.
Expected behavior It works! Debug Output
Data from device: :ѧY{trimmed}
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [e.g. macOS] macOS
- OS Version [e.g. 22] 11.1
- Node Version [output of
node -v
] Electron v11.0.3Chromium v87.0.4280.67Node v12.18.3v8 v8.7.220.25-electron.0
Additional context Add any other context about the problem here.
Electron
That looks interesting... 😛
Can you please set the DEBUG
environment variable to *
and post the output?
That looks interesting... 😛 It isn't electron specific, happens with regular node too!
bash-3.2$ node
TuyAPI Finding missing IP undefined or ID 474172802cf432e2d525 +0ms
./artCache/TW9uc3RlcmNhdCBVbmNhZ2VkIFZvbC4gOA==.jpg
[ [ 81.81818181818181, 0.2444444444444445, 0.17647058823529413 ] ]
TuyAPI Received UDP message. +5s
TuyAPI UDP data: +1ms
TuyAPI {
TuyAPI payload: {
TuyAPI ip: '192.168.1.57',
TuyAPI gwId: '474xxxxxxxxxxxxxxx525',
TuyAPI active: 2,
TuyAPI ability: 0,
TuyAPI mode: 0,
TuyAPI encrypt: true,
TuyAPI productKey: 'keyj97xxxxxxheh',
TuyAPI version: '3.3'
TuyAPI },
TuyAPI leftover: false,
TuyAPI commandByte: 19,
TuyAPI sequenceN: 0
TuyAPI } +0ms
TuyAPI Connecting to 192.168.1.57... +1ms
TuyAPI Socket connected. +5ms
connected
TuyAPI GET Payload: +0ms
TuyAPI {
TuyAPI gwId: '474xxxxxxxxxxxxxxx525',
TuyAPI devId: '474xxxxxxxxxxxxxxx525',
TuyAPI t: '1610916705',
TuyAPI dps: {},
TuyAPI uid: '474xxxxxxxxxxxxxxx525'
TuyAPI } +0ms
TuyAPI Received data: 000055aa000000010000000a0000002c000000013ad1a75926f0891f27ec019f7b0b355a0f39aa6362d4e8e3dbe81ee00f62560881eed5190000aa55 +27ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: ":ѧY&��\x1F'�\x01�{\x0B5Z\x0F9�cb�����\x1E�\x0FbV\b",
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +0ms
:ѧY&��'��{
5Z9�cb������b 10 1
[ 81.81818181818181, 0.2444444444444445, 0.17647058823529413 ]
51
f4
TuyAPI SET Payload: +415ms
TuyAPI {
TuyAPI devId: '474xxxxxxxxxxxxxxx525',
TuyAPI gwId: '474xxxxxxxxxxxxxxx525',
TuyAPI uid: '',
TuyAPI t: 1610916705,
TuyAPI dps: { '24': '005100f403e8' }
TuyAPI } +0ms
Error! Timeout waiting for status response from device id: 474xxxxxxxxxxxxxxx525```
It isn't electron specific, happens with regular node too!
Wasn't trying to imply that it was, just was curious what you're working on.
That is a bit of a strange-looking payload that the device sends back. IIRC even for protocol version 3.3 the version should be unencrypted before the payload, which isn't occurring here.
What are the options you're passing to the TuyAPI constructor? Try version 3.3 if you haven't already, and also double-check the key.
I have the same problem as @theLMGN: When I connect to the light I only get junk data. I'm using a simplified version of the example script.
Script:
const TuyAPI = require('tuyapi');
const device = new TuyAPI({
id: 'bxxxxxxxxxxxxxxxxxxxx',
key: '7xxxxxxxxxxxxx',
ip: '1xx.xxx.xxx.xx',
version: '3.3'});
device.find().then(() => {
device.connect();
});
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('data', data => {
console.log('Data from device:', data);
});
Everything I get as output:
Connected to device!
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
Data from device: 3.3h/☺w��↓�↨W
���▼�Ζ▬�R↨m �2��S,h]��%`�(�9��`�m�c��
Debug Output:
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to 1xx.xxx.xxx.xx... +45ms
TuyAPI Socket connected. +44ms
Connected to device!
TuyAPI GET Payload: +36ms
TuyAPI {
TuyAPI gwId: 'bxxxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'bxxxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615138232',
TuyAPI dps: {},
TuyAPI uid: 'bxxxxxxxxxxxxxxxxxxxx'
TuyAPI } +2ms
TuyAPI Received data: 000055aa000000010000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dedd6be230000aa55 +65ms
TuyAPI Parsed: +4ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +2ms
TuyAPI Pinging 1xx.xxx.xxx.xx +10s
TuyAPI Pinging 1xx.xxx.xxx.xx +16s
TuyAPI Received data: 000055aa00000000000000080000004b00000000332e3300000000000068350000000177e6db199717570a9cb6941f8bce96168a173365be94e1d3461d3f27121e3a6a0f14fec25d21efdb7a453e39609ab9556cc671cf0000aa55 +11ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: "3.3\x00\x00\x00\x00\x00\x00h5\x00\x00\x00\x01w��\x19�\x17W\n���\x1F�Ζ\x16�\x173e����F\x1D?'\x12\x1E:j\x0F\x14��]!��zE>9��U",
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 0
TuyAPI } +1ms
Desktop: OS: WIN 10 Version: 20H2 Node version: 14.16.0
Yours looks slightly different as the version number is inside the payload. Not sure what's going on.
Could you link to a product page for your device?
I'm using these lights: https://www.hombli.com/de/products/smart-spot-rgb/
I have them linked with the tuya app and not with the original app of the manufacturer. I have also tested if it works with the original app, but the API returns the same junk data.
Could you email or message me the local key for your device so I can play around with the payload locally (assuming it hasn't changed since your last post with the debug log)?
@codetheweb I mailed you the local key and the id to the email on your website.
Thank you, I'll try and take a look soon.
I've played around with the two strings from the above debug output and I have no idea what's going on.
Could you provide a longer debug output? Multiple GET payloads between changing a single value on the device would be helpful as well. It looks like the device doesn't respond to heartbeat packets either?
Here is a longer debug log:
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to xxx.xxx.xxx.xx... +3ms
TuyAPI Socket connected. +9ms
Connected to device!
1
TuyAPI SET Payload: +5ms
TuyAPI {
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI uid: '',
TuyAPI t: 1615750767,
TuyAPI dps: { '1': true }
TuyAPI } +0ms
TuyAPI GET Payload: +7ms
TuyAPI {
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI t: '1615750768',
TuyAPI dps: {},
TuyAPI uid:'xxxxxxxxxxxxxxxx'
TuyAPI } +0ms
2
TuyAPI SET Payload: +3ms
TuyAPI {
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI uid: '',
TuyAPI t: 1615750767,
TuyAPI dps: { '1': false }
TuyAPI } +1ms
TuyAPI GET Payload: +2ms
TuyAPI {
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI t: '1615750768',
TuyAPI dps: {},
TuyAPI uid:'xxxxxxxxxxxxxxxx'
TuyAPI } +0ms
3
TuyAPI SET Payload: +2ms
TuyAPI {
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI uid: '',
TuyAPI t: 1615750767,
TuyAPI dps: { '1': true }
TuyAPI } +1ms
TuyAPI GET Payload: +2ms
TuyAPI {
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI t: '1615750768',
TuyAPI dps: {},
TuyAPI uid:'xxxxxxxxxxxxxxxx'
TuyAPI } +0ms
4
TuyAPI SET Payload: +8ms
TuyAPI {
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI uid: '',
TuyAPI t: 1615750767,
TuyAPI dps: { '1': false }
TuyAPI } +1ms
TuyAPI GET Payload: +1ms
TuyAPI {
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI t: '1615750768',
TuyAPI dps: {},
TuyAPI uid:'xxxxxxxxxxxxxxxx'
TuyAPI } +2ms
end
TuyAPI GET Payload: +3ms
TuyAPI {
TuyAPI gwId:'xxxxxxxxxxxxxxxx',
TuyAPI devId:'xxxxxxxxxxxxxxxx',
TuyAPI t: '1615750768',
TuyAPI dps: {},
TuyAPI uid:'xxxxxxxxxxxxxxxx'
TuyAPI } +1ms
TuyAPI Received data: 000055aa00000001000000070000002c0000000157accad20e8862e725263f6050828d129fa06633bf7762a82515a2334a72d98213a132230000aa55 +18ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: 'W���\x0E�b�%&?`P��\x12��f3�wb�%\x15�3Jrق',
TuyAPI leftover: false,
TuyAPI commandByte: 7,
TuyAPI sequenceN: 1
TuyAPI } +0ms
Data from device: W���♫�b�%&?`P��↕��f3�wb�%§�3Jrق
TuyAPI Received data: 000055aa000000020000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dd21dc0b60000aa55 +202ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 2
TuyAPI } +2ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Received data: 000055aa000000040000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dad8b3d9c0000aa55000055aa000000060000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632d31d66b450000aa55000055aa000000080000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632d52a6c7c80000aa55000055aa000000090000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632df130ef840000aa55 +94ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: <Buffer 00 00 55 aa 00 00 00 06 00 00 00 0a 00 00 00 2c 00 00 00 01 b7 64 95 a5 39 d2 14 16 0d 3b d4 c9 6a 35 17 66 cf bc f5 9c 6c 26 51 0a 05 3a a6 a3 19 cf ... 130 more bytes>,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 4
TuyAPI } +2ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Parsed: +5ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: <Buffer 00 00 55 aa 00 00 00 08 00 00 00 0a 00 00 00 2c 00 00 00 01 b7 64 95 a5 39 d2 14 16 0d 3b d4 c9 6a 35 17 66 cf bc f5 9c 6c 26 51 0a 05 3a a6 a3 19 cf ... 70 more bytes>,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 6
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Parsed: +3ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: <Buffer 00 00 55 aa 00 00 00 09 00 00 00 0a 00 00 00 2c 00 00 00 01 b7 64 95 a5 39 d2 14 16 0d 3b d4 c9 6a 35 17 66 cf bc f5 9c 6c 26 51 0a 05 3a a6 a3 19 cf ... 10 more bytes>,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 8
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 9
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
Error! Timeout waiting for status response from device id: bf03ccdab821c241f9uhj2
TuyAPI Received data: 000055aa00000003000000070000002c0000000157accad20e8862e725263f6050828d129fa06633bf7762a82515a2334a72d9828ffc64fa0000aa55 +2s
TuyAPI Parsed: +0ms
TuyAPI {
TuyAPI payload: 'W���\x0E�b�%&?`P��\x12��f3�wb�%\x15�3Jrق',
TuyAPI leftover: false,
TuyAPI commandByte: 7,
TuyAPI sequenceN: 3
TuyAPI } +2ms
Data from device: W���♫�b�%&?`P��↕��f3�wb�%§�3Jrق
Error! Timeout waiting for status response from device id: bf03ccdab821c241f9uhj2
TuyAPI Received data: 000055aa00000005000000070000002c0000000157accad20e8862e725263f6050828d129fa06633bf7762a82515a2334a72d982f06a99d00000aa55 +2s
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: 'W���\x0E�b�%&?`P��\x12��f3�wb�%\x15�3Jrق',
TuyAPI leftover: false,
TuyAPI commandByte: 7,
TuyAPI sequenceN: 5
TuyAPI } +2ms
Data from device: W���♫�b�%&?`P��↕��f3�wb�%§�3Jrق
Error! Timeout waiting for status response from device id: bf03ccdab821c241f9uhj2
TuyAPI Received data: 000055aa00000007000000070000002c0000000157accad20e8862e725263f6050828d129fa06633bf7762a82515a2334a72d9826c37cf090000aa55 +2s
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: 'W���\x0E�b�%&?`P��\x12��f3�wb�%\x15�3Jrق',
TuyAPI leftover: false,
TuyAPI commandByte: 7,
TuyAPI sequenceN: 7
TuyAPI } +1ms
Data from device: W���♫�b�%&?`P��↕��f3�wb�%§�3Jrق
Error! Timeout waiting for status response from device id: bf03ccdab821c241f9uhj2
TuyAPI Pinging xxx.xxx.xxx.xx +4s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +54ms
TuyAPI Parsed: +1ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +1ms
TuyAPI Pong from xxx.xxx.xxx.xx +3ms
TuyAPI Pinging xxx.xxx.xxx.xx +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +84ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +2ms
TuyAPI Pong from xxx.xxx.xxx.xx +2ms
The new script is:
const TuyAPI = require('tuyapi');
const device = new TuyAPI({
id: 'xxxxxxxxxxxxxxxxxxx',
key: 'xxxxxxxxxxxxxxx',
ip: 'xxx.xxx.xxx.xx',
version: '3.3'});
// Find device on network
device.find().then(() => {
// Connect to device
device.connect();
});
// Add event listeners
device.on('connected', () => {
console.log('Connected to device!');
console.log(1);
device.set({dps: 1, set: true}).then(device.get().then(status => console.log(status)));
console.log(2);
device.set({dps: 1, set: false}).then(device.get().then(status => console.log(status)));
console.log(3);
device.set({dps: 1, set: true}).then(device.get().then(status => console.log(status)));
console.log(4);
device.set({dps: 1, set: false}).then(device.get().then(status => console.log(status)));
console.log("end");
});
device.on('disconnected', () => {
console.log('Disconnected from device.');
});
device.on('error', error => {
console.log('Error!', error);
});
device.on('data', data => {
console.log('Data from device:', data);
});
I hope this will help you, if you need more debug data let me know.
Thank you. Could you send a GET request, change only one attribute of the device through the app, then send another GET request? Trying to see what changes.
Here is the debug log while turning the led on and off in the app:
LED OFF
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to xxx.xxx.xxx.xx... +3ms
TuyAPI Socket connected. +13ms
Connected to device!
TuyAPI GET Payload: +2ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826222',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +1ms
end
TuyAPI GET Payload: +7ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826222',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +0ms
TuyAPI Received data: 000055aa000000010000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dedd6be230000aa55 +9ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +0ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Received data: 000055aa000000020000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dd21dc0b60000aa55 +4ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 2
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
LED ON
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to xxx.xxx.xxx.xx... +3ms
TuyAPI Socket connected. +97ms
Connected to device!
TuyAPI GET Payload: +4ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826230',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +2ms
end
TuyAPI GET Payload: +7ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826230',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +1ms
TuyAPI Received data: 000055aa000000010000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dedd6be230000aa55 +93ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Received data: 000055aa000000020000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dd21dc0b60000aa55 +97ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 2
TuyAPI } +2ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
LED OFF
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to xxx.xxx.xxx.xx... +4ms
TuyAPI Socket connected. +1s
Connected to device!
TuyAPI GET Payload: +5ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826235',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +1ms
end
TuyAPI GET Payload: +7ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826235',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +1ms
TuyAPI Received data: 000055aa000000010000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dedd6be230000aa55 +77ms
TuyAPI Parsed: +2ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +0ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Received data: 000055aa000000020000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dd21dc0b60000aa55 +5ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 2
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
LED ON
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to xxx.xxx.xxx.xx... +3ms
TuyAPI Socket connected. +44ms
Connected to device!
TuyAPI GET Payload: +4ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826242',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +1ms
end
TuyAPI GET Payload: +8ms
TuyAPI {
TuyAPI gwId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI devId: 'xxxxxxxxxxxxxxxxxxx',
TuyAPI t: '1615826242',
TuyAPI dps: {},
TuyAPI uid: 'xxxxxxxxxxxxxxxxxxx'
TuyAPI } +2ms
TuyAPI Received data: 000055aa000000010000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dedd6be230000aa55 +97ms
TuyAPI Parsed: +1ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1
TuyAPI } +1ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
TuyAPI Received data: 000055aa000000020000000a0000002c00000001b76495a539d214160d3bd4c96a351766cfbcf59c6c26510a053aa6a319cf632dd21dc0b60000aa55 +94ms
TuyAPI Parsed: +0ms
TuyAPI {
TuyAPI payload: '�d��9�\x14\x16\r;��j5\x17fϼ��l&Q\n\x05:��\x19�c-',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 2
TuyAPI } +2ms
;��j5↨fϼ��l&Qice: �d��9�¶▬
♣:��↓�c-
Here is the script:
const TuyAPI = require('tuyapi');
const device = new TuyAPI({
id: 'xxxxxxxxxxxxxxxxxxx',
key: 'xxxxxxxxxxxxxxxxxxx',
ip: 'xxx.xxx.xxx.xx',
version: '3.3'});
// Find device on network
device.find().then(() => {
// Connect to device
device.connect();
});
// Add event listeners
device.on('connected', () => {
console.log('Connected to device!');
device.get().then(status => console.log(status));
console.log("end");
});
device.on('disconnected', () => {
console.log('Disconnected from device.');
});
device.on('error', error => {
console.log('Error!', error);
});
device.on('data', data => {
console.log('Data from device:', data);
});
Thank you.
Several of the packets are the same in both the on and off scenarios, so I'm a bit stumped. That would imply that the device isn't actually sending data about whether it's on or off.
Could you fetch the local key again to make sure it hasn't changed? Decryption should fail if it's wrong and not just return junk data but that's the only thing left that I can think of to try.
@codetheweb The key has changed from yesterday to today, but I don't know why. The API is now working without a problem. :+1: Big thank you for the effort.
Glad it's working now 👍
Hi all,
pinkfloyd@Rainbow:~$ tuya-cli wizard ? Do you want to use these saved API credentials? Yes ? Provide a 'virtual ID' of a device currently registered in the app: [ { name: 'Salle a manger', id: 'bbh', key: '4e536a6bcacb2af9' }, ]
I can confirm my local key, but get junk data too :
data: "3.3��1���<b~>o-;x�9*I��_�Jp�p����Lm�uh,���̓�"
Test with another device : `data: "3.3�,縕Y���.8�����@�I� Q:<����������}5�� (ܘm"��E
does it reply in chineese and the system doesn't know how to convert ascii char ?
@pinkfloydFR please run your script with debug output enabled (DEBUG=*
) and post the result in a new issue.
hello, I've the similar issue. My device: wifi socket with firmware 1.1.7
node -v v14.17.3 (inside docker)
I've another 11 similar devices with 1.0.3 firmware that works normally.
@wojtulab can you double-check the local key? What do you mean by a 1.x.x firmware?
I can reply to this, i already double checked my api, and i am sure is good as i can control my roller with the extension in HA
@codetheweb double checked, its ok. Moreover I removed the socket and re-add with new keys.
The situation is the same.
By 1.x.x firmware I mean in Tuya app section firmware inside my device: Main module: V1.1.7 Module MCU V1.1.7