mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 00:10:20 +00:00
3.0.0-beta2
* Implement basic template model * Generic device can specify template in devices.conf * Simple switch, dimmer, and RGBTW specific support files
This commit is contained in:
24
lib/utils.js
Normal file
24
lib/utils.js
Normal file
@@ -0,0 +1,24 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user