New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-syntex-webhooks

Package Overview
Dependencies
Maintainers
1
Versions
1176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-syntex-webhooks - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4-b1

147

index.js
var request = require('request');
var http = require('http');
var https = require('https');
var url = require('url');
var auth = require('http-auth');
var store = require('json-fs-store');

@@ -19,17 +17,21 @@ var Service, Characteristic;

function SynTexWebHookPlatform(log, config, api)
var log;
var config;
function SynTexWebHookPlatform(slog, sconfig, api)
{
config = store(api.user.storagePath());
log = slog;
this.sensors = config["sensors"] || [];
this.switches = config["switches"] || [];
this.configPath = api.user.storagePath();
this.config = store(this.configPath);
this.cacheDirectory = config["cache_directory"] || "./.node-persist/storage";
this.port = config["port"] || 1710;
this.storage = store(this.cacheDirectory);
this.log = log;
//this.autoConfig = config["autoConfig"] || true;
this.port = config["port"] || 1710;
}
SynTexWebHookPlatform.prototype = {
accessories : function(callback)

@@ -41,3 +43,3 @@ {

{
var Sensor = new SynTexWebHookSensorAccessory(this.log, this.sensors[i], this.storage);
var Sensor = new SynTexWebHookSensorAccessory(this.sensors[i], this.storage);
accessories.push(Sensor);

@@ -48,3 +50,3 @@ }

{
var Switch = new SynTexWebHookSwitchAccessory(this.log, this.switches[i], this.storage);
var Switch = new SynTexWebHookSwitchAccessory(this.switches[i], this.storage);
accessories.push(Switch);

@@ -61,8 +63,11 @@ }

var body = [];
request.on('error', (function(err)
{
this.log("[ERROR] Reason: %s.", err);
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Reason: ", err);
}).bind(this)).on('data', function(chunk)
{
body.push(chunk);
}).on('end', (function()

@@ -86,3 +91,3 @@ {

{
this.log('[Devices] Storage.json geladen!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json geladen!");

@@ -126,3 +131,4 @@ var found = false;

this.storage.add(obj, (err) => {
this.log('Storage aktualisiert!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json aktualisiert!");
});

@@ -148,3 +154,4 @@ }

this.storage.add(device, (err) => {
this.log('Storage aktualisiert!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json aktualisiert!");
});

@@ -197,3 +204,3 @@ }

{
this.log('[Devices] Storage.json geladen!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json geladen!");

@@ -225,24 +232,10 @@ var found = false;

}
else
{
response.write("Error MAC");
response.end();
}
}
else if(urlPath == '/ping')
{
this.log(this.configPath);
response.write("");
response.end();
}
else
{
// Index
this.log("Index wurde aufgerufen!");
response.write("Hallo Welt!");
response.end();
}
}).bind(this));
}).bind(this);

@@ -252,9 +245,8 @@

this.log("Data Link Server läuft auf Port '%s'.", this.port);
log('\x1b[33m%s\x1b[0m', "[INFO]", "Data Link Server läuft auf Port ", "'" + this.port + "'");
}
}
function SynTexWebHookSensorAccessory(log, sensorConfig, storage)
function SynTexWebHookSensorAccessory(sensorConfig, storage)
{
this.log = log;
this.mac = sensorConfig["mac"];

@@ -272,3 +264,3 @@ this.id = sensorConfig["id"];

{
this.log("Change HomeKit state for contact sensor to '%s'.", newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )");
this.service.getCharacteristic(Characteristic.ContactSensorState).updateValue(newState ? Characteristic.ContactSensorState.CONTACT_DETECTED : Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);

@@ -285,3 +277,3 @@ }).bind(this);

{
this.log("Change HomeKit state for contact sensor to '%s'.", newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )");
this.service.getCharacteristic(Characteristic.MotionDetected).updateValue(newState);

@@ -298,3 +290,3 @@ }).bind(this);

{
this.log("Change HomeKit value for temperature sensor to '%s'.", newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )");
this.service.getCharacteristic(Characteristic.CurrentTemperature).updateValue(newState);

@@ -314,4 +306,3 @@ }).bind(this);

{
this.log("Change HomeKit value for humidity sensor to '%s'.", newState);
this.service.getCharacteristic(Characteristic.CurrentRelativeHumidity).updateValue(newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )"); this.service.getCharacteristic(Characteristic.CurrentRelativeHumidity).updateValue(newState);
}).bind(this);

@@ -327,3 +318,3 @@

{
this.log("Change HomeKit value for humidity sensor to '%s'.", newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )");
this.service.getCharacteristic(Characteristic.LeakDetected).updateValue(newState);

@@ -340,4 +331,3 @@ }).bind(this);

{
this.log("Change HomeKit value for light sensor to '%s'.", newState);
this.service.getCharacteristic(Characteristic.CurrentAmbientLightLevel).updateValue(parseFloat(newState));
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )"); this.service.getCharacteristic(Characteristic.CurrentAmbientLightLevel).updateValue(parseFloat(newState));
}).bind(this);

