homebridge-xiaomi-yeelight
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -19,2 +19,4 @@ import { PlatformAccessory, CharacteristicValue } from 'homebridge'; | ||
constructor(platform: XiaomiYeelightPlatform, accessory: PlatformAccessory); | ||
convertColorTempFromKelvinToMired(value: number): number; | ||
convertColorTempFromMiredToKelvin(value: number): number; | ||
/** | ||
@@ -39,3 +41,7 @@ * Handle "SET" requests from HomeKit | ||
getOn(): Promise<CharacteristicValue>; | ||
setBrightness(value: CharacteristicValue): Promise<void>; | ||
getBrightness(): Promise<CharacteristicValue>; | ||
setColorTemperature(value: CharacteristicValue): Promise<void>; | ||
getColorTemperature(): Promise<CharacteristicValue>; | ||
} | ||
//# sourceMappingURL=platformAccessory.d.ts.map |
@@ -49,8 +49,16 @@ "use strict"; | ||
// // register handlers for the Brightness Characteristic | ||
// this.service.getCharacteristic(this.platform.Characteristic.Brightness) | ||
// .onSet(this.setBrightness.bind(this)); // SET - bind to the 'setBrightness` method below | ||
this.service.getCharacteristic(this.platform.Characteristic.Brightness) | ||
.onSet(this.setBrightness.bind(this)) // SET - bind to the 'setBrightness` method below | ||
.onGet(this.getBrightness.bind(this)); // SET - bind to the 'setBrightness` method below | ||
// // register handlers for the ColorTemperature Characteristic | ||
// this.service.getCharacteristic(this.platform.Characteristic.ColorTemperature) | ||
// .onSet(this.setColorTemperature.bind(this)); // SET - bind to the 'setColorTemperature` method below | ||
this.service.getCharacteristic(this.platform.Characteristic.ColorTemperature) | ||
.onSet(this.setColorTemperature.bind(this)) // SET - bind to the 'setColorTemperature` method below | ||
.onGet(this.getColorTemperature.bind(this)); // SET - bind to the 'setColorTemperature` method below | ||
} | ||
convertColorTempFromKelvinToMired(value) { | ||
return 1000000 / value; | ||
} | ||
convertColorTempFromMiredToKelvin(value) { | ||
return 1000000 / value; | ||
} | ||
/** | ||
@@ -94,4 +102,60 @@ * Handle "SET" requests from HomeKit | ||
} | ||
// /** | ||
// * Handle "SET" requests from HomeKit | ||
// * These are sent when the user changes the state of an accessory, for example, changing the Brightness | ||
// */ | ||
async setBrightness(value) { | ||
// implement your own code to set the brightness | ||
this.state.Brightness = value; | ||
this.platform.log.info('setting brightness to', value); | ||
try { | ||
await this.connection.setBrightness(value); | ||
this.platform.log.info('brightness set successfully'); | ||
} | ||
catch (e) { | ||
this.platform.log.error(e); | ||
} | ||
} | ||
// /** | ||
// * Handle "SET" requests from HomeKit | ||
// * These are sent when the user changes the state of an accessory, for example, changing the Brightness | ||
// */ | ||
async getBrightness() { | ||
try { | ||
this.platform.log.info('requesting brightness'); | ||
const brightness = await this.connection.brightness(); | ||
return brightness; | ||
} | ||
catch (e) { | ||
this.platform.log.error(e); | ||
throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */); | ||
} | ||
} | ||
async setColorTemperature(value) { | ||
// implement your own code to set the brightness | ||
this.state.ColorTemperature = value; | ||
this.platform.log.info('setting color temp to', value, 'in kelvin:', this.convertColorTempFromMiredToKelvin(value)); | ||
try { | ||
await this.connection.colorthis.convertColorTempFromMiredToKelvin(value); | ||
this.platform.log.info('color temp set successfully'); | ||
} | ||
catch (e) { | ||
this.platform.log.error(e); | ||
} | ||
} | ||
async getColorTemperature() { | ||
try { | ||
this.platform.log.info('requesting color temperature'); | ||
let colorTemp = await this.connection.color(); | ||
colorTemp = this.convertColorTempFromKelvinToMired(colorTemp.values[0]); | ||
this.platform.log.info(colorTemp); | ||
return colorTemp; | ||
} | ||
catch (e) { | ||
this.platform.log.error(e); | ||
throw new this.platform.api.hap.HapStatusError(-70402 /* SERVICE_COMMUNICATION_FAILURE */); | ||
} | ||
} | ||
} | ||
exports.Light = Light; | ||
//# sourceMappingURL=platformAccessory.js.map |
{ | ||
"displayName": "Xiaomi Yeelight Support", | ||
"name": "homebridge-xiaomi-yeelight", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A short description about what your plugin does.", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49101
481