diff --git a/lib/SimpleFanLightAccessory.js b/lib/SimpleFanLightAccessory.js index 7c86e6a0..b594951c 100644 --- a/lib/SimpleFanLightAccessory.js +++ b/lib/SimpleFanLightAccessory.js @@ -63,8 +63,8 @@ class SimpleFanLightAccessory extends BaseAccessory { characteristicBrightness = serviceLightbulb.getCharacteristic(Characteristic.Brightness) .setProps({ minValue: 0, - maxValue: 1000, - minStep: 100 + maxValue: 100, + minStep: 1 }) .updateValue(this.convertBrightnessFromTuyaToHomeKit(dps[this.dpBrightness])) .on('get', this.getBrightness.bind(this)) @@ -83,9 +83,11 @@ class SimpleFanLightAccessory extends BaseAccessory { if (changes.hasOwnProperty(this.dpLightOn) && characteristicLightOn && characteristicLightOn.value !== changes[this.dpLightOn]) characteristicLightOn.updateValue(changes[this.dpLightOn]); - if (changes.hasOwnProperty(this.dpBrightness) && characteristicBrightness && characteristicBrightness.value !== changes[this.dpBrightness]) - characteristicBrightness.updateValue(changes[this.dpBrightness]); - + if (changes.hasOwnProperty(this.dpBrightness) && characteristicBrightness && cha +racteristicBrightness.value !== changes[this.dpBrightness]) + characteristicBrightness.updateValue(this.convertBrightnessFromTuyaToHomeKit +(changes[this.dpBrightness])); + this.log.debug('SimpleFanLight changed: ' + JSON.stringify(state)); }); } @@ -182,23 +184,14 @@ class SimpleFanLightAccessory extends BaseAccessory { callback(); } - //Lightbulb Brightness getBrightness(callback) { - this.getState(this.dpBrightness, (err, dp) => { - if (err) return callback(err); - callback(null, this._getBrightness(dp)); - }); - } - - _getBrightness(dp) { - const {Characteristic} = this.hap; - return dp; + callback(null, this.convertBrightnessFromTuyaToHomeKit(this.device.state[this.dpBrig +htness])); } setBrightness(value, callback) { - const {Characteristic} = this.hap; - return this.setState(this.dpBrightness, value, callback); - callback(); + this.setState(this.dpBrightness, this.convertBrightnessFromHomeKitToTuya(value), cal +lback); } }