Release 5.0.0

This commit is contained in:
tsightler
2022-02-21 23:53:05 -05:00
parent e23fc20f3e
commit aea8ba7dc4
2 changed files with 10 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ const { RingApi, RingDeviceType, RingCamera, RingChime } = require('@tsightler/r
const debug = require('debug')('ring-mqtt')
const colors = require('colors/safe')
const utils = require('./utils.js')
const rss = require('./rtsp-simple-server.js')
const BaseStation = require('../devices/base-station')
const Beam = require('../devices/beam')
const BeamOutdoorPlug = require('../devices/beam-outdoor-plug')
@@ -33,9 +34,8 @@ class Ring {
this.republishCount = 6 // Republish config/state this many times after startup or HA start/restart
}
async init(ringAuth, config, rssLib, tokenSource) {
async init(ringAuth, config, tokenSource) {
this.config = config
this.rss = rssLib
try {
debug(`Attempting connection to Ring API using ${tokenSource} refresh token.`)
this.client = new RingApi(ringAuth)
@@ -189,8 +189,8 @@ class Ring {
debug('Ring location/device data updated, sleeping for 5 seconds.')
await utils.sleep(2)
const cameras = await this.devices.filter(d => d.device instanceof RingCamera)
if (cameras.length > 0 && !this.rss.started) {
await this.rss.start(cameras)
if (cameras.length > 0 && !rss.started) {
await rss.start(cameras)
}
await utils.sleep(3)
}
@@ -297,6 +297,10 @@ class Ring {
this.republishCount--
}
}
async rssShutdown() {
await rss.shutdown()
}
}
module.exports = new Ring()

View File

@@ -10,7 +10,6 @@ const debug = require('debug')('ring-mqtt')
const colors = require('colors/safe')
const utils = require('./lib/utils.js')
const tokenApp = require('./lib/tokenapp.js')
const rss = require('./lib/rtsp-simple-server.js')
// Setup Exit Handlers
process.on('exit', processExit.bind(null, 0))
@@ -40,7 +39,7 @@ process.on('unhandledRejection', function(err) {
async function processExit(exitCode) {
await utils.sleep(1)
debug('The ring-mqtt process is shutting down...')
rss.shutdown()
await ring.rssShutdown()
if (ring.devices.length > 0) {
debug('Setting all devices offline...')
await utils.sleep(1)
@@ -111,7 +110,7 @@ const main = async(generatedToken) => {
...!(config.data.location_ids === undefined || config.data.location_ids == 0) ? { locationIds: config.data.location_ids } : {}
}
if (await ring.init(ringAuth, config.data, rss, generatedToken ? 'generated' : 'saved')) {
if (await ring.init(ringAuth, config.data, generatedToken ? 'generated' : 'saved')) {
debug('Successfully established connection to Ring API')
// Update the web app with current connected refresh token