mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 00:10:20 +00:00
* Implement basic template model * Generic device can specify template in devices.conf * Simple switch, dimmer, and RGBTW specific support files
24 lines
484 B
JavaScript
24 lines
484 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))
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = new Utils() |