homebridge-syntex-webhooks
Advanced tools
Comparing version 2.0.6-b1 to 2.0.7-b10
92
index.js
@@ -15,2 +15,3 @@ var request = require('request'); | ||
homebridge.registerAccessory("homebridge-syntex-webhooks", "SynTexWebHookSwitch", SynTexWebHookSwitchAccessory); | ||
homebridge.registerAccessory("homebridge-syntex-webhooks", "SynTexWebHookStripeRGB", SynTexWebHookStripeRGBAccessory); | ||
}; | ||
@@ -27,2 +28,3 @@ | ||
this.switches = sconfig["switches"] || []; | ||
this.lights = sconfig["lights"] || []; | ||
@@ -54,2 +56,8 @@ this.cacheDirectory = sconfig["cache_directory"] || "./SynTex"; | ||
} | ||
for (var i = 0; i < this.lights.length; i++) | ||
{ | ||
var Light = new SynTexWebHookStripeRGBAccessory(this.lights[i]); | ||
accessories.push(Light); | ||
} | ||
@@ -186,3 +194,2 @@ callback(accessories); | ||
this.mac = sensorConfig["mac"]; | ||
this.id = sensorConfig["id"]; | ||
this.name = sensorConfig["name"]; | ||
@@ -371,3 +378,2 @@ this.type = sensorConfig["type"]; | ||
this.type = switchConfig["type"]; | ||
this.id = switchConfig["id"]; | ||
this.name = switchConfig["name"]; | ||
@@ -489,2 +495,84 @@ this.onURL = switchConfig["on_url"] || ""; | ||
function SynTexWebHookStripeRGBAccessory(switchConfig) | ||
{ | ||
this.mac = switchConfig["mac"]; | ||
this.type = switchConfig["type"]; | ||
this.name = switchConfig["name"]; | ||
this.onURL = switchConfig["on_url"] || ""; | ||
this.onMethod = switchConfig["on_method"] || "GET"; | ||
this.onBody = switchConfig["on_body"] || ""; | ||
this.onForm = switchConfig["on_form"] || ""; | ||
this.onHeaders = switchConfig["on_headers"] || "{}"; | ||
this.offURL = switchConfig["off_url"] || ""; | ||
this.offMethod = switchConfig["off_method"] || "GET"; | ||
this.offBody = switchConfig["off_body"] || ""; | ||
this.offForm = switchConfig["off_form"] || ""; | ||
this.offHeaders = switchConfig["off_headers"] || "{}"; | ||
this.service = new Service.Lightbulb(this.name); | ||
/* | ||
this.changeHandler = (function(newState) | ||
{ | ||
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für '" + this.name + "' geändert zu '" + newState + "' ( " + this.mac + " )"); | ||
this.service.getCharacteristic(Characteristic.On).updateValue(newState); | ||
}).bind(this); | ||
*/ | ||
this.service.getCharacteristic(Characteristic.On).on('get', this.getState.bind(this)).on('set', this.setState.bind(this)); | ||
//this.service.addCharacteristic(new Characteristic.Brightness()).on('get', this.getBrightness.bind(this)).on('set', this.setBrightness.bind(this)); | ||
this.service.addCharacteristic(new Characteristic.Hue()).on('get', this.getHue.bind(this))/*.on('set', this.setHue.bind(this))*/; | ||
//this.service.addCharacteristic(new Characteristic.Saturation()).on('get', this.getSaturation.bind(this)).on('set', this.setSaturation.bind(this)); | ||
} | ||
SynTexWebHookStripeRGBAccessory.prototype.getState = function(callback) | ||
{ | ||
var device = { | ||
mac: this.mac, | ||
name: this.name | ||
}; | ||
var name = this.name; | ||
var mac = this.mac; | ||
readDevice(device).then(function(res) { | ||
state = (res == 'true' || res); | ||
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für '" + name + "' ist '" + state + "'"); | ||
callback(null, state); | ||
}); | ||
}; | ||
SynTexWebHookStripeRGBAccessory.prototype.setState = function(powerOn, callback, context) | ||
{ | ||
callback(null); | ||
}; | ||
SynTexWebHookStripeRGBAccessory.prototype.getHue = function(callback) | ||
{ | ||
var device = { | ||
mac: this.mac, | ||
name: this.name | ||
}; | ||
var name = this.name; | ||
var mac = this.mac; | ||
readDevice(device).then(function(res) { | ||
state = 210; | ||
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für '" + name + "' ist '" + state + "'"); | ||
callback(null, state); | ||
}); | ||
}; | ||
SynTexWebHookStripeRGBAccessory.prototype.getServices = function() | ||
{ | ||
return [this.service]; | ||
}; | ||
async function updateDevice(obj) | ||
@@ -491,0 +579,0 @@ { |
{ | ||
"name": "homebridge-syntex-webhooks", | ||
"version": "2.0.6-b1", | ||
"version": "2.0.7-b10", | ||
"description": "A webhook plugin for HTTP devices", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
26570
530