mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-05 06:13:13 +01:00
Merge branch 'nfarina/master' into zway-motionsensor-and-fixes
This commit is contained in:
71
accessories/HttpHygrometer.js
Normal file
71
accessories/HttpHygrometer.js
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
var Service = require("HAP-NodeJS").Service;
|
||||||
|
var Characteristic = require("HAP-NodeJS").Characteristic;
|
||||||
|
var request = require("request");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
accessory: HygrometerAccessory
|
||||||
|
}
|
||||||
|
|
||||||
|
function HygrometerAccessory(log, config) {
|
||||||
|
this.log = log;
|
||||||
|
|
||||||
|
// url info
|
||||||
|
this.url = config["url"];
|
||||||
|
this.http_method = config["http_method"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HygrometerAccessory.prototype = {
|
||||||
|
|
||||||
|
httpRequest: function(url, method, callback) {
|
||||||
|
request({
|
||||||
|
url: url,
|
||||||
|
method: method
|
||||||
|
},
|
||||||
|
function (error, response, body) {
|
||||||
|
callback(error, response, body)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
identify: function(callback) {
|
||||||
|
this.log("Identify requested!");
|
||||||
|
callback(); // success
|
||||||
|
},
|
||||||
|
|
||||||
|
getCurrentRelativeHumidity: function (callback) {
|
||||||
|
var that = this;
|
||||||
|
that.log ("getting CurrentCurrentRelativeHumidity");
|
||||||
|
|
||||||
|
this.httpRequest(this.url, this.http_method, function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HTTP function failed: %s', error);
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('HTTP function succeeded - %s', body);
|
||||||
|
callback(null, Number(body));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getServices: function() {
|
||||||
|
|
||||||
|
// you can OPTIONALLY create an information service if you wish to override
|
||||||
|
// the default values for things like serial number, model, etc.
|
||||||
|
var informationService = new Service.AccessoryInformation();
|
||||||
|
|
||||||
|
informationService
|
||||||
|
.setCharacteristic(Characteristic.Manufacturer, "HTTP Manufacturer")
|
||||||
|
.setCharacteristic(Characteristic.Model, "HTTP Hygrometer")
|
||||||
|
.setCharacteristic(Characteristic.SerialNumber, "HTTP Serial Number");
|
||||||
|
|
||||||
|
var humidityService = new Service.HumiditySensor();
|
||||||
|
|
||||||
|
humidityService
|
||||||
|
.getCharacteristic(Characteristic.CurrentRelativeHumidity)
|
||||||
|
.on('get', this.getCurrentRelativeHumidity.bind(this));
|
||||||
|
|
||||||
|
return [informationService, humidityService];
|
||||||
|
}
|
||||||
|
};
|
||||||
79
accessories/HttpThermometer.js
Normal file
79
accessories/HttpThermometer.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
var Service = require("HAP-NodeJS").Service;
|
||||||
|
var Characteristic = require("HAP-NodeJS").Characteristic;
|
||||||
|
var request = require("request");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
accessory: ThermometerAccessory
|
||||||
|
}
|
||||||
|
|
||||||
|
function ThermometerAccessory(log, config) {
|
||||||
|
this.log = log;
|
||||||
|
|
||||||
|
// url info
|
||||||
|
this.url = config["url"];
|
||||||
|
this.http_method = config["http_method"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ThermometerAccessory.prototype = {
|
||||||
|
|
||||||
|
httpRequest: function(url, method, callback) {
|
||||||
|
request({
|
||||||
|
url: url,
|
||||||
|
method: method
|
||||||
|
},
|
||||||
|
function (error, response, body) {
|
||||||
|
callback(error, response, body)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
identify: function(callback) {
|
||||||
|
this.log("Identify requested!");
|
||||||
|
callback(); // success
|
||||||
|
},
|
||||||
|
|
||||||
|
getCurrentTemperature: function (callback) {
|
||||||
|
var that = this;
|
||||||
|
that.log ("getting CurrentTemperature");
|
||||||
|
|
||||||
|
|
||||||
|
this.httpRequest(this.url, this.http_method, function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HTTP function failed: %s', error);
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('HTTP function succeeded - %s', body);
|
||||||
|
callback(null, Number(body));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getTemperatureUnits: function (callback) {
|
||||||
|
var that = this;
|
||||||
|
that.log ("getTemperature Units");
|
||||||
|
// 1 = F and 0 = C
|
||||||
|
callback (null, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
getServices: function() {
|
||||||
|
|
||||||
|
// you can OPTIONALLY create an information service if you wish to override
|
||||||
|
// the default values for things like serial number, model, etc.
|
||||||
|
var informationService = new Service.AccessoryInformation();
|
||||||
|
|
||||||
|
informationService
|
||||||
|
.setCharacteristic(Characteristic.Manufacturer, "HTTP Manufacturer")
|
||||||
|
.setCharacteristic(Characteristic.Model, "HTTP Thermometer")
|
||||||
|
.setCharacteristic(Characteristic.SerialNumber, "HTTP Serial Number");
|
||||||
|
|
||||||
|
var temperatureService = new Service.TemperatureSensor();
|
||||||
|
|
||||||
|
temperatureService
|
||||||
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
||||||
|
.on('get', this.getCurrentTemperature.bind(this));
|
||||||
|
|
||||||
|
return [informationService, temperatureService];
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
"token" : "telldus token",
|
"token" : "telldus token",
|
||||||
"token_secret" : "telldus token secret"
|
"token_secret" : "telldus token secret"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"platform" : "Telldus",
|
||||||
|
"name" : "Telldus"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"platform": "Wink",
|
"platform": "Wink",
|
||||||
"name": "Wink",
|
"name": "Wink",
|
||||||
@@ -164,7 +168,20 @@
|
|||||||
"off_url": "https://192.168.1.22:3030/devices/23222/off",
|
"off_url": "https://192.168.1.22:3030/devices/23222/off",
|
||||||
"brightness_url": "https://192.168.1.22:3030/devices/23222/brightness/%b",
|
"brightness_url": "https://192.168.1.22:3030/devices/23222/brightness/%b",
|
||||||
"http_method": "POST"
|
"http_method": "POST"
|
||||||
},{
|
},
|
||||||
|
{
|
||||||
|
"accessory": "HttpHygrometer",
|
||||||
|
"name": "Kitchen",
|
||||||
|
"url": "http://host/URL",
|
||||||
|
"http_method": "GET"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"accessory": "HttpThermometer",
|
||||||
|
"name": "Garage",
|
||||||
|
"url": "http://home/URL",
|
||||||
|
"http_method": "GET"
|
||||||
|
},
|
||||||
|
{
|
||||||
"accessory": "ELKM1",
|
"accessory": "ELKM1",
|
||||||
"name": "Security System",
|
"name": "Security System",
|
||||||
"description": "Allows basic control of Elk M1 security system. You can use 1 of 3 arm modes: Away, Stay, Night. If you need to access all 3, create 3 accessories with different names.",
|
"description": "Allows basic control of Elk M1 security system. You can use 1 of 3 arm modes: Away, Stay, Night. If you need to access all 3, create 3 accessories with different names.",
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
"tough-cookie": "^2.0.0",
|
"tough-cookie": "^2.0.0",
|
||||||
"request": "2.49.x",
|
"request": "2.49.x",
|
||||||
"sonos": "0.8.x",
|
"sonos": "0.8.x",
|
||||||
|
"telldus": "0.0.9",
|
||||||
"telldus-live": "0.2.x",
|
"telldus-live": "0.2.x",
|
||||||
"teslams": "1.0.1",
|
"teslams": "1.0.1",
|
||||||
"unofficial-nest-api": "git+https://github.com/hachidorii/unofficial_nodejs_nest.git#d8d48edc952b049ff6320ef99afa7b2f04cdee98",
|
"unofficial-nest-api": "git+https://github.com/hachidorii/unofficial_nodejs_nest.git#d8d48edc952b049ff6320ef99afa7b2f04cdee98",
|
||||||
|
|||||||
@@ -2,7 +2,15 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// HomeSeer Platform Shim for HomeBridge
|
// HomeSeer Platform Shim for HomeBridge
|
||||||
// V0.1 - Jean-Michel Joudrier (stipus at stipus dot com) - 2015/10/07 - Initial version
|
// V0.1 - Jean-Michel Joudrier (stipus at stipus dot com) - 2015/10/07
|
||||||
|
// - Initial version
|
||||||
|
// V0.2 - Jean-Michel Joudrier (stipus at stipus dot com) - 2015/10/10
|
||||||
|
// - Occupancy sensor fix
|
||||||
|
// V0.3 - Jean-Michel Joudrier (stipus at stipus dot com) - 2015/10/11
|
||||||
|
// - Added TemperatureUnit=F|C option to temperature sensors
|
||||||
|
// - Added negative temperature support to temperature sensors
|
||||||
|
// V0.4 - Jean-Michel Joudrier (stipus at stipus dot com) - 2015/10/12
|
||||||
|
// - Added thermostat support
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Remember to add platform to config.json.
|
// Remember to add platform to config.json.
|
||||||
@@ -13,24 +21,50 @@
|
|||||||
// Example:
|
// Example:
|
||||||
// "platforms": [
|
// "platforms": [
|
||||||
// {
|
// {
|
||||||
// "platform": "HomeSeer", // required
|
// "platform": "HomeSeer", // Required
|
||||||
// "name": "HomeSeer", // required
|
// "name": "HomeSeer", // Required
|
||||||
// "url": "http://192.168.3.4:81", // required
|
// "host": "http://192.168.3.4:81", // Required - If you did setup HomeSeer authentication, use "http://user:password@ip_address:port"
|
||||||
// "accessories":[
|
// "accessories":[
|
||||||
// {
|
// {
|
||||||
// "ref":8, // required - HomeSeer Device Reference (To get it, select the HS Device - then Advanced Tab)
|
// "ref":8, // Required - HomeSeer Device Reference (To get it, select the HS Device - then Advanced Tab)
|
||||||
// "type":"Lightbulb", // Optional - Lightbulb is the default
|
// "type":"Lightbulb", // Optional - Lightbulb is the default
|
||||||
// "name":"My Light", // Optional - HomeSeer device name is the default
|
// "name":"My Light", // Optional - HomeSeer device name is the default
|
||||||
// "offValue":"0", // Optional - 0 is the default
|
// "offValue":"0", // Optional - 0 is the default
|
||||||
// "onValue":"100", // Optional - 100 is the default
|
// "onValue":"100", // Optional - 100 is the default
|
||||||
// "can_dim":true // Optional - true is the default - false for a non dimmable lightbulb
|
// "can_dim":true // Optional - true is the default - false for a non dimmable lightbulb
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "ref":9 // This is a dimmable Lightbulb by default
|
// "ref":9 // This is a dimmable Lightbulb by default
|
||||||
// },
|
// },
|
||||||
// {
|
// {
|
||||||
// "ref":58, // This is an controllable outlet
|
// "ref":58, // This is an controllable outlet
|
||||||
// "type":"Outlet"
|
// "type":"Outlet"
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "ref":111,
|
||||||
|
// "type":"TemperatureSensor", // Required for a temperature sensor
|
||||||
|
// "temperatureUnit":"F", // Optional - C is the default
|
||||||
|
// "name":"Bedroom temp" // Optional - HomeSeer device name is the default
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "ref":113, // Required - HomeSeer Device Reference of the Current Temperature Device
|
||||||
|
// "type":"Thermostat", // Required for a Thermostat
|
||||||
|
// "name":"Température Salon", // Optional - HomeSeer device name is the default
|
||||||
|
// "temperatureUnit":"C", // Optional - F for Fahrenheit, C for Celsius, C is the default
|
||||||
|
// "setPointRef":167, // Required - HomeSeer device reference for your thermostat Set Point.
|
||||||
|
// "setPointReadOnly":true, // Optional - Set to false if your SetPoint is read/write. true is the default
|
||||||
|
// "stateRef":166, // Required - HomeSeer device reference for your thermostat current state
|
||||||
|
// "stateOffValues":[0,4,5], // Required - List of the HomeSeer device values for a HomeKit state=OFF
|
||||||
|
// "stateHeatValues":[1], // Required - List of the HomeSeer device values for a HomeKit state=HEAT
|
||||||
|
// "stateCoolValues":[2], // Required - List of the HomeSeer device values for a HomeKit state=COOL
|
||||||
|
// "stateAutoValues":[3], // Required - List of the HomeSeer device values for a HomeKit state=AUTO
|
||||||
|
// "controlRef":168, // Required - HomeSeer device reference for your thermostat mode control (It can be the same as stateRef for some thermostats)
|
||||||
|
// "controlOffValue":0, // Required - Value for OFF
|
||||||
|
// "controlHeatValue":1, // Required - Value for HEAT
|
||||||
|
// "controlCoolValue":2, // Required - Value for COOL
|
||||||
|
// "controlAutoValue":3, // Required - Value for AUTO
|
||||||
|
// "coolingThresholdRef":169, // Optional - Not-implemented-yet - HomeSeer device reference for your thermostat cooling threshold
|
||||||
|
// "heatingThresholdRef":170 // Optional - Not-implemented-yet - HomeSeer device reference for your thermostat heating threshold
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
@@ -42,7 +76,8 @@
|
|||||||
// - Fan (onValue, offValue options)
|
// - Fan (onValue, offValue options)
|
||||||
// - Switch (onValue, offValue options)
|
// - Switch (onValue, offValue options)
|
||||||
// - Outlet (onValue, offValue options)
|
// - Outlet (onValue, offValue options)
|
||||||
// - TemperatureSensor
|
// - TemperatureSensor (temperatureUnit=C|F)
|
||||||
|
// - Thermostat (temperatureUnit, setPoint, state, control options)
|
||||||
// - ContactSensor
|
// - ContactSensor
|
||||||
// - MotionSensor
|
// - MotionSensor
|
||||||
// - LeakSensor
|
// - LeakSensor
|
||||||
@@ -88,6 +123,7 @@ HomeSeerPlatform.prototype = {
|
|||||||
var that = this;
|
var that = this;
|
||||||
var foundAccessories = [];
|
var foundAccessories = [];
|
||||||
var url = this.config["host"] + "/JSON?request=getstatus&ref=" + refList;
|
var url = this.config["host"] + "/JSON?request=getstatus&ref=" + refList;
|
||||||
|
|
||||||
httpRequest( url, "GET", function(error, response, body) {
|
httpRequest( url, "GET", function(error, response, body) {
|
||||||
if (error) {
|
if (error) {
|
||||||
this.log('HomeSeer status function failed: %s', error.message);
|
this.log('HomeSeer status function failed: %s', error.message);
|
||||||
@@ -114,8 +150,9 @@ function HomeSeerAccessory(log, platformConfig, status ) {
|
|||||||
this.onValue = "100";
|
this.onValue = "100";
|
||||||
this.offValue = "0";
|
this.offValue = "0";
|
||||||
|
|
||||||
this.control_url = platformConfig["host"] + "/JSON?request=controldevicebyvalue&ref=" + this.ref + "&value=";
|
this.access_url = platformConfig["host"] + "/JSON?";
|
||||||
this.status_url = platformConfig["host"] + "/JSON?request=getstatus&ref=" + this.ref;
|
this.control_url = this.access_url + "request=controldevicebyvalue&ref=" + this.ref + "&value=";
|
||||||
|
this.status_url = this.access_url + "request=getstatus&ref=" + this.ref;
|
||||||
|
|
||||||
for( var i=0; i<platformConfig.accessories.length; i++ ) {
|
for( var i=0; i<platformConfig.accessories.length; i++ ) {
|
||||||
if( platformConfig.accessories[i].ref == this.ref )
|
if( platformConfig.accessories[i].ref == this.ref )
|
||||||
@@ -222,6 +259,152 @@ HomeSeerAccessory.prototype = {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setTemperature: function(temperature, callback) {
|
||||||
|
this.log("Setting temperature to %s", temperature);
|
||||||
|
if( this.config.temperatureUnit == "F" ) {
|
||||||
|
temperature = temperature*9/5+32;
|
||||||
|
}
|
||||||
|
|
||||||
|
var url = this.control_url + temperature;
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer set temperature function failed: %s', error.message);
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('HomeSeer set temperature function succeeded!');
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getTemperature: function(callback) {
|
||||||
|
var url = this.status_url;
|
||||||
|
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer get temperature function failed: %s', error.message);
|
||||||
|
callback( error, 0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var status = JSON.parse( body );
|
||||||
|
var value = status.Devices[0].value;
|
||||||
|
|
||||||
|
this.log('HomeSeer get temperature function succeeded: value=' + value );
|
||||||
|
if( this.config.temperatureUnit == "F" ) {
|
||||||
|
value = (value-32)*5/9;
|
||||||
|
}
|
||||||
|
callback( null, value );
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getThermostatCurrentHeatingCoolingState: function(callback) {
|
||||||
|
var ref = this.config.stateRef;
|
||||||
|
var url = this.access_url + "request=getstatus&ref=" + ref;
|
||||||
|
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer get thermostat current heating cooling state function failed: %s', error.message);
|
||||||
|
callback( error, 0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var status = JSON.parse( body );
|
||||||
|
var value = status.Devices[0].value;
|
||||||
|
|
||||||
|
this.log('HomeSeer get thermostat current heating cooling state function succeeded: value=' + value );
|
||||||
|
if( this.config.stateOffValues.indexOf(value) != -1 )
|
||||||
|
callback( null, 0 );
|
||||||
|
else if( this.config.stateHeatValues.indexOf(value) != -1 )
|
||||||
|
callback( null, 1 );
|
||||||
|
else if( this.config.stateCoolValues.indexOf(value) != -1 )
|
||||||
|
callback( null, 2 );
|
||||||
|
else if( this.config.stateAutoValues.indexOf(value) != -1 )
|
||||||
|
callback( null, 3 );
|
||||||
|
else {
|
||||||
|
this.log( "Error: value for thermostat current heating cooling state not in offValues, heatValues, coolValues or autoValues" );
|
||||||
|
callback( null, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
setThermostatCurrentHeatingCoolingState: function(state, callback) {
|
||||||
|
this.log("Setting thermostat current heating cooling state to %s", state);
|
||||||
|
|
||||||
|
var ref = this.config.controlRef;
|
||||||
|
var value = 0;
|
||||||
|
if( state == 0 )
|
||||||
|
value = this.config.controlOffValue;
|
||||||
|
else if( state == 1 )
|
||||||
|
value = this.config.controlHeatValue;
|
||||||
|
else if( state == 2 )
|
||||||
|
value = this.config.controlCoolValue;
|
||||||
|
else if( state == 3 )
|
||||||
|
value = this.config.controlAutoValue;
|
||||||
|
|
||||||
|
var url = this.access_url + "request=controldevicebyvalue&ref=" + ref + "&value=" + value;
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer set thermostat current heating cooling state function failed: %s', error.message);
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('HomeSeer set thermostat current heating cooling state function succeeded!');
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getThermostatTargetTemperature: function(callback) {
|
||||||
|
var ref = this.config.setPointRef;
|
||||||
|
var url = this.access_url + "request=getstatus&ref=" + ref;
|
||||||
|
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer get thermostat target temperature function failed: %s', error.message);
|
||||||
|
callback( error, 0 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var status = JSON.parse( body );
|
||||||
|
var value = status.Devices[0].value;
|
||||||
|
|
||||||
|
this.log('HomeSeer get thermostat target temperature function succeeded: value=' + value );
|
||||||
|
if( this.config.temperatureUnit == "F" ) {
|
||||||
|
value = (value-32)*5/9;
|
||||||
|
}
|
||||||
|
callback( null, value );
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
setThermostatTargetTemperature: function(temperature, callback) {
|
||||||
|
this.log("Setting thermostat target temperature to %s", temperature);
|
||||||
|
if( this.config.temperatureUnit == "F" ) {
|
||||||
|
temperature = temperature*9/5+32;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ref = this.config.setPointRef;
|
||||||
|
var url = this.access_url + "request=controldevicebyvalue&ref=" + ref + "&value=" + temperature;
|
||||||
|
httpRequest(url, 'GET', function(error, response, body) {
|
||||||
|
if (error) {
|
||||||
|
this.log('HomeSeer set thermostat target temperature function failed: %s', error.message);
|
||||||
|
callback(error);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log('HomeSeer set thermostat target temperature function succeeded!');
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
getThermostatTemperatureDisplayUnits: function(callback) {
|
||||||
|
if( this.config.temperatureUnit == "F" )
|
||||||
|
callback( null, 1 );
|
||||||
|
else
|
||||||
|
callback( null, 0 );
|
||||||
|
},
|
||||||
|
|
||||||
getServices: function() {
|
getServices: function() {
|
||||||
var services = []
|
var services = []
|
||||||
|
|
||||||
@@ -282,7 +465,9 @@ HomeSeerAccessory.prototype = {
|
|||||||
var temperatureSensorService = new Service.TemperatureSensor();
|
var temperatureSensorService = new Service.TemperatureSensor();
|
||||||
temperatureSensorService
|
temperatureSensorService
|
||||||
.getCharacteristic(Characteristic.CurrentTemperature)
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
||||||
.on('get', this.getValue.bind(this));
|
.on('get', this.getTemperature.bind(this));
|
||||||
|
temperatureSensorService
|
||||||
|
.getCharacteristic(Characteristic.CurrentTemperature).setProps( {minValue: -100} );
|
||||||
services.push( temperatureSensorService );
|
services.push( temperatureSensorService );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -320,7 +505,7 @@ HomeSeerAccessory.prototype = {
|
|||||||
}
|
}
|
||||||
case "OccupancySensor": {
|
case "OccupancySensor": {
|
||||||
var occupancySensorService = new Service.OccupancySensor();
|
var occupancySensorService = new Service.OccupancySensor();
|
||||||
motionSensorService
|
occupancySensorService
|
||||||
.getCharacteristic(Characteristic.OccupancyDetected)
|
.getCharacteristic(Characteristic.OccupancyDetected)
|
||||||
.on('get', this.getPowerState.bind(this));
|
.on('get', this.getPowerState.bind(this));
|
||||||
services.push( occupancySensorService );
|
services.push( occupancySensorService );
|
||||||
@@ -345,6 +530,34 @@ HomeSeerAccessory.prototype = {
|
|||||||
services.push( doorService );
|
services.push( doorService );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "Thermostat": {
|
||||||
|
var thermostatService = new Service.Thermostat();
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.CurrentTemperature)
|
||||||
|
.on('get', this.getTemperature.bind(this));
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.TargetTemperature)
|
||||||
|
.on('get', this.getThermostatTargetTemperature.bind(this));
|
||||||
|
if( this.config.setPointReadOnly === null || this.config.setPointReadOnly === false )
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.TargetTemperature)
|
||||||
|
.on('set', this.setThermostatTargetTemperature.bind(this));
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
||||||
|
.on('get', this.getThermostatCurrentHeatingCoolingState.bind(this));
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
||||||
|
.on('get', this.getThermostatCurrentHeatingCoolingState.bind(this));
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
||||||
|
.on('set', this.setThermostatCurrentHeatingCoolingState.bind(this));
|
||||||
|
thermostatService
|
||||||
|
.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
||||||
|
.on('get', this.getThermostatTemperatureDisplayUnits.bind(this));
|
||||||
|
|
||||||
|
services.push( thermostatService );
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:{
|
default:{
|
||||||
var lightbulbService = new Service.Lightbulb();
|
var lightbulbService = new Service.Lightbulb();
|
||||||
lightbulbService
|
lightbulbService
|
||||||
|
|||||||
265
platforms/Telldus.js
Normal file
265
platforms/Telldus.js
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
var types = require("HAP-NodeJS/accessories/types.js");
|
||||||
|
var telldus = require('telldus');
|
||||||
|
|
||||||
|
function TelldusPlatform(log, config) {
|
||||||
|
var that = this;
|
||||||
|
that.log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
TelldusPlatform.prototype = {
|
||||||
|
|
||||||
|
accessories: function(callback) {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
that.log("Fetching devices...");
|
||||||
|
|
||||||
|
var devices = telldus.getDevicesSync();
|
||||||
|
|
||||||
|
that.log("Found " + devices.length + " devices...");
|
||||||
|
|
||||||
|
var foundAccessories = [];
|
||||||
|
|
||||||
|
// Clean non device
|
||||||
|
for (var i = 0; i < devices.length; i++) {
|
||||||
|
if (devices[i].type != 'DEVICE') {
|
||||||
|
devices.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < devices.length; i++) {
|
||||||
|
if (devices[i].type === 'DEVICE') {
|
||||||
|
TelldusAccessory.create(that.log, devices[i], function(err, accessory) {
|
||||||
|
if (!!err) that.log("Couldn't load device info");
|
||||||
|
foundAccessories.push(accessory);
|
||||||
|
if (foundAccessories.length >= devices.length) {
|
||||||
|
callback(foundAccessories);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var TelldusAccessory = function TelldusAccessory(log, device) {
|
||||||
|
|
||||||
|
this.log = log;
|
||||||
|
|
||||||
|
var m = device.model.split(':');
|
||||||
|
|
||||||
|
this.dimTimeout = false;
|
||||||
|
|
||||||
|
// Set accessory info
|
||||||
|
this.device = device;
|
||||||
|
this.id = device.id;
|
||||||
|
this.name = device.name;
|
||||||
|
this.manufacturer = "Telldus"; // NOTE: Change this later
|
||||||
|
this.model = device.model;
|
||||||
|
this.status = device.status;
|
||||||
|
switch (device.status.name) {
|
||||||
|
case 'OFF':
|
||||||
|
this.state = 0;
|
||||||
|
this.stateValue = 0;
|
||||||
|
break;
|
||||||
|
case 'ON':
|
||||||
|
this.state = 2;
|
||||||
|
this.stateValue = 1;
|
||||||
|
break;
|
||||||
|
case 'DIM':
|
||||||
|
this.state = 16;
|
||||||
|
this.stateValue = device.status.level;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TelldusAccessory.create = function (log, device, callback) {
|
||||||
|
|
||||||
|
callback(null, new TelldusAccessory(log, device));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
TelldusAccessory.prototype = {
|
||||||
|
|
||||||
|
dimmerValue: function() {
|
||||||
|
|
||||||
|
if (this.state === 1) {
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state === 16 && this.stateValue != "unde") {
|
||||||
|
return parseInt(this.stateValue * 100 / 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
informationCharacteristics: function() {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
informationCharacteristics = [
|
||||||
|
{
|
||||||
|
cType: types.NAME_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: that.name,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Name of the accessory",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.MANUFACTURER_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: that.manufacturer,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Manufacturer",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.MODEL_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: that.model,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Model",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.SERIAL_NUMBER_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: "A1S2NASF88EW",
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "SN",
|
||||||
|
designedMaxLength: 255
|
||||||
|
},{
|
||||||
|
cType: types.IDENTIFY_CTYPE,
|
||||||
|
onUpdate: function () {
|
||||||
|
telldus.turnOff(that.id, function(err){
|
||||||
|
if (!!err) that.log("Error: " + err.message);
|
||||||
|
telldus.turnOn(that.id, function(err){
|
||||||
|
if (!!err) that.log("Error: " + err.message);
|
||||||
|
telldus.turnOff(that.id, function(err){
|
||||||
|
if (!!err) that.log("Error: " + err.message);
|
||||||
|
telldus.turnOn(that.id, function(err){
|
||||||
|
if (!!err) that.log("Error: " + err.message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
perms: ["pw"],
|
||||||
|
format: "bool",
|
||||||
|
initialValue: false,
|
||||||
|
supportEvents: false,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Identify Accessory",
|
||||||
|
designedMaxLength: 1
|
||||||
|
}
|
||||||
|
];
|
||||||
|
return informationCharacteristics;
|
||||||
|
},
|
||||||
|
|
||||||
|
controlCharacteristics: function() {
|
||||||
|
var that = this;
|
||||||
|
|
||||||
|
cTypes = [{
|
||||||
|
cType: types.NAME_CTYPE,
|
||||||
|
onUpdate: null,
|
||||||
|
perms: ["pr"],
|
||||||
|
format: "string",
|
||||||
|
initialValue: that.name,
|
||||||
|
supportEvents: true,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Name of service",
|
||||||
|
designedMaxLength: 255
|
||||||
|
}]
|
||||||
|
|
||||||
|
cTypes.push({
|
||||||
|
cType: types.POWER_STATE_CTYPE,
|
||||||
|
onUpdate: function(value) {
|
||||||
|
if (value) {
|
||||||
|
telldus.turnOn(that.id, function(err){
|
||||||
|
if (!!err) {
|
||||||
|
that.log("Error: " + err.message)
|
||||||
|
} else {
|
||||||
|
that.log(that.name + " - Updated power state: ON");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
telldus.turnOff(that.id, function(err){
|
||||||
|
if (!!err) {
|
||||||
|
that.log("Error: " + err.message)
|
||||||
|
} else {
|
||||||
|
that.log(that.name + " - Updated power state: OFF");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
perms: ["pw","pr","ev"],
|
||||||
|
format: "bool",
|
||||||
|
initialValue: (that.state != 2 && (that.state === 16 && that.stateValue != 0)) ? 1 : 0,
|
||||||
|
supportEvents: true,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Change the power state",
|
||||||
|
designedMaxLength: 1
|
||||||
|
})
|
||||||
|
|
||||||
|
if (that.model === "selflearning-dimmer") {
|
||||||
|
cTypes.push({
|
||||||
|
cType: types.BRIGHTNESS_CTYPE,
|
||||||
|
onUpdate: function (value) {
|
||||||
|
if (that.dimTimeout) {
|
||||||
|
clearTimeout(that.dimTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
that.dimTimeout = setTimeout(function(){
|
||||||
|
telldus.dim(that.id, (255 * (value / 100)), function(err, result){
|
||||||
|
if (!!err) {
|
||||||
|
that.log("Error: " + err.message);
|
||||||
|
} else {
|
||||||
|
that.log(that.name + " - Updated brightness: " + value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
that.dimTimeout = false;
|
||||||
|
}, 250);
|
||||||
|
},
|
||||||
|
perms: ["pw", "pr", "ev"],
|
||||||
|
format: "int",
|
||||||
|
initialValue: that.dimmerValue(),
|
||||||
|
supportEvents: true,
|
||||||
|
supportBonjour: false,
|
||||||
|
manfDescription: "Adjust Brightness of Light",
|
||||||
|
designedMinValue: 0,
|
||||||
|
designedMaxValue: 100,
|
||||||
|
designedMinStep: 1,
|
||||||
|
unit: "%"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return cTypes
|
||||||
|
},
|
||||||
|
|
||||||
|
getServices: function() {
|
||||||
|
|
||||||
|
var services = [
|
||||||
|
{
|
||||||
|
sType: types.ACCESSORY_INFORMATION_STYPE,
|
||||||
|
characteristics: this.informationCharacteristics()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sType: types.LIGHTBULB_STYPE,
|
||||||
|
characteristics: this.controlCharacteristics()
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.platform = TelldusPlatform;
|
||||||
|
module.exports.accessory = TelldusAccessory;
|
||||||
@@ -31,24 +31,24 @@ function YamahaAVRPlatform(log, config){
|
|||||||
|
|
||||||
YamahaAVRPlatform.AudioVolume = function() {
|
YamahaAVRPlatform.AudioVolume = function() {
|
||||||
Characteristic.call(this, 'Audio Volume', '00001001-0000-1000-8000-135D67EC4377');
|
Characteristic.call(this, 'Audio Volume', '00001001-0000-1000-8000-135D67EC4377');
|
||||||
this.format = 'uint8';
|
this.setProps({
|
||||||
this.unit = 'percentage';
|
format: Characteristic.Formats.UINT8,
|
||||||
this.maximumValue = 100;
|
unit: Characteristic.Units.PERCENTAGE,
|
||||||
this.minimumValue = 0;
|
maxValue: 100,
|
||||||
this.stepValue = 1;
|
minValue: 0,
|
||||||
this.readable = true;
|
minStep: 1,
|
||||||
this.writable = true;
|
perms: [Characteristic.Perms.READ, Characteristic.Perms.WRITE, Characteristic.Perms.NOTIFY]
|
||||||
this.supportsEventNotification = true;
|
});
|
||||||
this.value = this.getDefaultValue();
|
this.value = this.getDefaultValue();
|
||||||
};
|
};
|
||||||
inherits(YamahaAVRPlatform.AudioVolume, Characteristic);
|
inherits(YamahaAVRPlatform.AudioVolume, Characteristic);
|
||||||
|
|
||||||
YamahaAVRPlatform.Muting = function() {
|
YamahaAVRPlatform.Muting = function() {
|
||||||
Characteristic.call(this, 'Muting', '00001002-0000-1000-8000-135D67EC4377');
|
Characteristic.call(this, 'Muting', '00001002-0000-1000-8000-135D67EC4377');
|
||||||
this.format = 'bool';
|
this.setProps({
|
||||||
this.readable = true;
|
format: Characteristic.Formats.UINT8,
|
||||||
this.writable = true;
|
perms: [Characteristic.Perms.READ, Characteristic.Perms.WRITE, Characteristic.Perms.NOTIFY]
|
||||||
this.supportsEventNotification = true;
|
});
|
||||||
this.value = this.getDefaultValue();
|
this.value = this.getDefaultValue();
|
||||||
};
|
};
|
||||||
inherits(YamahaAVRPlatform.Muting, Characteristic);
|
inherits(YamahaAVRPlatform.Muting, Characteristic);
|
||||||
|
|||||||
@@ -83,7 +83,20 @@ ZWayServerPlatform.prototype = {
|
|||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
getTagValue: function(vdev, tagStem){
|
||||||
|
if(!(vdev.tags && vdev.tags.length > 0)) return false;
|
||||||
|
var tagStem = "Homebridge." + tagStem;
|
||||||
|
if(vdev.tags.indexOf(tagStem) >= 0) return true;
|
||||||
|
var tags = vdev.tags, l = tags.length, tag;
|
||||||
|
for(var i = 0; i < l; i++){
|
||||||
|
tag = tags[i];
|
||||||
|
if(tag.indexOf(tagStem + ":") === 0){
|
||||||
|
return tag.substr(tagStem.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
,
|
||||||
accessories: function(callback) {
|
accessories: function(callback) {
|
||||||
debug("Fetching Z-Way devices...");
|
debug("Fetching Z-Way devices...");
|
||||||
|
|
||||||
@@ -110,12 +123,30 @@ ZWayServerPlatform.prototype = {
|
|||||||
var groupedDevices = {};
|
var groupedDevices = {};
|
||||||
for(var i = 0; i < devices.length; i++){
|
for(var i = 0; i < devices.length; i++){
|
||||||
var vdev = devices[i];
|
var vdev = devices[i];
|
||||||
if(vdev.tags.indexOf("Homebridge:Skip") >= 0) { debug("Tag says skip!"); continue; }
|
if(this.getTagValue("Skip")) { debug("Tag says skip!"); continue; }
|
||||||
if(this.opt_in && vdev.tags.indexOf("Homebridge:Include") < 0) continue;
|
if(this.opt_in && !this.getTagValue(vdev, "Include")) continue;
|
||||||
var gdid = vdev.id.replace(/^(.*?)_zway_(\d+-\d+)-\d.*/, '$1_$2');
|
|
||||||
|
var gdid = this.getTagValue(vdev, "Accessory.Id");
|
||||||
|
if(!gdid){
|
||||||
|
gdid = vdev.id.replace(/^(.*?)_zway_(\d+-\d+)-\d.*/, '$1_$2');
|
||||||
|
}
|
||||||
|
|
||||||
var gd = groupedDevices[gdid] || (groupedDevices[gdid] = {devices: [], types: {}, extras: {}, primary: undefined});
|
var gd = groupedDevices[gdid] || (groupedDevices[gdid] = {devices: [], types: {}, extras: {}, primary: undefined});
|
||||||
gd.devices.push(vdev);
|
gd.devices.push(vdev);
|
||||||
var tk = ZWayServerPlatform.getVDevTypeKey(vdev);
|
var tk = ZWayServerPlatform.getVDevTypeKey(vdev);
|
||||||
|
|
||||||
|
// If this is explicitly set as primary, set it now...
|
||||||
|
if(this.getTagValue(vdev, "IsPrimary")){
|
||||||
|
// everybody out of the way! Can't be in "extras" if you're the primary...
|
||||||
|
if(gd.types[tk] !== undefined){
|
||||||
|
gd.extras[tk] = gd.extras[tk] || [];
|
||||||
|
gd.extras[tk].push(gd.types[tk]);
|
||||||
|
delete gd.types[tk]; // clear the way for this one to be set here below...
|
||||||
|
}
|
||||||
|
gd.primary = gd.devices.length - 1;
|
||||||
|
//gd.types[tk] = gd.primary;
|
||||||
|
}
|
||||||
|
|
||||||
if(gd.types[tk] === undefined){
|
if(gd.types[tk] === undefined){
|
||||||
gd.types[tk] = gd.devices.length - 1;
|
gd.types[tk] = gd.devices.length - 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -124,7 +155,7 @@ ZWayServerPlatform.prototype = {
|
|||||||
}
|
}
|
||||||
if(tk !== vdev.deviceType) gd.types[vdev.deviceType] = gd.devices.length - 1; // also include the deviceType only as a possibility
|
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
|
|
||||||
for(var gdid in groupedDevices) {
|
for(var gdid in groupedDevices) {
|
||||||
if(!groupedDevices.hasOwnProperty(gdid)) continue;
|
if(!groupedDevices.hasOwnProperty(gdid)) continue;
|
||||||
|
|
||||||
@@ -136,12 +167,17 @@ ZWayServerPlatform.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var accessory = null;
|
var accessory = null;
|
||||||
for(var ti = 0; ti < primaryDeviceClasses.length; ti++){
|
if(gd.primary !== undefined){
|
||||||
|
var pd = gd.devices[gd.primary];
|
||||||
|
var name = pd.metrics && pd.metrics.title ? pd.metrics.title : pd.id;
|
||||||
|
accessory = new ZWayServerAccessory(name, gd, that);
|
||||||
|
}
|
||||||
|
else for(var ti = 0; ti < primaryDeviceClasses.length; ti++){
|
||||||
if(gd.types[primaryDeviceClasses[ti]] !== undefined){
|
if(gd.types[primaryDeviceClasses[ti]] !== undefined){
|
||||||
gd.primary = gd.types[primaryDeviceClasses[ti]];
|
gd.primary = gd.types[primaryDeviceClasses[ti]];
|
||||||
var pd = gd.devices[gd.primary];
|
var pd = gd.devices[gd.primary];
|
||||||
var name = pd.metrics && pd.metrics.title ? pd.metrics.title : pd.id;
|
var name = pd.metrics && pd.metrics.title ? pd.metrics.title : pd.id;
|
||||||
debug("Using primary device with type " + primaryDeviceClasses[ti] + ", " + name + " (" + pd.id + ") as primary.");
|
//debug("Using primary device with type " + primaryDeviceClasses[ti] + ", " + name + " (" + pd.id + ") as primary.");
|
||||||
accessory = new ZWayServerAccessory(name, gd, that);
|
accessory = new ZWayServerAccessory(name, gd, that);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -153,7 +189,6 @@ ZWayServerPlatform.prototype = {
|
|||||||
foundAccessories.push(accessory);
|
foundAccessories.push(accessory);
|
||||||
|
|
||||||
}
|
}
|
||||||
//foundAccessories = foundAccessories.slice(0, 10); // Limit to a few devices for testing...
|
|
||||||
callback(foundAccessories);
|
callback(foundAccessories);
|
||||||
|
|
||||||
// Start the polling process...
|
// Start the polling process...
|
||||||
@@ -302,8 +337,13 @@ ZWayServerAccessory.prototype = {
|
|||||||
case "switchBinary":
|
case "switchBinary":
|
||||||
services.push(new Service.Switch(vdev.metrics.title, vdev.id));
|
services.push(new Service.Switch(vdev.metrics.title, vdev.id));
|
||||||
break;
|
break;
|
||||||
|
case "switchRGBW":
|
||||||
case "switchMultilevel":
|
case "switchMultilevel":
|
||||||
services.push(new Service.Lightbulb(vdev.metrics.title, vdev.id));
|
if(this.platform.getTagValue(vdev, "Service.Type") === "Switch"){
|
||||||
|
services.push(new Service.Switch(vdev.metrics.title, vdev.id));
|
||||||
|
} else {
|
||||||
|
services.push(new Service.Lightbulb(vdev.metrics.title, vdev.id));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "sensorBinary.Door/Window":
|
case "sensorBinary.Door/Window":
|
||||||
services.push(new Service.GarageDoorOpener(vdev.metrics.title, vdev.id));
|
services.push(new Service.GarageDoorOpener(vdev.metrics.title, vdev.id));
|
||||||
@@ -402,6 +442,12 @@ ZWayServerAccessory.prototype = {
|
|||||||
return cx;
|
return cx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't want to override "Name"'s name...so we just move this below that block.
|
||||||
|
var descOverride = this.platform.getTagValue(vdev, "Characteristic.Description");
|
||||||
|
if(descOverride){
|
||||||
|
cx.displayName = descOverride;
|
||||||
|
}
|
||||||
|
|
||||||
if(cx instanceof Characteristic.On){
|
if(cx instanceof Characteristic.On){
|
||||||
cx.zway_getValueFromVDev = function(vdev){
|
cx.zway_getValueFromVDev = function(vdev){
|
||||||
var val = false;
|
var val = false;
|
||||||
@@ -763,22 +809,29 @@ ZWayServerAccessory.prototype = {
|
|||||||
getServices: function() {
|
getServices: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
|
var vdevPrimary = this.devDesc.devices[this.devDesc.primary];
|
||||||
|
var accId = this.platform.getTagValue(vdevPrimary, "Accessory.Id");
|
||||||
|
if(!accId){
|
||||||
|
accId = "VDev-" + vdevPrimary.h; //FIXME: Is this valid?
|
||||||
|
}
|
||||||
|
|
||||||
var informationService = new Service.AccessoryInformation();
|
var informationService = new Service.AccessoryInformation();
|
||||||
|
|
||||||
informationService
|
informationService
|
||||||
.setCharacteristic(Characteristic.Name, this.name)
|
.setCharacteristic(Characteristic.Name, this.name)
|
||||||
.setCharacteristic(Characteristic.Manufacturer, "Z-Wave.me")
|
.setCharacteristic(Characteristic.Manufacturer, "Z-Wave.me")
|
||||||
.setCharacteristic(Characteristic.Model, "Virtual Device (VDev version 1)")
|
.setCharacteristic(Characteristic.Model, "Virtual Device (VDev version 1)")
|
||||||
.setCharacteristic(Characteristic.SerialNumber, "VDev-" + this.devDesc.devices[this.devDesc.primary].h) //FIXME: Is this valid?);
|
.setCharacteristic(Characteristic.SerialNumber, accId);
|
||||||
|
|
||||||
var services = [informationService];
|
var services = [informationService];
|
||||||
|
|
||||||
services = services.concat(this.getVDevServices(this.devDesc.devices[this.devDesc.primary]));
|
services = services.concat(this.getVDevServices(vdevPrimary));
|
||||||
|
|
||||||
// Any extra switchMultilevels? Could be a RGBW+W bulb, add them as additional services...
|
// 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++){
|
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]];
|
var xvdev = this.devDesc.devices[this.devDesc.extras["switchMultilevel"][i]];
|
||||||
services = services.concat(this.getVDevServices(xvdev));
|
var xservice = this.getVDevServices(xvdev);
|
||||||
|
services = services.concat(xservice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.platform.splitServices){
|
if(this.platform.splitServices){
|
||||||
|
|||||||
Reference in New Issue
Block a user