Skip to content

Commit

Permalink
Publish Mi Flora discovery even when attribute not present in measure…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
mikakoivisto committed Jun 13, 2024
1 parent 9e43f86 commit 0c0ecdd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class App {
precision: 1,
stateTopicPostfix: "temperature",
battery: false,
skipAttributeCheck: true,
});
this.publishSensorDiscovery(measurement, {
deviceClass: "moisture",
Expand All @@ -278,6 +279,7 @@ class App {
icon: "mdi:water-percent",
stateTopicPostfix: "moisture",
battery: false,
skipAttributeCheck: true,
});
this.publishSensorDiscovery(measurement, {
deviceClass: "illuminance",
Expand All @@ -288,6 +290,7 @@ class App {
precision: 0,
stateTopicPostfix: "illuminance",
battery: false,
skipAttributeCheck: true,
});
this.publishSensorDiscovery(measurement, {
namePostfix: "conductivity",
Expand All @@ -298,14 +301,15 @@ class App {
precision: 0,
stateTopicPostfix: "conductivity",
battery: false,
skipAttributeCheck: true,
});
break;
}
}

publishSensorDiscovery(measurement, disco) {
let self = this;
if (!measurement[disco.jsonAttribute]) {
if (!measurement[disco.jsonAttribute] && !disco.skipAttributeCheck) {
logDebug(`${disco.jsonAttribute} not present in measurement for tag ${measurement.mac}, skipping discovery`);
return;
}
Expand Down

0 comments on commit 0c0ecdd

Please sign in to comment.