mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Working towards getting the extra dimmers in one accessory
Having trouble with service subtypes…hmm…
This commit is contained in:
@@ -113,10 +113,16 @@ ZWayServerPlatform.prototype = {
|
|||||||
if(vdev.tags.indexOf("Homebridge:Skip") >= 0) { debug("Tag says skip!"); continue; }
|
if(vdev.tags.indexOf("Homebridge:Skip") >= 0) { debug("Tag says skip!"); continue; }
|
||||||
if(this.opt_in && vdev.tags.indexOf("Homebridge:Include") < 0) continue;
|
if(this.opt_in && vdev.tags.indexOf("Homebridge:Include") < 0) continue;
|
||||||
var gdid = vdev.id.replace(/^(.*?)_zway_(\d+-\d+)-\d.*/, '$1_$2');
|
var gdid = vdev.id.replace(/^(.*?)_zway_(\d+-\d+)-\d.*/, '$1_$2');
|
||||||
var gd = groupedDevices[gdid] || (groupedDevices[gdid] = {devices: [], types: {}, primary: undefined});
|
var gd = groupedDevices[gdid] || (groupedDevices[gdid] = {devices: [], types: {}, extras: {}, primary: undefined});
|
||||||
gd.devices.push(vdev);
|
gd.devices.push(vdev);
|
||||||
gd.types[ZWayServerPlatform.getVDevTypeKey(vdev)] = gd.devices.length - 1;
|
var tk = ZWayServerPlatform.getVDevTypeKey(vdev);
|
||||||
gd.types[vdev.deviceType] = gd.devices.length - 1; // also include the deviceType only as a possibility
|
if(gd.types[tk] === undefined){
|
||||||
|
gd.types[tk] = gd.devices.length - 1;
|
||||||
|
} else {
|
||||||
|
gd.extras[tk] = gd.extras[tk] || [];
|
||||||
|
gd.extras[tk].push(gd.devices.length - 1);
|
||||||
|
}
|
||||||
|
if(tk !== vdev.deviceType) gd.types[vdev.deviceType] = gd.devices.length - 1; // also include the deviceType only as a possibility
|
||||||
}
|
}
|
||||||
//TODO: Make a second pass, re-splitting any devices that don't make sense together
|
//TODO: Make a second pass, re-splitting any devices that don't make sense together
|
||||||
for(var gdid in groupedDevices) {
|
for(var gdid in groupedDevices) {
|
||||||
@@ -250,25 +256,25 @@ ZWayServerAccessory.prototype = {
|
|||||||
var services = [], service;
|
var services = [], service;
|
||||||
switch (typeKey) {
|
switch (typeKey) {
|
||||||
case "switchBinary":
|
case "switchBinary":
|
||||||
services.push(new Service.Switch(vdev.metrics.title));
|
services.push(new Service.Switch(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "switchMultilevel":
|
case "switchMultilevel":
|
||||||
services.push(new Service.Lightbulb(vdev.metrics.title));
|
services.push(new Service.Lightbulb(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "thermostat":
|
case "thermostat":
|
||||||
services.push(new Service.Thermostat(vdev.metrics.title));
|
services.push(new Service.Thermostat(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "sensorMultilevel.Temperature":
|
case "sensorMultilevel.Temperature":
|
||||||
services.push(new Service.TemperatureSensor(vdev.metrics.title));
|
services.push(new Service.TemperatureSensor(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "sensorBinary.Door/Window":
|
case "sensorBinary.Door/Window":
|
||||||
services.push(new Service.GarageDoorOpener(vdev.metrics.title));
|
services.push(new Service.GarageDoorOpener(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "battery.Battery":
|
case "battery.Battery":
|
||||||
services.push(new Service.BatteryService(vdev.metrics.title));
|
services.push(new Service.BatteryService(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
case "sensorMultilevel.Luminiscence":
|
case "sensorMultilevel.Luminiscence":
|
||||||
services.push(new Service.LightSensor(vdev.metrics.title));
|
services.push(new Service.LightSensor(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +341,7 @@ ZWayServerAccessory.prototype = {
|
|||||||
}
|
}
|
||||||
,
|
,
|
||||||
configureCharacteristic: function(cx, vdev){
|
configureCharacteristic: function(cx, vdev){
|
||||||
var that, accessory = this;
|
var accessory = this;
|
||||||
|
|
||||||
// Add this combination to the maps...
|
// Add this combination to the maps...
|
||||||
if(!this.platform.cxVDevMap[vdev.id]) this.platform.cxVDevMap[vdev.id] = [];
|
if(!this.platform.cxVDevMap[vdev.id]) this.platform.cxVDevMap[vdev.id] = [];
|
||||||
@@ -349,7 +355,7 @@ ZWayServerAccessory.prototype = {
|
|||||||
cx.value = cx.zway_getValueFromVDev(vdev);
|
cx.value = cx.zway_getValueFromVDev(vdev);
|
||||||
cx.on('get', function(callback, context){
|
cx.on('get', function(callback, context){
|
||||||
debug("Getting value for " + vdev.metrics.title + ", characteristic \"" + cx.displayName + "\"...");
|
debug("Getting value for " + vdev.metrics.title + ", characteristic \"" + cx.displayName + "\"...");
|
||||||
callback(false, that.name);
|
callback(false, accessory.name);
|
||||||
});
|
});
|
||||||
cx.writable = false;
|
cx.writable = false;
|
||||||
return cx;
|
return cx;
|
||||||
@@ -597,7 +603,7 @@ ZWayServerAccessory.prototype = {
|
|||||||
|
|
||||||
if(cx instanceof Characteristic.StatusLowBattery){
|
if(cx instanceof Characteristic.StatusLowBattery){
|
||||||
cx.zway_getValueFromVDev = function(vdev){
|
cx.zway_getValueFromVDev = function(vdev){
|
||||||
return vdev.metrics.level <= that.platform.batteryLow ? Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
return vdev.metrics.level <= accessory.platform.batteryLow ? Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
|
||||||
};
|
};
|
||||||
cx.value = cx.zway_getValueFromVDev(vdev);
|
cx.value = cx.zway_getValueFromVDev(vdev);
|
||||||
cx.on('get', function(callback, context){
|
cx.on('get', function(callback, context){
|
||||||
@@ -686,6 +692,12 @@ ZWayServerAccessory.prototype = {
|
|||||||
var services = [informationService];
|
var services = [informationService];
|
||||||
|
|
||||||
services = services.concat(this.getVDevServices(this.devDesc.devices[this.devDesc.primary]));
|
services = services.concat(this.getVDevServices(this.devDesc.devices[this.devDesc.primary]));
|
||||||
|
|
||||||
|
// Any extra switchMultilevels? Could be a RGBW+W bulb, add them as additional services...
|
||||||
|
if(this.devDesc.extras["switchMultilevel"]) for(var i = 0; i < this.devDesc.extras["switchMultilevel"].length; i++){
|
||||||
|
var xvdev = this.devDesc.devices[this.devDesc.extras["switchMultilevel"][i]];
|
||||||
|
services = services.concat(this.getVDevServices(xvdev));
|
||||||
|
}
|
||||||
|
|
||||||
if(this.platform.splitServices){
|
if(this.platform.splitServices){
|
||||||
if(this.devDesc.types["battery.Battery"]){
|
if(this.devDesc.types["battery.Battery"]){
|
||||||
|
|||||||
Reference in New Issue
Block a user