Files
tuya-mqtt/lib/utils.js
tsightler 60b50c760e 3.0.0-beta4
* Default to generic device
* Improved debugging granularity/increased categories
* Add heartbeat monitoring for availability
* Catch more failure cases with retry (still some missing I'd guess)
* Switch to MathJS evaluate for simple math transforms
* RGBTW: Switch base scale for all friendly topics to 100 (automatic conversion on backend)
* RGBTW: Add color temperature support
* RGBTW: Improve autodetection
* RGBTW: Improved white/color mode handling (still work to do here)
2020-10-12 16:14:22 -04:00

28 lines
564 B
JavaScript

class Utils
{
// Check if data is JSON or not
isJsonString(data) {
try {
const parsedData = JSON.parse(data)
if (parsedData && typeof parsedData === "object") {
return parsedData
}
}
catch (e) { }
return false
}
// Simple sleep function for various required delays
sleep(sec) {
return new Promise(res => setTimeout(res, sec*1000))
}
msSleep(ms) {
return new Promise(res => setTimeout(res, ms))
}
}
module.exports = new Utils()