mirror of
https://github.com/tsightler/ring-mqtt.git
synced 2025-10-17 22:30:47 +08:00

4.5.0 Release **New Features** * During motion detection events, battery cameras will now attempt to get snapshots from the livestream since they can't take snapshots while recording. This takes longer, is slightly less reliable, and doesn't always produce the best image quality, but it's almost always better than no snapshot. * Person detection attribute is available on camera motion sensors. This only works if you see "Person detected" events in the Ring app (needs more testing as my account does not support person detection for reasons unknown) * Last motion/ding events are available as attributes on cameras **Enhancements/Fixes** * Snapshot on motion reliability is improved for line powered cameras * Fixed various crashes in camera support * Docker/addon now uses newer Alpine build with Node v14 to hopefully fix issues with reconnecting to Ring API after network interruptions * Times in attributes now use a consistent format (ISO 8601 without milliseconds)
35 lines
820 B
JavaScript
35 lines
820 B
JavaScript
const fs = require('fs');
|
|
|
|
class Utils
|
|
{
|
|
|
|
// Sleep function (seconds)
|
|
sleep(sec) {
|
|
return this.msleep(sec*1000)
|
|
}
|
|
|
|
// Sleep function (milliseconds)
|
|
msleep(msec) {
|
|
return new Promise(res => setTimeout(res, msec))
|
|
}
|
|
|
|
// Function to check if file exist and, optionally, if it is over a given size
|
|
checkFile(file, sizeInBytes) {
|
|
sizeInBytes = sizeInBytes ? sizeInBytes : 0
|
|
if (!fs.existsSync(file)) {
|
|
return false
|
|
} else if (fs.statSync(file).size > sizeInBytes) {
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
}
|
|
|
|
// Return ISO time from epoch without milliseconds
|
|
getISOTime(epoch) {
|
|
return new Date(epoch).toISOString().slice(0,-5)+"Z"
|
|
}
|
|
}
|
|
|
|
module.exports = new Utils()
|