tuya gateway subdevice not found
See original GitHub issueDescribe the bug I have a json file from tuya smart data, which contains all device ID’s and the localKey for the gateway. Tuyapi can connect (and/or discover) the gateway, but can not get data from any subdevice. It may be the fault of my coding…
To Reproduce DEBUG=* node tuya_gw.js (I posted the code below)
Expected behavior I expected to get any available dps data from the given subdevice.
Debug Output
# DEBUG=* node tuya_gw.js
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to 192.168.0.26... +4ms
TuyAPI Socket connected. +62ms
Connected to device!
TuyAPI GET Payload: +3ms
TuyAPI { gwId: 'bfd62f405900fd4511rabd',
TuyAPI devId: 'bfdcbeaf72ae6bfbe7zzoa' } +0ms
TuyAPI Received data: 000055aa000000010000000a0000001c0000000128794c6c00610d92a29f3b88f40a91210fd902350000aa55 +34ms
TuyAPI Parsed: +3ms
TuyAPI { payload: 'devid not found',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1 } +0ms
Data from device: devid not found
TuyAPI Pinging 192.168.0.26 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +30ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
TuyAPI Pong from 192.168.0.26 +1ms
TuyAPI Disconnect +5s
TuyAPI Socket closed: 192.168.0.26 +2ms
Disconnected from device.
# DEBUG=* node tuya_gw.js
TuyAPI IP and ID are already both resolved. +0ms
TuyAPI Connecting to 192.168.0.26... +6ms
TuyAPI Socket connected. +110ms
Connected to device!
TuyAPI GET Payload: +3ms
TuyAPI { gwId: 'bfd62f405900fd4511rabd',
TuyAPI devId: 'bf88a38b43cae1ca740e09' } +0ms
TuyAPI Received data: 000055aa000000010000000a0000001c0000000128794c6c00610d92a29f3b88f40a91210fd902350000aa55 +35ms
TuyAPI Parsed: +4ms
TuyAPI { payload: 'devid not found',
TuyAPI leftover: false,
TuyAPI commandByte: 10,
TuyAPI sequenceN: 1 } +0ms
Data from device: devid not found
TuyAPI Pinging 192.168.0.26 +10s
TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +26ms
TuyAPI Parsed: +0ms
TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +0ms
TuyAPI Pong from 192.168.0.26 +1ms
TuyAPI Disconnect +5s
TuyAPI Socket closed: 192.168.0.26 +1ms
Disconnected from device.
Screenshots N/A
Desktop (please complete the following information):
- OS: [ linux (ubuntu)]
- OS Version [ bionic 4.15.0-43-generic ]
- Node Version [v8.10.0]
Additional context tuya_gw.js:
const TuyAPI = require('tuyapi');
const device = new TuyAPI({
ip: '192.168.0.26',
key: 'xxxx',
gwID: 'bfd62f405900fd4511rabd',
id: 'bf88a38b43cae1ca740e09',
version: 3.3
});
let stateHasChanged = false;
// 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('data', data => {
console.log('Data from device:', data);
});
// Disconnect after 15 seconds
setTimeout(() => { device.disconnect(); }, 15000);
relevant sections from the json file:
{"activeTime":1583615453,"devId":"bf88a38b43cae1ca740e09","displayOrder":0,"dpMaxTime":1583875320214,"dpName":{},"dps":{"1":true,"101":false,"102":true,"103":"1","124":"","125":0,"126":"1","127":16,"128":22,"129":"4","130":"c","131":"B+QDChYW","132":0,"133":true,"134":0,"135":0,"136":true,"137":true,"138":true,"139":true,"2":160,"3":220},"errorCode":0,"iconUrl":"https://...","isShare":false,"key":"bf88a38b43cae1ca740e09","lat":"","lon":"","meshId":"bfd62f405900fd4511rabd","moduleMap":{},"name":"4853_Nappali","nodeId":"505745","productId":"foitasaq52xwyqmt","resptime":0,"runtimeEnv":"prod","timezoneId":"Europe/Budapest","uuid":"bf88a38b43cae1ca740e09","virtual":false},
{"activeTime":1583171103,"devId":"bfdcbeaf72ae6bfbe7zzoa","displayOrder":0,"dpMaxTime":1583875320494,"dpName":{},"dps":{"1":true,"101":false,"102":true,"103":"1","125":0,"126":"1","127":25,"128":25,"129":"4","130":"c","131":"B+QDChYW","132":0,"133":true,"134":0,"135":0,"136":true,"137":true,"138":true,"139":true,"2":250,"3":253},"errorCode":0,"iconUrl":"https://...","isShare":false,"key":"bfdcbeaf72ae6bfbe7zzoa","lat":"","lon":"","meshId":"bfd62f405900fd4511rabd","moduleMap":{},"name":"4947_Lilla","nodeId":"608745","productId":"foitasaq52xwyqmt","resptime":0,"runtimeEnv":"prod","timezoneId":"Europe/Budapest","uuid":"bfdcbeaf72ae6bfbe7zzoa","virtual":false},
{"activeTime":1583170512,"devId":"bfd62f405900fd4511rabd","displayOrder":0,"dpMaxTime":0,"dpName":{},"dps":{},"errorCode":0,"iconUrl":"https://...","isShare":false,"key":"bfd62f405900fd4511rabd","lat":"47.5865865","localKey":"xxxx","lon":"19.0965987",
"moduleMap":{"wifi":
{"bv":"30.04",
"cadv":"1.0.2",
"isOnline":true,
"pv":"2.2",
"verSw":"1.1.6"}
},"name":"Gateway","productId":"tefahiby9c10n9zp","resptime":0,"runtimeEnv":"prod","timezoneId":"Europe/Budapest","uuid":"xxx","virtual":false}],
Tuya smart app shows the very same device ID’s as I see in the json file. Sub devices regulary send broadcast messages:
TuyAPI Received data: 000055aa00000000000000080000005b00000000332e330000000000015fea0000000156aca002d94a27d5d64756255260ce9e22efac65a96cde6fec763dbcb9b73c759ca31a70b72fb234efe32a4f1aec78db4c7e0ceafe1bcbb2bf327fb2c2fee55b26848c930000aa55 +6s
TuyAPI Parsed: +1ms
TuyAPI { payload: { dps: { '131': 'B+QEAxYj' }, cid: '608745', t: 1585946101 },
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 0 } +0ms
Data from device: { dps: { '131': 'B+QEAxYj' }, cid: '608745', t: 1585946101 }
TuyAPI Received data: 000055aa00000000000000080000005b00000000332e330000000000015feb0000000156aca002d94a27d5d64756255260ce9e22efac65a96cde6fec763dbcb9b73c75c4fd2867246c6d871451a9cf29d861c4708fda48f3b814766376e4201f44d4606a05c1a50000aa55 +336ms
TuyAPI Parsed: +1ms
TuyAPI { payload: { dps: { '131': 'B+QEAxYj' }, cid: '505745', t: 1585946102 },
TuyAPI leftover: false,
TuyAPI commandByte: 8,
TuyAPI sequenceN: 0 } +0ms
Data from device: { dps: { '131': 'B+QEAxYj' }, cid: '505745', t: 1585946102 }
Please help me by finding the right code to get dps data or by improving tuyapi to support this kind of device.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (3 by maintainers)
Top GitHub Comments
@danielgiovanni : Unfortunately I was not able to solve it yet. It appears, that even the tuya smart app didn’t communicate to the gateway directly, but through the tuya cloud.
I plan to create an artifical block towards the internet on the AP the devices connected to (Phone, tuya GW), and see if the phone tries to communicate the gateway directly if there is no internet connection to the tuya cloud.
If this didn’t help, I don’t know what else can I do.
I found something interesting that the same code test with tuya wire zigbee hub and result is different.
/homebridge # DEBUG=* node gateway.js
TuyAPI IP and ID are already both resolved. +0ms TuyAPI Connecting to 10.1.9.28… +6ms TuyAPI Socket connected. +5ms Connected to device! TuyAPI GET Payload: +2ms TuyAPI { TuyAPI gwId: ‘ebdd7925c7531bf4falakg’, TuyAPI devId: ‘ebd2e8be35c5cc00d3nkp9’, TuyAPI t: ‘1599384049’, TuyAPI dps: {}, TuyAPI uid: ‘ebd2e8be35c5cc00d3nkp9’ TuyAPI } +1ms TuyAPI Received data: 000055aa000000010000000a0000001c00000001a4fd046f973e79562bee4dfbd672a9ca03a3f1f40000aa55 +15ms TuyAPI Parsed: +2ms TuyAPI { TuyAPI payload: ‘devid not found’, TuyAPI leftover: false, TuyAPI commandByte: 10, TuyAPI sequenceN: 1 TuyAPI } +1ms Data from device: devid not found TuyAPI Pinging 10.1.9.28 +10s TuyAPI Received data: 000055aa00000000000000090000000c00000000b051ab030000aa55 +5ms TuyAPI Parsed: +0ms TuyAPI { payload: false, leftover: false, commandByte: 9, sequenceN: 0 } +1ms TuyAPI Pong from 10.1.9.28 +0ms TuyAPI Disconnect +5s TuyAPI Socket closed: 10.1.9.28 +2ms Disconnected from device.