Release 5.0.0

This commit is contained in:
tsightler
2022-02-22 09:25:46 -05:00
parent c9baf0cc8d
commit 410ed1c763
3 changed files with 12 additions and 12 deletions

View File

@@ -47,33 +47,33 @@ class Mqtt {
// MQTT initialization successful, setup actions for MQTT events
start() {
const mqttLib = this
const mqtt = this
// On MQTT connect/reconnect send config/state information after delay
this.client.on('connect', async function () {
if (!mqttLib.connected) {
mqttLib.connected = true
if (!mqtt.connected) {
mqtt.connected = true
debug('MQTT connection established, processing locations...')
}
mqttLib.ring.processLocations(mqttLib)
mqtt.ring.processLocations(mqttLib)
})
this.client.on('reconnect', function () {
if (mqttLib.connected) {
if (mqtt.connected) {
debug('Connection to MQTT broker lost. Attempting to reconnect...')
} else {
debug('Attempting to reconnect to MQTT broker...')
}
mqttLib.connected = false
mqtt.connected = false
})
this.client.on('error', function (error) {
debug('Unable to connect to MQTT broker.', error.message)
mqttLib.connected = false
mqtt.connected = false
})
// Process MQTT messages from subscribed command topics
this.client.on('message', async function (topic, message) {
mqttLib.processMessage(topic, message)
mqtt.processMessage(topic, message)
})
}
@@ -105,7 +105,7 @@ class Mqtt {
}
} else {
// Parse topic to get location/device ID
const ringTopicLevels = (this.config.data.ring_topic).split('/').length
const ringTopicLevels = (this.config.ring_topic).split('/').length
splitTopic = topic.split('/')
const locationId = splitTopic[ringTopicLevels]
const deviceId = splitTopic[ringTopicLevels + 2]

View File

@@ -49,8 +49,8 @@ class Ring {
}
// Loop through each location and call publishLocation for supported/connected devices
async processLocations(mqttLib) {
this.mqtt = mqttLib
async processLocations(mqtt) {
this.mqtt = mqtt
// Update Ring location and device data
await this.updateRingData()

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env node
// Defines
const config = require('./lib/config')
const state = require('./lib/state')
const ring = require('./lib/ring')
@@ -129,6 +128,7 @@ const main = async(generatedToken) => {
}
}
// Subscribe to token updates from token Web UI
tokenApp.token.registerListener(function(generatedToken) {
main(generatedToken)
})