Comparing version 5.3.0 to 5.3.1
26
index.js
@@ -96,3 +96,6 @@ // Import packages | ||
gwId: this.device.gwID, | ||
devId: this.device.id | ||
devId: this.device.id, | ||
t: Math.round(new Date().getTime() / 1000).toString(), | ||
dps: {}, | ||
uid: this.device.id | ||
}; | ||
@@ -114,3 +117,3 @@ | ||
// Send request | ||
this._send(buffer).then(data => { | ||
this._send(buffer).then(async data => { | ||
if (typeof data !== 'object' || options.schema === true) { | ||
@@ -314,2 +317,19 @@ // Return whole response | ||
packets = this.device.parser.parse(data); | ||
for (const packet of packets) { | ||
if (packet.payload && packet.payload === 'json obj data unvalid') { | ||
this.emit('error', packet.payload); | ||
packet.payload = { | ||
dps: { | ||
1: null, | ||
2: null, | ||
3: null, | ||
101: null, | ||
102: null, | ||
103: null | ||
} | ||
}; | ||
} | ||
} | ||
} catch (error) { | ||
@@ -386,3 +406,3 @@ debug(error); | ||
// can emit a `data` event as soon as possible | ||
await this.get(); | ||
this.get(); | ||
@@ -389,0 +409,0 @@ // Return |
@@ -312,3 +312,5 @@ const Cipher = require('./cipher'); | ||
payload.copy(buffer, 16); | ||
buffer.writeInt32BE(crc(buffer.slice(0, payload.length + 16)), payload.length + 16); | ||
const calculatedCrc = crc(buffer.slice(0, payload.length + 16)) & 0xFFFFFFFF; | ||
buffer.writeInt32BE(calculatedCrc, payload.length + 16); | ||
buffer.writeUInt32BE(0x0000AA55, payload.length + 20); | ||
@@ -315,0 +317,0 @@ |
{ | ||
"name": "tuyapi", | ||
"version": "5.3.0", | ||
"version": "5.3.1", | ||
"description": "An easy-to-use API for devices that use Tuya's cloud services", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
43589
1000