Huge News!Announcing our $40M Series B led by Abstract Ventures.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.5-b2 to 1.0.5-b20

236

index.js

@@ -5,2 +5,4 @@ var request = require('request');

var store = require('json-fs-store');
var fs = require('fs');
var path = require('path');
var Service, Characteristic;

@@ -86,6 +88,105 @@

if(err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", "ERR", err);
}
else
{
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "!ERR");
}
if(obj)
{
log(obj.devices);
{
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", "OBJ");
}
else
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", "!OBJ");
}
if(!obj && err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht geparst werden!");
var pathname = this.cacheDirectory + 'storage.json';
fs.exists(pathname, function (exist)
{
if(!exist)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", pathname + ' wurde nicht gefunden!');
}
else
{
fs.readFile(pathname, function(err, data)
{
if(err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", 'Die Seite konnte nicht geladen werden: ' + err);
}
else
{
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", pathname);
log(data.toString());
}
});
}
});
}
else if(!obj && !err)
{
log('\x1b[33m%s\x1b[0m', "[INFO]", "Storage.json wurde ohne Inhalt geladen!");
if(urlParams.type)
{
var device = {
id: "storage",
devices: [{mac: urlParams.mac, value: urlParams.value, type: urlParams.type}]
};
}
else
{
var device = {
id: "storage",
devices: [{mac: urlParams.mac, value: urlParams.value}]
};
}
log(device);
this.storage.add(device, (err) => {
if(err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!");
}
var pathname = this.cacheDirectory + 'storage.json';
fs.exists(pathname, function (exist)
{
if(!exist)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", pathname + ' wurde nicht gefunden!');
}
else
{
fs.readFile(pathname, function(err, data)
{
if(err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", 'Die Seite konnte nicht geladen werden: ' + err);
}
else
{
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", pathname);
log(data.toString());
}
});
}
});
});
}
else if(obj && !err)
{
var found = false;

@@ -106,3 +207,3 @@

}
else
else if(!urlParams.type)
{

@@ -128,2 +229,4 @@ obj.devices[i].value = urlParams.value;

log(obj);
this.storage.add(obj, (err) => {

@@ -135,29 +238,27 @@

}
});
}
else
{
log('\x1b[31m%s\x1b[0m', "[ERROR 1]", "Storage.json konnte nicht geladen werden!");
if(urlParams.type)
{
var device = {
id: "storage",
devices: [{mac: urlParams.mac, value: urlParams.value, type: urlParams.type}]
};
}
else
{
var device = {
id: "storage",
devices: [{mac: urlParams.mac, value: urlParams.value}]
};
}
this.storage.add(device, (err) => {
if(err)
var pathname = this.cacheDirectory + 'storage.json';
fs.exists(pathname, function (exist)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht aktualisiert werden!");
}
if(!exist)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", pathname + ' wurde nicht gefunden!');
}
else
{
fs.readFile(pathname, function(err, data)
{
if(err)
{
log('\x1b[31m%s\x1b[0m', "[ERROR]", 'Die Seite konnte nicht geladen werden: ' + err);
}
else
{
log('\x1b[32m%s\x1b[0m', "[SUCCESS]", pathname);
log(data.toString());
}
});
}
});
});

@@ -199,7 +300,8 @@ }

}
if(err)
/*
if(obj && obj.devices)
{
log('\x1b[31m%s\x1b[0m', "[ERROR 2]", "Storage.json konnte nicht geladen werden!");
log(obj.devices);
}
*/
});

@@ -214,3 +316,3 @@

if(obj)
if(obj && !err)
{

@@ -254,3 +356,3 @@ var found = false;

{
log('\x1b[31m%s\x1b[0m', "[ERROR 3]", "Storage.json konnte nicht geladen werden!");
log('\x1b[31m%s\x1b[0m', "[ERROR]", "Storage.json konnte nicht geladen werden!");
}

@@ -357,3 +459,2 @@ });

}
/*

@@ -363,11 +464,8 @@ else if(this.type === "occupancy")

this.service = new Service.OccupancySensor(this.name);
this.changeHandler = (function(newState) {
this.changeHandler = (function(newState)
{
this.service.getCharacteristic(Characteristic.OccupancyDetected).updateValue(newState ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED, undefined, CONTEXT_FROM_WEBHOOK);
if (this.autoRelease) {
setTimeout(function() {
this.storage.setItemSync("http-webhook-" + this.id, false);
this.service.getCharacteristic(Characteristic.OccupancyDetected).updateValue(Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED, undefined, CONTEXT_FROM_TIMEOUTCALL);
}.bind(this), this.autoReleaseTime);
}
}).bind(this);
this.service.getCharacteristic(Characteristic.OccupancyDetected).on('get', this.getState.bind(this));

@@ -378,6 +476,9 @@ }

this.service = new Service.SmokeSensor(this.name);
this.changeHandler = (function(newState) {
this.changeHandler = (function(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);
}).bind(this);
this.service.getCharacteristic(Characteristic.SmokeDetected).on('get', this.getState.bind(this));

@@ -388,6 +489,9 @@ }

this.service = new Service.AirQualitySensor(this.name);
this.changeHandler = (function(newState) {
this.changeHandler = (function(newState)
{
log("Change HomeKit value for air quality sensor to '%s'.", newState);
this.service.getCharacteristic(Characteristic.AirQuality).updateValue(newState, undefined, CONTEXT_FROM_WEBHOOK);
}).bind(this);
this.service.getCharacteristic(Characteristic.AirQuality).on('get', this.getState.bind(this));

@@ -404,3 +508,3 @@ }

if(obj)
if(obj && !err)
{

@@ -454,2 +558,12 @@ for(var i = 0; i < obj.devices.length; i++)

}
/*
else if(this.type === "smoke")
{
callback(null, state ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED);
}
else if(this.type === "occupancy")
{
callback(null, state ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED);
}
*/
else if(this.type === "light")

@@ -466,13 +580,2 @@ {

});
/*
else if(this.type === "smoke")
{
callback(null, state ? Characteristic.SmokeDetected.SMOKE_DETECTED : Characteristic.SmokeDetected.SMOKE_NOT_DETECTED);
}
else if(this.type === "occupancy")
{
callback(null, state ? Characteristic.OccupancyDetected.OCCUPANCY_DETECTED : Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED);
}
*/
};

@@ -521,5 +624,4 @@

if(obj)
if(obj && !err)
{
for(var i = 0; i < obj.devices.length; i++)

@@ -563,5 +665,14 @@ {

if(!powerOn)
{
urlToCall = this.offURL;
urlMethod = this.offMethod;
urlBody = this.offBody;
urlForm = this.offForm;
urlHeaders = this.offHeaders;
}
this.storage.load('storage', (err, obj) => {
if(obj)
if(obj && !err)
{

@@ -610,11 +721,2 @@ var found = false;

if(!powerOn)
{
urlToCall = this.offURL;
urlMethod = this.offMethod;
urlBody = this.offBody;
urlForm = this.offForm;
urlHeaders = this.offHeaders;
}
if(urlToCall != "")

@@ -621,0 +723,0 @@ {

{
"name": "homebridge-syntex-webhooks",
"version": "1.0.5-b2",
"version": "1.0.5-b20",
"description": "A webhook plugin for HTTP devices",

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

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