mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-31 22:04:12 +01:00
Merge remote-tracking branch 'nfarina/master' into HaveDimmer
This commit is contained in:
@@ -41,7 +41,9 @@
|
|||||||
"platform": "Domoticz",
|
"platform": "Domoticz",
|
||||||
"name": "Domoticz",
|
"name": "Domoticz",
|
||||||
"server": "127.0.0.1",
|
"server": "127.0.0.1",
|
||||||
"port": "8005"
|
"port": "8080",
|
||||||
|
"roomid": 0,
|
||||||
|
"loadscenes": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"platform": "PhilipsHue",
|
"platform": "PhilipsHue",
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
// - Added support for Scenes
|
// - Added support for Scenes
|
||||||
// - Sorting device names
|
// - Sorting device names
|
||||||
//
|
//
|
||||||
|
// 26 August 2015 [EddyK69]
|
||||||
|
// - Added parameter in config.json: 'loadscenes' for enabling/disabling loading scenes
|
||||||
|
// - Fixed issue with dimmer-range; was 0-100, should be 0-16
|
||||||
|
//
|
||||||
|
//
|
||||||
// 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
|
||||||
//
|
//
|
||||||
@@ -18,7 +23,8 @@
|
|||||||
// "name": "Domoticz",
|
// "name": "Domoticz",
|
||||||
// "server": "127.0.0.1",
|
// "server": "127.0.0.1",
|
||||||
// "port": "8080",
|
// "port": "8080",
|
||||||
// "roomid": 123 (0=no roomplan)
|
// "roomid": 123, (0=no roomplan)
|
||||||
|
// "loadscenes": 1 (0=disable scenes)
|
||||||
// }
|
// }
|
||||||
// ],
|
// ],
|
||||||
//
|
//
|
||||||
@@ -47,6 +53,10 @@ function DomoticzPlatform(log, config){
|
|||||||
if (typeof config["roomid"] != 'undefined') {
|
if (typeof config["roomid"] != 'undefined') {
|
||||||
this.roomid = config["roomid"];
|
this.roomid = config["roomid"];
|
||||||
}
|
}
|
||||||
|
this.loadscenes = 1;
|
||||||
|
if (typeof config["loadscenes"] != 'undefined') {
|
||||||
|
this.loadscenes = config["loadscenes"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByKey(array, key) {
|
function sortByKey(array, key) {
|
||||||
@@ -120,24 +130,26 @@ DomoticzPlatform.prototype = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
//Get Scenes
|
//Get Scenes
|
||||||
asyncCalls++;
|
if (this.loadscenes == 1) {
|
||||||
request.get({
|
asyncCalls++;
|
||||||
url: this.urlForQuery("type=scenes"),
|
request.get({
|
||||||
json: true
|
url: this.urlForQuery("type=scenes"),
|
||||||
}, function(err, response, json) {
|
json: true
|
||||||
if (!err && response.statusCode == 200) {
|
}, function(err, response, json) {
|
||||||
if (json['result'] != undefined) {
|
if (!err && response.statusCode == 200) {
|
||||||
var sArray=sortByKey(json['result'],"Name");
|
if (json['result'] != undefined) {
|
||||||
sArray.map(function(s) {
|
var sArray=sortByKey(json['result'],"Name");
|
||||||
accessory = new DomoticzAccessory(that.log, that, true, s.idx, s.Name, false, 0, false);
|
sArray.map(function(s) {
|
||||||
foundAccessories.push(accessory);
|
accessory = new DomoticzAccessory(that.log, that, true, s.idx, s.Name, false, 0, false);
|
||||||
})
|
foundAccessories.push(accessory);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
callbackLater();
|
||||||
|
} else {
|
||||||
|
that.log("There was a problem connecting to Domoticz.");
|
||||||
}
|
}
|
||||||
callbackLater();
|
});
|
||||||
} else {
|
}
|
||||||
that.log("There was a problem connecting to Domoticz.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +177,9 @@ 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
|
||||||
|
//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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user