mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-09 22:06:55 +01:00
use the percent functions from node-hue-api
This commit is contained in:
+4
-11
@@ -60,22 +60,15 @@ var execute = function(api, device, characteristic, value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (characteristic === "hue") {
|
else if (characteristic === "hue") {
|
||||||
value = value/360;
|
value = value*182.5487;
|
||||||
value = value*65535;
|
|
||||||
value = Math.round(value);
|
value = Math.round(value);
|
||||||
state.hue(value);
|
state.hue(value);
|
||||||
}
|
}
|
||||||
else if (characteristic === "brightness") {
|
else if (characteristic === "brightness") {
|
||||||
value = value/100;
|
state.brightness(value);
|
||||||
value = value*255;
|
|
||||||
value = Math.round(value);
|
|
||||||
state.bri(value);
|
|
||||||
}
|
}
|
||||||
else if (characteristic === "saturation") {
|
else if (characteristic === "saturation") {
|
||||||
value = value/100;
|
state.saturation(value);
|
||||||
value = value*255;
|
|
||||||
value = Math.round(value);
|
|
||||||
state.sat(value);
|
|
||||||
}
|
}
|
||||||
api.setLightState(device.id, state, function(err, lights) {
|
api.setLightState(device.id, state, function(err, lights) {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
@@ -227,7 +220,7 @@ PhilipsHueAccessory.prototype = {
|
|||||||
supportBonjour: false,
|
supportBonjour: false,
|
||||||
manfDescription: "Adjust Saturation of Light",
|
manfDescription: "Adjust Saturation of Light",
|
||||||
designedMinValue: 0,
|
designedMinValue: 0,
|
||||||
designedMaxValue: 255,
|
designedMaxValue: 100,
|
||||||
designedMinStep: 1,
|
designedMinStep: 1,
|
||||||
unit: "%"
|
unit: "%"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user