Skip to content

Commit

Permalink
try: brightness range for H6159
Browse files Browse the repository at this point in the history
  • Loading branch information
bwp91 committed Oct 7, 2020
1 parent cd27a9d commit cf0bfad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/device/led.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ module.exports = class deviceLED {

externalUpdate (accessory, newParams) {
const lightService = accessory.getService(Service.Lightbulb)
const newBrightness = accessory.context.gvModel === 'H6159'
? newParams.brightness
: Math.round((newParams.brightness / 254) * 100)
const rgb = {}
if (utils.hasProperty(newParams, 'colorTemInKelvin')) {
const rgbArray = cTemp.temp2rgb(newParams.colorTemInKelvin)
Expand All @@ -120,7 +123,7 @@ module.exports = class deviceLED {
const newColour = cConvert.rgb.hsv(rgb.r, rgb.g, rgb.b)
lightService
.updateCharacteristic(Characteristic.On, newParams.powerState === 'on')
.updateCharacteristic(Characteristic.Brightness, Math.round((newParams.brightness / 254) * 100))
.updateCharacteristic(Characteristic.Brightness, newBrightness)
.updateCharacteristic(Characteristic.Hue, newColour[0])
.updateCharacteristic(Characteristic.Saturation, newColour[1])
}
Expand Down

0 comments on commit cf0bfad

Please sign in to comment.