mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-10 22:04:50 +01:00
Merge pull request #169 from lukeredpath/fix-domoticz-dimmer-handling
Fix domoticz dimmer handling
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
// - Added support for Scenes
|
// - Added support for Scenes
|
||||||
// - Sorting device names
|
// - Sorting device names
|
||||||
//
|
//
|
||||||
|
// 22 July 2015 [lukeredpath]
|
||||||
|
// - Added SSL and basic auth support
|
||||||
|
//
|
||||||
// 26 August 2015 [EddyK69]
|
// 26 August 2015 [EddyK69]
|
||||||
// - Added parameter in config.json: 'loadscenes' for enabling/disabling loading scenes
|
// - Added parameter in config.json: 'loadscenes' for enabling/disabling loading scenes
|
||||||
// - Fixed issue with dimmer-range; was 0-100, should be 0-16
|
// - Fixed issue with dimmer-range; was 0-100, should be 0-16
|
||||||
@@ -17,6 +20,10 @@
|
|||||||
// - Fixed issue that 'on-off'-type lights would not react on Siri 'Switch on/off light'; On/Off types are now handled as Lights instead of Switches
|
// - Fixed issue that 'on-off'-type lights would not react on Siri 'Switch on/off light'; On/Off types are now handled as Lights instead of Switches
|
||||||
// (Cannot determine if 'on/off'-type device is a Light or a Switch :( )
|
// (Cannot determine if 'on/off'-type device is a Light or a Switch :( )
|
||||||
//
|
//
|
||||||
|
// 14 September 2015 [lukeredpath]
|
||||||
|
// - Fixed incorrect dimmer range for LightwaveRF lights (0-32 required, MaxDimLevel should be honored)
|
||||||
|
//
|
||||||
|
//
|
||||||
// Domoticz JSON API required
|
// Domoticz JSON API required
|
||||||
// https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's#Lights_and_switches
|
// https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's#Lights_and_switches
|
||||||
//
|
//
|
||||||
@@ -183,9 +190,7 @@ DomoticzAccessory.prototype = {
|
|||||||
url = this.platform.urlForQuery("type=command¶m=setcolbrightnessvalue&idx=" + this.idx + "&hue=" + value + "&brightness=100" + "&iswhite=false");
|
url = this.platform.urlForQuery("type=command¶m=setcolbrightnessvalue&idx=" + this.idx + "&hue=" + value + "&brightness=100" + "&iswhite=false");
|
||||||
}
|
}
|
||||||
else if (c == "setLevel") {
|
else if (c == "setLevel") {
|
||||||
//Range should be 0-16 instead of 0-100
|
value = this.dimmerLevelForValue(value)
|
||||||
//See http://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Set_a_dimmable_light_to_a_certain_level
|
|
||||||
value = Math.round((value / 100) * 16)
|
|
||||||
url = this.platform.urlForQuery("type=command¶m=switchlight&idx=" + this.idx + "&switchcmd=Set%20Level&level=" + value);
|
url = this.platform.urlForQuery("type=command¶m=switchlight&idx=" + this.idx + "&switchcmd=Set%20Level&level=" + value);
|
||||||
}
|
}
|
||||||
else if (value != undefined) {
|
else if (value != undefined) {
|
||||||
@@ -208,11 +213,19 @@ DomoticzAccessory.prototype = {
|
|||||||
that.log("There was a problem sending command " + c + " to" + that.name);
|
that.log("There was a problem sending command " + c + " to" + that.name);
|
||||||
that.log(url);
|
that.log(url);
|
||||||
} else {
|
} else {
|
||||||
that.log(that.name + " sent command " + c);
|
that.log(that.name + " sent command " + c + " (value: " + value + ")");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// translates the HomeKit dim level as a percentage to whatever scale the device requires
|
||||||
|
dimmerLevelForValue: function(value) {
|
||||||
|
if (this.MaxDimLevel == 100) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return Math.round((value / 100.0) * this.MaxDimLevel)
|
||||||
|
},
|
||||||
|
|
||||||
informationCharacteristics: function() {
|
informationCharacteristics: function() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -362,4 +375,4 @@ DomoticzAccessory.prototype = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.accessory = DomoticzAccessory;
|
module.exports.accessory = DomoticzAccessory;
|
||||||
module.exports.platform = DomoticzPlatform;
|
module.exports.platform = DomoticzPlatform;
|
||||||
|
|||||||
Reference in New Issue
Block a user