Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-contrib-deconz

Package Overview
Dependencies
Maintainers
2
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-deconz - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

7

CHANGELOG.md

@@ -10,2 +10,9 @@ # Changelog

## [2.0.5] - 2021-10-13 ![Relative date](https://img.shields.io/date/1634079545?label=)
### Fixed
- Fix HomeKit loop detection.
- Fix node error on partial deploy.
## [2.0.4] - 2021-10-11 ![Relative date](https://img.shields.io/date/1633986241?label=)

@@ -12,0 +19,0 @@

107

nodes/battery.js
const OutputMsgFormatter = require("../src/runtime/OutputMsgFormatter");
const ConfigMigration = require("../src/migration/ConfigMigration");
const Utils = require("../src/runtime/Utils");

@@ -8,2 +7,8 @@

const defaultRule = {
type: 'config',
format: 'single',
onstart: true
};
const defaultConfig = {

@@ -19,14 +24,5 @@ name: "",

outputs: 1,
output_rules: [{
type: 'config',
format: 'single',
onstart: true
}]
output_rules: [defaultRule]
};
const defaultRule = {
type: 'config',
format: 'single',
onstart: true
};

@@ -60,49 +56,61 @@ class deConzItemBattery {

node.server.on('onStart', () => {
// Config migration
let configMigration = new ConfigMigration(NodeType, node.config, node.server);
let migrationResult = configMigration.applyMigration(node.config, node);
if (Array.isArray(migrationResult.errors) && migrationResult.errors.length > 0) {
migrationResult.errors.forEach(
error => console.error(`Error with migration of node ${node.type} with id ${node.id}`, error)
);
node.error(
`Error with migration of node ${node.type} with id ${node.id}\n` +
migrationResult.errors.join('\n') +
'\nPlease open the node settings and update the configuration'
);
node.status({
fill: "red",
shape: "dot",
text: "node-red-contrib-deconz/server:status.migration_error"
});
return;
let initNode = function () {
node.server.off('onStart', initNode);
if (node.server.migrateNodeConfiguration(node)) {
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.registerNode();
node.server.updateNodeStatus(node, null);
node.ready = true;
}
};
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
if (node.server.state.pooling.isValid === true) {
(async () => {
await Utils.sleep(1500);
initNode();
node.server.propagateStartNews([node.id]);
})().then().catch((error) => {
console.error(error);
});
} else {
node.server.on('onStart', initNode);
}
if (node.config.search_type === 'device') {
node.config.device_list.forEach(function (item) {
node.server.registerNodeByDevicePath(node.config.id, item);
});
} else {
node.server.registerNodeWithQuery(node.config.id);
}
node.on('close', (removed, done) => {
this.unregisterNode();
done();
});
node.server.updateNodeStatus(node, null);
node.ready = true;
});
}
registerNode() {
let node = this;
if (node.config.search_type === 'device') {
node.config.device_list.forEach(function (item) {
node.server.registerNodeByDevicePath(node.config.id, item);
});
} else {
node.server.registerNodeWithQuery(node.config.id);
}
}
unregisterNode() {
let node = this;
if (node.config.search_type === "device") {
node.config.device_list.forEach(function (item) {
node.server.unregisterNodeByDevicePath(node.config.id, item);
});
} else {
node.server.unregisterNodeWithQuery(node.config.id);
}
}
handleDeconzEvent(device, changed, rawEvent, opt) {
let node = this;
(async () => {
let waitResult = await Utils.waitForEverythingReady(node);
if (waitResult) {
return;
}
if (waitResult) return;
let msgs = new Array(this.config.output_rules.length);
let options = Object.assign({

@@ -124,2 +132,3 @@ initialEvent: false,

let msgs = new Array(this.config.output_rules.length);
this.config.output_rules.forEach((saved_rule, index) => {

@@ -132,5 +141,7 @@ // Make sure that all expected config are defined

msgs.fill(undefined);
// Format msgs, can get one or many msgs.
let formatter = new OutputMsgFormatter(rule, NodeType, this.config);
let msgToSend = formatter.getMsgs({data: device, changed}, rawEvent, options);
// Make sure that the result is an array

@@ -162,3 +173,1 @@ if (!Array.isArray(msgToSend)) msgToSend = [msgToSend];

};

@@ -21,3 +21,4 @@ module.exports = function (RED) {

node.server.on('onStart', () => {
let initCounter = () => {
node.server.off('onStart', initCounter);
node.status({

@@ -29,2 +30,8 @@ fill: "green",

});
};
node.server.on('onStart', initCounter);
node.on('close', (removed, done) => {
node.server.unregisterEventNode(node.id);
done();
});

@@ -31,0 +38,0 @@

@@ -49,28 +49,22 @@ const ConfigMigration = require("../src/migration/ConfigMigration");

node.server.on('onStart', () => {
// Config migration
let configMigration = new ConfigMigration(NodeType, node.config, node.server);
let migrationResult = configMigration.applyMigration(node.config, node);
if (Array.isArray(migrationResult.errors) && migrationResult.errors.length > 0) {
migrationResult.errors.forEach(
error => console.error(`Error with migration of node ${node.type} with id ${node.id}`, error)
);
node.error(
`Error with migration of node ${node.type} with id ${node.id}\n` +
migrationResult.errors.join('\n') +
'\nPlease open the node settings and update the configuration'
);
node.status({
fill: "red",
shape: "dot",
text: "node-red-contrib-deconz/server:status.migration_error"
});
return;
let initNode = function () {
node.server.off('onStart', initNode);
if (node.server.migrateNodeConfiguration(node)) {
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.server.updateNodeStatus(node, null);
node.ready = true;
}
};
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.server.updateNodeStatus(node, null);
node.ready = true;
});
if (node.server.state.pooling.isValid === true) {
(async () => {
await Utils.sleep(1500);
initNode();
})().then().catch((error) => {
console.error(error);
});
} else {
node.server.on('onStart', initNode);
}

@@ -77,0 +71,0 @@ node.on('input', (message_in, send, done) => {

@@ -1,3 +0,1 @@

const dotProp = require('dot-prop');
const ConfigMigration = require("../src/migration/ConfigMigration");
const OutputMsgFormatter = require("../src/runtime/OutputMsgFormatter");

@@ -57,36 +55,28 @@ const Utils = require("../src/runtime/Utils");

node.server.on('onStart', () => {
// Config migration
let configMigration = new ConfigMigration(NodeType, node.config, node.server);
let migrationResult = configMigration.applyMigration(node.config, node);
if (Array.isArray(migrationResult.errors) && migrationResult.errors.length > 0) {
migrationResult.errors.forEach(
error => console.error(`Error with migration of node ${node.type} with id ${node.id}`, error)
);
node.error(
`Error with migration of node ${node.type} with id ${node.id}\n` +
migrationResult.errors.join('\n') +
'\nPlease open the node settings and update the configuration'
);
node.status({
fill: "red",
shape: "dot",
text: "node-red-contrib-deconz/server:status.migration_error"
});
return;
let initNode = function () {
node.server.off('onStart', initNode);
if (node.server.migrateNodeConfiguration(node)) {
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.registerNode();
node.server.updateNodeStatus(node, null);
node.ready = true;
}
};
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
if (node.server.state.pooling.isValid === true) {
(async () => {
await Utils.sleep(1500);
initNode();
node.server.propagateStartNews([node.id]);
})().then().catch((error) => {
console.error(error);
});
} else {
node.server.on('onStart', initNode);
}
if (node.config.search_type === "device") {
node.config.device_list.forEach(function (item) {
node.server.registerNodeByDevicePath(node.config.id, item);
});
} else {
node.server.registerNodeWithQuery(node.config.id);
}
node.server.updateNodeStatus(node, null);
node.ready = true;
node.on('close', (removed, done) => {
this.unregisterNode();
done();
});

@@ -96,3 +86,24 @@

//TODO wait for migration before sending events
registerNode() {
let node = this;
if (node.config.search_type === 'device') {
node.config.device_list.forEach(function (item) {
node.server.registerNodeByDevicePath(node.config.id, item);
});
} else {
node.server.registerNodeWithQuery(node.config.id);
}
}
unregisterNode() {
let node = this;
if (node.config.search_type === "device") {
node.config.device_list.forEach(function (item) {
node.server.unregisterNodeByDevicePath(node.config.id, item);
});
} else {
node.server.unregisterNodeWithQuery(node.config.id);
}
}
handleDeconzEvent(device, changed, rawEvent, opt) {

@@ -105,3 +116,2 @@ let node = this;

let msgs = new Array(this.config.output_rules.length);
let options = Object.assign({

@@ -123,2 +133,3 @@ initialEvent: false,

let msgs = new Array(this.config.output_rules.length);
this.config.output_rules.forEach((saved_rule, index) => {

@@ -155,3 +166,2 @@ // Make sure that all expected config are defined

});
}

@@ -163,3 +173,1 @@

};

@@ -76,27 +76,21 @@ const CommandParser = require("../src/runtime/CommandParser");

node.server.on('onStart', () => {
// Config migration
let configMigration = new ConfigMigration(NodeType, node.config, node.server);
let migrationResult = configMigration.applyMigration(node.config, node);
if (Array.isArray(migrationResult.errors) && migrationResult.errors.length > 0) {
migrationResult.errors.forEach(
error => console.error(`Error with migration of node ${node.type} with id ${node.id}`, error)
);
node.error(
`Error with migration of node ${node.type} with id ${node.id}\n` +
migrationResult.errors.join('\n') +
'\nPlease open the node settings and update the configuration'
);
node.status({
fill: "red",
shape: "dot",
text: "node-red-contrib-deconz/server:status.migration_error"
});
return;
let initNode = function () {
node.server.off('onStart', initNode);
if (node.server.migrateNodeConfiguration(node)) {
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.ready = true;
}
};
// Make sure that all expected config are defined
node.config = Object.assign({}, defaultConfig, node.config);
node.ready = true;
});
if (node.server.state.pooling.isValid === true) {
(async () => {
await Utils.sleep(1500);
initNode();
})().then().catch((error) => {
console.error(error);
});
} else {
node.server.on('onStart', initNode);
}

@@ -103,0 +97,0 @@ node.on('input', (message_in, send, done) => {

@@ -211,6 +211,13 @@ const got = require('got');

propagateStartNews() {
propagateStartNews(whitelistNodes) {
let node = this;
// Node with device selected
let filterMethod;
if (Array.isArray(whitelistNodes)) {
filterMethod = (id) => whitelistNodes.includes(id);
}
for (let [device_path, nodeIDs] of Object.entries(node.nodesByDevicePath)) {
if (filterMethod) nodeIDs = nodeIDs.filter(filterMethod);
node.propagateNews(nodeIDs, {

@@ -225,2 +232,3 @@ type: 'start',

for (let nodeID of node.nodesWithQuery) {
if (filterMethod && filterMethod(nodeID) === false) continue;
let target = RED.nodes.getNode(nodeID);

@@ -744,2 +752,24 @@

}
migrateNodeConfiguration(node) {
let configMigration = new ConfigMigration(node.type, node.config, this);
let migrationResult = configMigration.applyMigration(node.config, node);
if (Array.isArray(migrationResult.errors) && migrationResult.errors.length > 0) {
migrationResult.errors.forEach(
error => console.error(`Error with migration of node ${node.type} with id ${node.id}`, error)
);
node.error(
`Error with migration of node ${node.type} with id ${node.id}\n` +
migrationResult.errors.join('\n') +
'\nPlease open the node settings and update the configuration'
);
node.status({
fill: "red",
shape: "dot",
text: "node-red-contrib-deconz/server:status.migration_error"
});
return false;
}
return true;
}
}

@@ -746,0 +776,0 @@

{
"name": "node-red-contrib-deconz",
"version": "2.0.4",
"version": "2.0.5",
"description": "deCONZ connectivity nodes for node-red",

@@ -5,0 +5,0 @@ "keywords": [

@@ -38,3 +38,3 @@ const Utils = require("./Utils");

case 'homekit':
if (this.message_in.hap !== undefined && this.message_in.hap.session !== undefined) {
if (this.message_in.hap !== undefined && this.message_in.hap.session === undefined) {
this.node.error("Deconz outptut node received a message that was not initiated by a HomeKit node. " +

@@ -41,0 +41,0 @@ "Make sure you disable the 'Allow Message Passthrough' in homekit-bridge node or ensure " +

@@ -71,3 +71,3 @@ const REDUtil = require("@node-red/util/lib/util");

});
await this.waitForReady(node.server.state);
await this.waitForReady(node.server.state, 30000);
if (node.server.ready === false) {

@@ -79,2 +79,3 @@ node.status({

});
console.error('Timeout, the server node is not ready after 30 seconds.');
return "node-red-contrib-deconz/server:status.server_node_error";

@@ -86,3 +87,3 @@ } else {

await this.waitForReady(node);
await this.waitForReady(node, 30000);

@@ -95,2 +96,3 @@ if (node.ready === false) {

});
console.error('Timeout, the node is not ready after 30 seconds.');
return "node-red-contrib-deconz/server:status.node_error";

@@ -97,0 +99,0 @@ }

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