Comparing version 5.1.3 to 5.2.0
@@ -153,2 +153,9 @@ // Import packages | ||
* }}).then(() => console.log('device was changed')) | ||
* @example | ||
* // set custom property for a specific (virtual) deviceId | ||
* tuya.set({ | ||
* dps: 2, | ||
* set: false, | ||
* devId: '04314116cc50e346566e' | ||
* }).then(() => console.log('device was turned off')) | ||
* @returns {Promise<Object>} - returns response from device | ||
@@ -182,3 +189,3 @@ */ | ||
const payload = { | ||
devId: this.device.id, | ||
devId: options.devId || this.device.id, | ||
gwId: this.device.gwID, | ||
@@ -185,0 +192,0 @@ uid: '', |
@@ -74,3 +74,3 @@ const crypto = require('crypto'); | ||
result += decipher.final('utf8'); | ||
} catch (error) { | ||
} catch (_) { | ||
// Try the universal key, in case it's a new UDP message format | ||
@@ -81,3 +81,3 @@ try { | ||
result += decipher.final('utf8'); | ||
} catch (error) { | ||
} catch (_) { | ||
throw new Error('Decrypt failed'); | ||
@@ -91,3 +91,3 @@ } | ||
return JSON.parse(result); | ||
} catch (error) { | ||
} catch (_) { | ||
return result; | ||
@@ -104,5 +104,5 @@ } | ||
const md5hash = crypto.createHash('md5').update(data, 'utf8').digest('hex'); | ||
return md5hash.substr(8, 16); | ||
return md5hash.slice(8, 24); | ||
} | ||
} | ||
module.exports = TuyaCipher; |
@@ -185,3 +185,3 @@ const Cipher = require('./cipher'); | ||
data = this.cipher.decrypt(data); | ||
} catch (error) { | ||
} catch (_) { | ||
data = data.toString('utf8'); | ||
@@ -195,3 +195,3 @@ } | ||
data = JSON.parse(data); | ||
} catch (error) { } | ||
} catch (_) { } | ||
} | ||
@@ -252,3 +252,3 @@ | ||
// Check command byte | ||
if (Object.values(CommandType).indexOf(options.commandByte) === -1) { | ||
if (!Object.values(CommandType).includes(options.commandByte)) { | ||
throw new TypeError('Command byte not defined.'); | ||
@@ -255,0 +255,0 @@ } |
{ | ||
"name": "tuyapi", | ||
"version": "5.1.3", | ||
"version": "5.2.0", | ||
"description": "An easy-to-use API for devices that use Tuya's cloud services", | ||
@@ -41,14 +41,14 @@ "main": "index.js", | ||
"debug": "4.1.1", | ||
"p-retry": "4.1.0", | ||
"p-timeout": "3.1.0" | ||
"p-retry": "4.2.0", | ||
"p-timeout": "3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@tuyapi/stub": "0.1.4", | ||
"ava": "2.3.0", | ||
"ava": "2.4.0", | ||
"clone": "2.1.2", | ||
"coveralls": "3.0.6", | ||
"coveralls": "3.0.9", | ||
"delay": "4.3.0", | ||
"documentation": "12.1.1", | ||
"nyc": "14.1.1", | ||
"xo": "0.24.0" | ||
"documentation": "12.1.4", | ||
"nyc": "15.0.0", | ||
"xo": "0.25.4" | ||
}, | ||
@@ -55,0 +55,0 @@ "xo": { |
@@ -101,2 +101,4 @@ # TuyAPI 🌧 🔌 | ||
- Newer firmware may use protocol 3.3. If you are not using `find()`, you will need to manually pass `version: 3.3` to the constructor. | ||
- TuyAPI does not support sensors due to the fact that they only connect to the network when their state changes. There are no plans to add support as it's out of scope to intercept network requests. | ||
- The key parameter for devices changes every time a device is removed and re-added to the TuyaSmart app. If you're getting decrypt errors, try getting the key again - it might have changed. | ||
@@ -103,0 +105,0 @@ |
42811
976
163
+ Addedp-retry@4.2.0(transitive)
+ Addedp-timeout@3.2.0(transitive)
- Removedp-retry@4.1.0(transitive)
- Removedp-timeout@3.1.0(transitive)
Updatedp-retry@4.2.0
Updatedp-timeout@3.2.0