Socket
Socket
Sign inDemoInstall

node-red-contrib-deconz

Package Overview
Dependencies
Maintainers
1
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 0.10.6 to 0.10.7

7

deconz.js

@@ -42,3 +42,8 @@ var request = require('request');

if (controller && controller.constructor.name === "ServerNode") {
var item = controller.getDevice(config.uniqueid);
if (config.uniqueid.match(/^group_/)) {
var groupid = ((config.uniqueid).split('group_').join(''));
var item = controller.getGroup(groupid);
} else {
var item = controller.getDevice(config.uniqueid);
}
if (item) {

@@ -45,0 +50,0 @@ res.json(item.state);

@@ -20,2 +20,3 @@ module.exports = function(RED) {

node.server.on('onSocketOpen', () => this.onSocketOpen());
node.server.on('onSocketMessage', (data) => this.onSocketMessage(data));
node.server.on('onSocketPongTimeout', () => this.onSocketPongTimeout());

@@ -72,4 +73,22 @@ } else {

onSocketMessage(data) {
var node = this;
// console.log(data);
if ("t" in data && data.t === "event") {
node.send({'payload': data});
clearTimeout(node.cleanTimer);
node.status({
fill: "green",
shape: "dot",
text: 'event'
});
node.cleanTimer = setTimeout(function () {
node.status({}); //clean
}, 3000);
}
}
}
RED.nodes.registerType('deconz-event', deConzItemEvent);
};

36

nodes/get.js

@@ -29,30 +29,13 @@ module.exports = function(RED) {

var deviceMeta = node.server.getDevice(node.config.device);
if ((/group_/g).test(node.config.device)) {
var groupid = ((node.config.device).split('group_').join(''));
var group = node.server.getGroup(groupid);
node.meta = group
if (group !== false) {
node.send({
payload:node.meta.state['any_on'],
meta:group,
});
} else {
node.status({
fill: "red",
shape: "dot",
text: 'no device'
});
node.cleanTimer = setTimeout(function(){
node.status({}); //clean
}, 3000);
}
} else if (deviceMeta) {
var deviceMeta = node.server.getGroup(groupid);
} else {
var deviceMeta = node.server.getDevice(node.config.device);
}
if (deviceMeta) {
node.server.devices[node.id] = deviceMeta.uniqueid;
node.meta = deviceMeta;
//status

@@ -84,3 +67,2 @@ if ("state" in deviceMeta && "reachable" in deviceMeta.state && deviceMeta.state.reachable === false) {

node.cleanTimer = setTimeout(function(){

@@ -110,7 +92,1 @@ node.status({}); //clean

};

@@ -18,2 +18,4 @@ module.exports = function(RED) {

node.server.on('onNewDevice', (uniqueid) => this.onNewDevice(uniqueid));
node.sendLastState();
} else {

@@ -101,14 +103,15 @@ node.status({

//filter output
if ('onchange' === node.config.output && device.state[node.config.state] === node.oldState) return;
if ('onupdate' === node.config.output && device.state['lastupdated'] === node.prevUpdateTime) return;
//outputs
if ( !(node.config.state in device.state && node.config.output == 'onchange' && device.state[node.config.state] == node.oldState) &&
!(node.config.state in device.state && node.config.output == 'onupdate' && device.state['lastupdated'] == node.prevUpdateTime ))
{
node.send([
{
payload: (node.config.state in device.state) ? device.state[node.config.state] : device.state,
payload_raw: device
},
node.formatHomeKit(device)
]);
}
node.send([
{
payload: (node.config.state in device.state) ? device.state[node.config.state] : device.state,
payload_raw: device
},
node.formatHomeKit(device)
]);
node.oldState = device.state[node.config.state];

@@ -298,3 +301,2 @@ node.prevUpdateTime = device.state['lastupdated'];

var node = this;
node.sendLastState();
}

@@ -301,0 +303,0 @@

@@ -21,3 +21,3 @@ var request = require('request');

node.devices = {};
node.setMaxListeners(255);
node.refreshDiscoverTimer = null;

@@ -33,2 +33,4 @@ node.refreshDiscoverInterval = 15000;

});
node.socket.on('close', (code, reason) => this.onSocketClose(code, reason));

@@ -216,21 +218,8 @@ node.socket.on('unauthorized', () => this.onSocketUnauthorized());

onSocketMessage(dataParsed) {
var that = this;
that.emit('onSocketMessage', dataParsed);
for (var nodeId in this.devices) {
var item = this.devices[nodeId];
if ("event" === item && "t" in dataParsed && dataParsed.t == "event") {
var node = RED.nodes.getNode(nodeId);
var serverNode = RED.nodes.getNode(node.server.id);
if (node && "type" in node && node.type === "deconz-event" && serverNode && "items" in serverNode) {
node.send({'payload': dataParsed});
clearTimeout(node.cleanTimer);
node.status({
fill: "green",
shape: "dot",
text: 'event'
});
node.cleanTimer = setTimeout(function () {
node.status({}); //clean
}, 3000);
}
}

@@ -237,0 +226,0 @@ if (dataParsed.uniqueid === item) {

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

},
"version": "0.10.6"
"version": "0.10.7"
}

@@ -6,6 +6,10 @@ # node-red-contrib-deconz

* deconz-in: A node to subscribe to deCONZ devices
* deconz-get: get state of device or group
* deconz-out: send data to device or group
* deconz-battery: get battery status of device
* deconz-event: get all deconz events
<b>IMPORTANT:</b> This is only very early test version, without OUT node
<img src="https://github.com/andreypopov/node-red-contrib-deconz/blob/master/readme/1.png?raw=true">

@@ -16,2 +20,6 @@ <img src="https://github.com/andreypopov/node-red-contrib-deconz/blob/master/readme/2.png?raw=true">

https://www.youtube.com/watch?v=blzeK5NFN-I&feature=youtu.be
https://youtu.be/i3TiZiuNofM
# Support
Developing and supporting this plugin needs time and efforts. Appreciate your support on [Patreon](https://www.patreon.com/bePatron?u=12661781). Here, you can sign up to be a member and help support my project.

Sorry, the diff of this file is not supported yet

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