Socket
Socket
Sign inDemoInstall

node-red-contrib-insteon

Package Overview
Dependencies
101
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.0 to 0.7.1

dist/device/common/functions.js

44

dist/device/insteonDeviceCommand/insteonDeviceCommand.js

@@ -11,2 +11,3 @@ "use strict";

};
const functions_1 = require("../common/functions");
function onStatus(node, text) {

@@ -27,6 +28,6 @@ node.status({ fill: 'green', shape: 'dot', text });

if (topic === 'switch') {
toggle(node, device, msg);
functions_1.toggle(node, device, msg);
}
else if (topic === 'dim') {
dim(node, device, msg);
functions_1.dim(node, device, msg);
}

@@ -38,41 +39,2 @@ else {

}
function toggle(node, device, msg) {
var _a, _b, _c, _d, _e, _f, _g, _h;
return __awaiter(this, void 0, void 0, function* () {
const status = (_b = (_a = msg) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.status;
const fast = (_e = (_d = (_c = msg) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.fast, (_e !== null && _e !== void 0 ? _e : false));
const level = (_h = (_g = (_f = msg) === null || _f === void 0 ? void 0 : _f.payload) === null || _g === void 0 ? void 0 : _g.level, (_h !== null && _h !== void 0 ? _h : 0xFF));
if (status === undefined || (status !== 'off' && status !== 'on' && status != 'instant')) {
node.error('Payload or Status in incorrect format');
return;
}
if (status == 'on')
fast ? device.LightOnFast() : device.LightOn(level);
else if (status == 'off')
fast ? device.LightOffFast() : device.LightOff();
else if (status == 'instant')
device.InstantOnOff(level);
else
node.error('Payload or Status in incorrect format');
});
}
function dim(node, device, msg) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
const direction = (_b = (_a = msg) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.dim;
const continuous = (_d = (_c = msg) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.continuous;
if (direction === undefined || (direction !== 'up' && direction !== 'down' && direction !== 'stop')) {
node.error('Payload or Status in incorrect format');
return;
}
if (direction == 'up')
continuous ? device.BeginBrightening() : device.BrightenOneStep();
else if (direction == 'down')
continuous ? device.BeginDimming() : device.DimOneStep();
else if (direction == 'stop')
device.StopChanging();
else
node.error('Payload or Status in incorrect format');
});
}
module.exports = function (RED) {

@@ -79,0 +41,0 @@ RED.nodes.registerType('insteon-device-command', function (props) {

@@ -11,2 +11,3 @@ "use strict";

};
const insteon_plm_1 = require("insteon-plm");
function setupDevice(node) {

@@ -24,3 +25,3 @@ return __awaiter(this, void 0, void 0, function* () {

try {
node.device = yield node.PLMConfigNode.plm.getDeviceInstance(node.address, { debug: false, syncInfo: false, syncLinks: false });
node.device = yield getDeviceInstance(node, node.PLMConfigNode.plm);
if (!node.device)

@@ -47,2 +48,9 @@ throw new Error('No Device Instance Found');

}
function getDeviceInstance(node, plm) {
return __awaiter(this, void 0, void 0, function* () {
const options = { debug: false, syncInfo: false, syncLinks: false };
const DeviceClass = yield insteon_plm_1.Utilities.getDeviceClassFromClassName(node.deviceType);
return DeviceClass ? new DeviceClass(node.address, plm, options) : null;
});
}
module.exports = function (RED) {

@@ -52,2 +60,3 @@ RED.nodes.registerType('insteon-device-config', function (config) {

this.address = config.address.split(".").map(_ => parseInt(_, 16));
this.deviceType = config.deviceType;
if (!config.modem) {

@@ -54,0 +63,0 @@ this.emit('status', 'No modem');

@@ -11,2 +11,3 @@ "use strict";

};
const functions_1 = require("../common/functions");
function onStatus(node, text) {

@@ -27,6 +28,6 @@ node.status({ fill: 'green', shape: 'dot', text });

if (topic === 'switch') {
msg.payload = yield toggle(node, device, msg);
msg.payload = yield functions_1.toggle(node, device, msg);
}
else if (topic === 'dim') {
msg.payload = yield dim(node, device, msg);
msg.payload = yield functions_1.dim(node, device, msg);
}

@@ -42,41 +43,2 @@ else if (topic === 'status') {

}
function toggle(node, device, msg) {
var _a, _b, _c, _d, _e, _f, _g, _h;
return __awaiter(this, void 0, void 0, function* () {
const status = (_b = (_a = msg) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.status;
const fast = (_e = (_d = (_c = msg) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.fast, (_e !== null && _e !== void 0 ? _e : false));
const level = (_h = (_g = (_f = msg) === null || _f === void 0 ? void 0 : _f.payload) === null || _g === void 0 ? void 0 : _g.level, (_h !== null && _h !== void 0 ? _h : 0xFF));
if (status === undefined || (status !== 'off' && status !== 'on' && status != 'instant')) {
node.error('Payload or Status in incorrect format');
return;
}
if (status == 'on')
return fast ? device.LightOnFast() : device.LightOn(level);
else if (status == 'off')
return fast ? device.LightOffFast() : device.LightOff();
else if (status == 'instant')
return device.InstantOnOff(level);
else
node.error('Payload or Status in incorrect format');
});
}
function dim(node, device, msg) {
var _a, _b, _c, _d;
return __awaiter(this, void 0, void 0, function* () {
const direction = (_b = (_a = msg) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.dim;
const continuous = (_d = (_c = msg) === null || _c === void 0 ? void 0 : _c.payload) === null || _d === void 0 ? void 0 : _d.continuous;
if (direction === undefined || (direction !== 'up' && direction !== 'down' && direction !== 'stop')) {
node.error('Payload or Status in incorrect format');
return;
}
if (direction == 'up')
return continuous ? device.BeginBrightening() : device.BrightenOneStep();
else if (direction == 'down')
return continuous ? device.BeginDimming() : device.DimOneStep();
else if (direction == 'stop')
return device.StopChanging();
else
node.error('Payload or Status in incorrect format');
});
}
module.exports = function (RED) {

@@ -83,0 +45,0 @@ RED.nodes.registerType('insteon-device-request', function (props) {

@@ -18,7 +18,3 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const insteon_plm_1 = __importStar(require("insteon-plm"));
const insteon_plm_2 = __importDefault(require("insteon-plm"));
let reconnectTime = 15000;

@@ -74,3 +70,3 @@ function setupPLM(node) {

try {
let PLMConfigNode = validatePLMConnection(RED, req.query.id);
let PLMConfigNode = RED.nodes.getNode(req.query.id);
res.json((_c = (_b = (_a = PLMConfigNode) === null || _a === void 0 ? void 0 : _a.plm) === null || _b === void 0 ? void 0 : _b.links, (_c !== null && _c !== void 0 ? _c : [])));

@@ -87,3 +83,3 @@ }

try {
let PLMConfigNode = validatePLMConnection(RED, req.query.id);
let PLMConfigNode = RED.nodes.getNode(req.query.id);
let address = insteon_plm_1.Utilities.toAddressArray(req.query.address);

@@ -126,5 +122,5 @@ if (address.length !== 3) {

let path = req.query.path;
const plm = new insteon_plm_2.default(path, { syncConfig: false, syncLinks: false });
const plm = new insteon_plm_1.default(path, { syncConfig: false, syncLinks: false });
plm.on('ready', () => {
const info = insteon_plm_2.default.getDeviceInfo(plm.info.devcat, plm.info.subcat, plm.info.firmware);
const info = insteon_plm_1.default.getDeviceInfo(plm.info.devcat, plm.info.subcat, plm.info.firmware);
const id = plm.info.id;

@@ -148,2 +144,19 @@ res.json({

}
function getDeviceType(RED, req, res) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const address = req.query.address.split('.').map((_) => parseInt(_, 16));
const modemId = req.query.modemId;
try {
let PLMConfigNode = RED.nodes.getNode(modemId);
const info = yield ((_b = (_a = PLMConfigNode) === null || _a === void 0 ? void 0 : _a.plm) === null || _b === void 0 ? void 0 : _b.queryDeviceInfo(address, { syncInfo: true, syncLinks: false, debug: false }));
if (!info)
res.status(500).send({ message: 'An error has occured while getting device info' });
res.json(info);
}
catch (e) {
res.status(500).send({ message: 'An error has occured', error: e });
}
});
}
function removeOldPLM(node) {

@@ -156,11 +169,2 @@ var _a, _b;

}
function validatePLMConnection(RED, configNodeId) {
var _a;
let PLMConfigNode = RED.nodes.getNode(configNodeId);
if (PLMConfigNode == null || PLMConfigNode.type !== 'insteon-modem-config')
throw Error("Invalid config node specified.");
if (PLMConfigNode.plm === null || !((_a = PLMConfigNode.plm) === null || _a === void 0 ? void 0 : _a.connected))
throw Error("The PLM is not connected. Cannot load links.");
return PLMConfigNode;
}
module.exports = function (RED) {

@@ -178,4 +182,5 @@ var _a;

RED.httpAdmin.get("/insteon/modem/links", RED.auth.needsPermission('serial.read'), (req, res) => getInsteonLinks(RED, req, res));
RED.httpAdmin.get("/insteon/device/type", RED.auth.needsPermission('serial.read'), (req, res) => getDeviceType(RED, req, res));
RED.httpAdmin.post("/insteon/device/manage", RED.auth.needsPermission('serial.read'), (req, res) => manageDevice(RED, req, res));
};
//# sourceMappingURL=insteonModemConfig.js.map
{
"name": "node-red-contrib-insteon",
"version": "0.7.0",
"version": "0.7.1",
"description": "A library of Node-RED nodes for interacting with the Insteon home automation ecosystem",

@@ -45,4 +45,4 @@ "license": "MIT",

"@types/express": "^4.17.2",
"insteon-plm": "^0.4.2"
"insteon-plm": "^0.5.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc