homebridge-abode
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -158,3 +158,2 @@ { | ||
"quote-props": [2, "as-needed"], | ||
"quotes": [2, "single", { "avoidEscape": true, "allowTemplateLiterals": true }], | ||
"semi": [2, "always"], | ||
@@ -161,0 +160,0 @@ "sort-vars": 0, |
46
index.js
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
/* 'use strict'; | ||
@@ -45,1 +45,45 @@ var Service; | ||
}; | ||
*/ | ||
var Service; | ||
var Characteristic; | ||
module.exports = function (homebridge) { | ||
Service = homebridge.hap.Service; | ||
Characteristic = homebridge.hap.Characteristic; | ||
homebridge.registerAccessory("homebridge-fakebulb", "FakeBulb", FakeBulbAccessory); | ||
}; | ||
function FakeBulbAccessory(log, config) { | ||
this.log = log; | ||
this.name = config.name; | ||
this.bulbName = config.bulb_name || this.name; // fallback to "name" if you didn't specify an exact "bulb_name" | ||
this.binaryState = 0; // bulb state, default is OFF | ||
this.log("Starting a fake bulb device with name '" + this.bulbName + "'..."); | ||
// this.search(); | ||
} | ||
FakeBulbAccessory.prototype.getPowerOn = function (callback) { | ||
var powerOn = this.binaryState > 0; | ||
this.log("Power state for the '%s' is %s", this.bulbName, this.binaryState); | ||
callback(null, powerOn); | ||
}; | ||
FakeBulbAccessory.prototype.setPowerOn = function (powerOn, callback) { | ||
this.binaryState = powerOn ? 1 : 0; // wemo langauge | ||
this.log("Set power state on the '%s' to %s", this.bulbName, this.binaryState); | ||
callback(null); | ||
}; | ||
FakeBulbAccessory.prototype.getServices = function () { | ||
var lightbulbService = new Service.Lightbulb(this.name); | ||
lightbulbService | ||
.getCharacteristic(Characteristic.On) | ||
.on('get', this.getPowerOn.bind(this)) | ||
.on('set', this.setPowerOn.bind(this)); | ||
return [lightbulbService]; | ||
}; | ||
{ | ||
"name": "homebridge-abode", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Abode Plugin for homebridge", | ||
@@ -5,0 +5,0 @@ "scripts": { |
8220
247