diff --git a/abilities/battery.js b/abilities/battery.js index c78fe4a..cd452ff 100644 --- a/abilities/battery.js +++ b/abilities/battery.js @@ -25,7 +25,7 @@ module.exports = homebridge => { } get level() { - return this.device[this._levelProperty] + return Math.min(Math.max(this.device[this._levelProperty], 0), 100) } get chargingState() { diff --git a/abilities/humidity-sensor.js b/abilities/humidity-sensor.js index 7abf763..b8fd8f1 100644 --- a/abilities/humidity-sensor.js +++ b/abilities/humidity-sensor.js @@ -16,6 +16,10 @@ module.exports = homebridge => { humidityProperty ) } + + _valueToHomeKit(value) { + return Math.min(Math.max(value, 0), 100) + } } return HumiditySensorAbility diff --git a/abilities/light-sensor.js b/abilities/light-sensor.js index 8566c25..067b70a 100644 --- a/abilities/light-sensor.js +++ b/abilities/light-sensor.js @@ -30,6 +30,10 @@ module.exports = homebridge => { return service } + + _valueToHomeKit(value) { + return Math.min(Math.max(value, 0.0001), 500000) + } } return LightSensorAbility diff --git a/abilities/power-meter.js b/abilities/power-meter.js index 8962a17..1ec803f 100644 --- a/abilities/power-meter.js +++ b/abilities/power-meter.js @@ -31,7 +31,10 @@ module.exports = homebridge => { } get consumption() { - return this.device[this._consumptionProperty] + return Math.min( + Math.max(this.device[this._consumptionProperty], 0), + 65535 + ) } get electricCurrent() { diff --git a/abilities/temperature-sensor.js b/abilities/temperature-sensor.js index 33096b4..e9dc408 100644 --- a/abilities/temperature-sensor.js +++ b/abilities/temperature-sensor.js @@ -27,6 +27,10 @@ module.exports = homebridge => { return service } + + _valueToHomeKit(value) { + return Math.min(Math.max(value, -270), 100) + } } return TemperatureSensorAbility