@@ -367,3 +357,3 @@

this.changeHandler = (function(newState) {
this.log("Change HomeKit state for smoke sensor to '%s'.", newState);
log("Change HomeKit state for smoke sensor to '%s'.", newState);
this.service.getCharacteristic(Characteristic.SmokeDetected).updateValue(newState ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED, undefined, CONTEXT_FROM_WEBHOOK);

@@ -377,3 +367,3 @@ }).bind(this);

this.changeHandler = (function(newState) {
this.log("Change HomeKit value for air quality sensor to '%s'.", newState);
log("Change HomeKit value for air quality sensor to '%s'.", newState);
this.service.getCharacteristic(Characteristic.AirQuality).updateValue(newState, undefined, CONTEXT_FROM_WEBHOOK);

@@ -387,5 +377,3 @@ }).bind(this);

SynTexWebHookSensorAccessory.prototype.getState = function(callback)
{
this.log("Getting current state for '%s'...", this.id);
{
var state = null;

@@ -448,3 +436,3 @@

this.log("Status von '%s' ist '%s'", this.id, state);
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für " + this.name + " ( " + this.type + " ) ist '" + state + "' ( " + this.mac + " )");
});

@@ -470,43 +458,6 @@

function SynTexWebHookSwitchAccessory(log, switchConfig, storage)
function SynTexWebHookSwitchAccessory(switchConfig, storage)
{
this.log = log;
this.mac = switchConfig["mac"];
this.type = switchConfig["type"];
this.id = switchConfig["id"];

@@ -530,3 +481,3 @@ this.name = switchConfig["name"];

{
this.log("Change HomeKit state for switch to '%s'.", newState);
log('\x1b[36m%s\x1b[0m', "[UPDATE]", "HomeKit Status für " + this.name + " ( " + this.type + " ) geändert zu '" + newState + "' ( " + this.mac + " )");
this.service.getCharacteristic(Characteristic.On).updateValue(newState);

@@ -540,4 +491,2 @@ }).bind(this);

{
this.log("Getting current state for '%s'...", this.id);
var state = null;

@@ -559,4 +508,2 @@

state = (state === 'true');
this.log("Device Found");
}

@@ -574,3 +521,3 @@ }

this.log("Status von '%s' ist '%s'", this.id, state);
log('\x1b[36m%s\x1b[0m', "[READ]", "HomeKit Status für " + this.name + " ( " + this.type + " ) ist '" + newState + "' ( " + this.mac + " )");
});

@@ -581,4 +528,2 @@ };

{
this.log("Switch state for '%s'...", this.id);
var urlToCall = this.onURL;

@@ -594,3 +539,3 @@ var urlMethod = this.onMethod;

{
this.log('[Switch] Storage.json geladen!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json geladen!");

@@ -615,3 +560,3 @@ var found = false;

this.storage.add(obj, (err) => {
this.log('Storage aktualisiert!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json aktualisiert!");
});

@@ -627,3 +572,3 @@ }

this.storage.add(device, (err) => {
this.log('Storage aktualisiert!');
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "Storage.json aktualisiert!");
});

@@ -655,3 +600,3 @@ }

{
this.log("Adding Form " + urlForm);
//log("Adding Form " + urlForm);
theRequest.form = JSON.parse(urlForm);

@@ -661,3 +606,3 @@ }

{
this.log("Adding Body " + urlBody);
//log("Adding Body " + urlBody);
theRequest.body = urlBody;

@@ -670,3 +615,3 @@ }

this.log("Request to '%s' finished with status code '%s' and body '%s'.", urlToCall, statusCode, body, err);
log("Anfrage zu '%s' wurde mit dem Status Code '%s' beendet: '%s'", urlToCall, statusCode, body, err);

@@ -673,0 +618,0 @@ if(!err && statusCode == 200)

{
"name": "homebridge-syntex-webhooks",
"version": "1.0.3",
"version": "1.0.4-b1",
"description": "A webhook plugin for HTTP devices",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

# Homebridge Syntex Webhooks
# Homebridge SynTex Webhooks
A plugin to control and to create HTTP devices.

@@ -25,3 +25,15 @@

# Update HTTP Devices
1. Open `http://<bridgeIP>/devices?mac=<bridgeMac>&value=<newValue>`
2. Insert the `Bridge IP` and `Device Mac`
3. For the `New Value` you can type these patterns:
- For boolean devices: `true` / `false`
- For numeric devices: `10` / `12.4`
# See HTTP Device Values
1. Open `http://<bridgeIP>/devices?mac=<bridgeMac>`
2. Insert the `Bridge IP` and `Device Mac`
# Currently Supported

@@ -28,0 +40,0 @@ - Temperature Sensor

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc