Skip to content

Commit

Permalink
Don't report when value or thresholds are nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Leendert de Kok committed Aug 31, 2024
1 parent 2e66a9a commit a579c6e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/MiFloraDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,13 @@ export default class MiFloraDevice extends Homey.Device {
*/
_checkThresholdTrigger(capability: string, value: string | number) {
const capabilityAlias = capability as CombinedCapabilities;
console.log(this.getApp()?.thresholdMapping[capabilityAlias] ?? `No mapping found for ${capabilityAlias}`);
const minValue = this.getSetting(this.getApp().thresholdMapping[capabilityAlias].min);
const maxValue = this.getSetting(this.getApp().thresholdMapping[capabilityAlias].max);

if (!value || !minValue || !maxValue) {
return;
}

if (value < minValue) {
if (this.hasCapability(capability.replace('measure_', 'alarm_'))) {
this.setCapabilityValue(capability.replace('measure_', 'alarm_'), true);
Expand Down

0 comments on commit a579c6e

Please sign in to comment.