From d5de0ee8fb60229aa1cf0d4ad974e72009afbff7 Mon Sep 17 00:00:00 2001 From: Phil Kulak Date: Thu, 27 Oct 2022 06:23:56 -0700 Subject: [PATCH 1/2] fix(mqtt): only retain state and configuration, not events. (#249) Co-authored-by: Phil Kulak --- api/src/util/mqtt.util.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/api/src/util/mqtt.util.js b/api/src/util/mqtt.util.js index e5dfe418..a702b62b 100644 --- a/api/src/util/mqtt.util.js +++ b/api/src/util/mqtt.util.js @@ -116,7 +116,7 @@ module.exports.connect = () => { }; module.exports.available = async (state) => { - if (CLIENT) this.publish({ topic: 'double-take/available', message: state }); + if (CLIENT) this.publish({ topic: 'double-take/available', retain: true, message: state }); }; module.exports.subscribe = () => { @@ -196,18 +196,21 @@ module.exports.recognize = (data) => { messages.push({ topic: `${MQTT.TOPICS.CAMERAS}/${camera}/person`, + retain: true, message: counts.person.toString(), }); if (unknowns.length) { messages.push({ topic: `${MQTT.TOPICS.MATCHES}/unknown`, + retain: false, message: JSON.stringify(payload.unknown), }); if (MQTT.TOPICS.HOMEASSISTANT) { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/unknown/config`, + retain: true, message: JSON.stringify({ name: 'double_take_unknown', icon: 'mdi:account', @@ -221,6 +224,7 @@ module.exports.recognize = (data) => { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/unknown/state`, + retain: true, message: JSON.stringify(payload.unknown), }); } @@ -232,6 +236,7 @@ module.exports.recognize = (data) => { messages.push({ topic: `${MQTT.TOPICS.MATCHES}/${topic}`, + retain: false, message: JSON.stringify({ ...payload.match, match, @@ -241,6 +246,7 @@ module.exports.recognize = (data) => { if (MQTT.TOPICS.HOMEASSISTANT) { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/${topic}/config`, + retain: true, message: JSON.stringify({ name: `double_take_${name}`, icon: 'mdi:account', @@ -254,6 +260,7 @@ module.exports.recognize = (data) => { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/${topic}/state`, + retain: true, message: JSON.stringify({ ...payload.match, match, @@ -265,12 +272,14 @@ module.exports.recognize = (data) => { if (matches.length || misses.length || unknowns.length) { messages.push({ topic: `${MQTT.TOPICS.CAMERAS}/${camera}`, + retain: false, message: JSON.stringify(payload.camera), }); if (MQTT.TOPICS.HOMEASSISTANT) { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/${camera}/config`, + retain: true, message: JSON.stringify({ name: `double_take_${camera}`, icon: 'mdi:camera', @@ -284,6 +293,7 @@ module.exports.recognize = (data) => { messages.push({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/${camera}/state`, + retain: true, message: JSON.stringify(payload.camera), }); } @@ -293,10 +303,11 @@ module.exports.recognize = (data) => { clearTimeout(PERSON_RESET_TIMEOUT[camera]); PERSON_RESET_TIMEOUT[camera] = setTimeout(() => { - this.publish({ topic: `${MQTT.TOPICS.CAMERAS}/${camera}/person`, message: '0' }); + this.publish({ topic: `${MQTT.TOPICS.CAMERAS}/${camera}/person`, retain: true, message: '0' }); if (MQTT.TOPICS.HOMEASSISTANT) { this.publish({ topic: `${MQTT.TOPICS.HOMEASSISTANT}/sensor/double-take/${camera}/state`, + retain: true, message: JSON.stringify(payload.cameraReset), }); } @@ -315,7 +326,7 @@ module.exports.publish = (data) => { if (!single && !multiple) console.error('MQTT: publish error'); const messages = single ? [{ ...data }] : data; - messages.forEach((message) => CLIENT.publish(message.topic, message.message, { retain: true })); + messages.forEach((message) => CLIENT.publish(message.topic, message.message, { retain: message.retain === true })); }; module.exports.status = () => ({ From b353068b937c526cfc34a5d436f1fc0fbe74c62f Mon Sep 17 00:00:00 2001 From: David Jakowenko Date: Thu, 27 Oct 2022 13:24:28 +0000 Subject: [PATCH 2/2] chore(release): 1.13.1-beta.1 [skip ci] ## [1.13.1-beta.1](https://github.com/jakowenko/double-take/compare/v1.13.0...v1.13.1-beta.1) (2022-10-27) ### Bug Fixes * **mqtt:** only retain state and configuration, not events. ([#249](https://github.com/jakowenko/double-take/issues/249)) ([d5de0ee](https://github.com/jakowenko/double-take/commit/d5de0ee8fb60229aa1cf0d4ad974e72009afbff7)) --- CHANGELOG.md | 7 +++++++ api/package-lock.json | 4 ++-- api/package.json | 2 +- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3149676..98fe5ed6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.13.1-beta.1](https://github.com/jakowenko/double-take/compare/v1.13.0...v1.13.1-beta.1) (2022-10-27) + + +### Bug Fixes + +* **mqtt:** only retain state and configuration, not events. ([#249](https://github.com/jakowenko/double-take/issues/249)) ([d5de0ee](https://github.com/jakowenko/double-take/commit/d5de0ee8fb60229aa1cf0d4ad974e72009afbff7)) + ## [1.13.0](https://github.com/jakowenko/double-take/compare/v1.12.1...v1.13.0) (2022-10-21) diff --git a/api/package-lock.json b/api/package-lock.json index 4aa83849..db731290 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -1,12 +1,12 @@ { "name": "double-take-api", - "version": "1.13.0", + "version": "1.13.1-beta.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "double-take-api", - "version": "1.13.0", + "version": "1.13.1-beta.1", "license": "MIT", "dependencies": { "@aws-sdk/client-rekognition": "^3.105.0", diff --git a/api/package.json b/api/package.json index da2eb5bf..d417df8e 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "double-take-api", - "version": "1.13.0", + "version": "1.13.1-beta.1", "description": "Unified UI and API for processing and training images for facial recognition", "scripts": { "start": "node server.js", diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e6183554..70a389e4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "double-take-frontend", - "version": "1.13.0", + "version": "1.13.1-beta.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "double-take-frontend", - "version": "1.13.0", + "version": "1.13.1-beta.1", "license": "MIT", "dependencies": { "ace-builds": "^1.5.3", diff --git a/frontend/package.json b/frontend/package.json index 72dd624c..6ac39650 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "double-take-frontend", - "version": "1.13.0", + "version": "1.13.1-beta.1", "description": "Unified UI and API for processing and training images for facial recognition", "scripts": { "serve": "vue-cli-service serve", diff --git a/package-lock.json b/package-lock.json index 81ae5880..f8ad6412 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "double-take", - "version": "1.13.0", + "version": "1.13.1-beta.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "double-take", - "version": "1.13.0", + "version": "1.13.1-beta.1", "license": "MIT", "devDependencies": { "@commitlint/cli": "^17.0.2", diff --git a/package.json b/package.json index 0297dd83..03377fab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "double-take", - "version": "1.13.0", + "version": "1.13.1-beta.1", "description": "Unified UI and API for processing and training images for facial recognition", "scripts": { "prepare": "husky install",