Skip to content

Commit

Permalink
Add handling for transient MQTT metrics (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGodbehere authored Aug 3, 2023
1 parent c08e0e1 commit 0100aa3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/mqttclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}, {}));
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0100aa3

Please sign in to comment.