mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-16 09:44:36 +00:00
* 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)
28 lines
564 B
JavaScript
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() |