From 0100aa35952e0c9c3362280bcb64600e67f6d35c Mon Sep 17 00:00:00 2001 From: Alex Godbehere <114239316+AlexGodbehere@users.noreply.github.com> Date: Thu, 3 Aug 2023 12:19:49 +0100 Subject: [PATCH] Add handling for transient MQTT metrics (#19) --- lib/mqttclient.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/mqttclient.ts b/lib/mqttclient.ts index 8f8530e..13e2851 100644 --- a/lib/mqttclient.ts +++ b/lib/mqttclient.ts @@ -315,7 +315,8 @@ export default class MQTTClient { }, name: obj.name, type: obj.type, - alias: alias + alias: alias, + transient: !(obj.properties?.recordToDB?.value) }; return acc; }, {})); @@ -399,6 +400,10 @@ export default class MQTTClient { writeToInfluxDB(birth, topic: Topic, value) { if (value === null) return; + if (birth.transient) { + logger.debug(`Metric ${birth.name} is transient, not writing to InfluxDB`); + return; + } // Get the value after the last / let metricName = birth.name.split('/').pop();