mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-18 13:20:56 +00:00
Add Carwings accessory shim
This commit is contained in:
@@ -3,9 +3,10 @@ var wemo = require('wemo');
|
||||
|
||||
function WeMoAccessory(log, config) {
|
||||
this.log = log;
|
||||
this.friendlyName = config["wemo_name"];
|
||||
this.siriName = config["siri_name"];
|
||||
this.wemoName = config["wemo_name"];
|
||||
this.device = null;
|
||||
this.log("Searching for WeMo device with exact name '" + this.friendlyName + "'...");
|
||||
this.log("Searching for WeMo device with exact name '" + this.wemoName + "'...");
|
||||
this.search();
|
||||
}
|
||||
|
||||
@@ -14,8 +15,8 @@ WeMoAccessory.prototype = {
|
||||
search: function() {
|
||||
var that = this;
|
||||
|
||||
wemo.Search(this.friendlyName, function(err, device) {
|
||||
that.log("Found '"+that.friendlyName+"' device at " + device.ip);
|
||||
wemo.Search(this.wemoName, function(err, device) {
|
||||
that.log("Found '"+that.wemoName+"' device at " + device.ip);
|
||||
that.device = new wemo(device.ip, device.port);
|
||||
});
|
||||
},
|
||||
@@ -23,21 +24,21 @@ WeMoAccessory.prototype = {
|
||||
setPowerState: function(powerOn) {
|
||||
|
||||
if (!this.device) {
|
||||
this.log("No '"+this.friendlyName+"' device found (yet?)");
|
||||
this.log("No '"+this.wemoName+"' device found (yet?)");
|
||||
return;
|
||||
}
|
||||
|
||||
var binaryState = powerOn ? 1 : 0;
|
||||
var that = this;
|
||||
|
||||
this.log("Setting power state on the '"+this.friendlyName+"' to " + binaryState);
|
||||
this.log("Setting power state on the '"+this.wemoName+"' to " + binaryState);
|
||||
|
||||
this.device.setBinaryState(binaryState, function(err, result) {
|
||||
if (!err) {
|
||||
that.log("Successfully set power state on the '"+that.friendlyName+"' to " + binaryState);
|
||||
that.log("Successfully set power state on the '"+that.wemoName+"' to " + binaryState);
|
||||
}
|
||||
else {
|
||||
that.log("Error setting power state on the '"+that.friendlyName+"'")
|
||||
that.log("Error setting power state on the '"+that.wemoName+"'")
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -52,7 +53,7 @@ WeMoAccessory.prototype = {
|
||||
onUpdate: null,
|
||||
perms: ["pr"],
|
||||
format: "string",
|
||||
initialValue: this.friendlyName,
|
||||
initialValue: this.siriName,
|
||||
supportEvents: false,
|
||||
supportBonjour: false,
|
||||
manfDescription: "Name of the accessory",
|
||||
@@ -105,7 +106,7 @@ WeMoAccessory.prototype = {
|
||||
onUpdate: null,
|
||||
perms: ["pr"],
|
||||
format: "string",
|
||||
initialValue: this.friendlyName,
|
||||
initialValue: this.siriName,
|
||||
supportEvents: false,
|
||||
supportBonjour: false,
|
||||
manfDescription: "Name of service",
|
||||
|
||||
Reference in New Issue
Block a user