diff --git a/CHANGELOG.md b/CHANGELOG.md
index 78bf249..8fdfa71 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+### 0.3.0
+* added keepalive node
+* correct handling of online-node with more than one miniserver connection
+
+### 0.2.2
+* fixed error if empty room name or empty category name
+
### 0.2.1
* fixed error on deploying after editing the config node
@@ -9,7 +16,8 @@
### 0.1.0
* breaks compatibility to 0.0.x
-* updated `node-lox-ws`
+* added webservice-node
+* updated `node-lox-ws-api`
### 0.0.x
* control-in
diff --git a/loxone/loxone.html b/loxone/loxone.html
index 12674c4..b7aba63 100644
--- a/loxone/loxone.html
+++ b/loxone/loxone.html
@@ -649,3 +649,57 @@
});
+
+
+
+
+
+
+
+
diff --git a/loxone/loxone.js b/loxone/loxone.js
index d712e68..643d853 100644
--- a/loxone/loxone.js
+++ b/loxone/loxone.js
@@ -123,7 +123,7 @@ module.exports = function (RED) {
client.connect();
client.on('connect', function () {
- node.log('Miniserver connected (' + config.host + ':' + config.port) + ')';
+ node.log('Miniserver connected (' + config.host + ':' + config.port + ')');
node.connected = true;
});
@@ -133,7 +133,7 @@ module.exports = function (RED) {
node.connection = client;
node.setConnectionState("green", "connected", "dot");
- sendOnlineMsg(true);
+ sendOnlineMsg(true, config.id);
});
client.on('connect_failed', function () {
@@ -153,7 +153,7 @@ module.exports = function (RED) {
node.connection = null;
node.setConnectionState("yellow", "connection closed", "ring");
- sendOnlineMsg(false);
+ sendOnlineMsg(false, config.id);
});
client.on('send', function (message) {
@@ -206,6 +206,23 @@ module.exports = function (RED) {
client.on('keepalive', function (time) {
node.log('keepalive (' + time + 'ms)');
+
+ RED.nodes.eachNode(function (nodeData) {
+
+ if (nodeData.type === 'loxone-keepalive' &&
+ nodeData.hasOwnProperty('miniserver') &&
+ nodeData.miniserver === node.id) {
+
+ var keepaliveNode = RED.nodes.getNode(nodeData.id);
+ if (keepaliveNode) {
+ keepaliveNode.send({
+ topic: 'keepalive',
+ payload: time
+ });
+ }
+ }
+ });
+
});
client.on('message_header', function (header) {
@@ -241,7 +258,7 @@ module.exports = function (RED) {
} else {
done();
}
- sendOnlineMsg(false);
+ sendOnlineMsg(false, config.id);
});
}
@@ -291,7 +308,8 @@ module.exports = function (RED) {
});
};
- LoxoneMiniserver.prototype.setConnectionState = function (color, text, shape = 'dot') {
+ LoxoneMiniserver.prototype.setConnectionState = function (color, text, shape) {
+ shape = shape || 'dot';
var newState = function (item) {
item.status({
fill: color,
@@ -393,13 +411,15 @@ module.exports = function (RED) {
return structure;
};
- function sendOnlineMsg(online) {
+ function sendOnlineMsg(online, configId) {
online = online || false;
RED.nodes.eachNode(function (theNode) {
- if (theNode.type == 'loxone-online') {
+ if (theNode.type === 'loxone-online' &&
+ theNode.hasOwnProperty('miniserver') &&
+ theNode.miniserver === configId) {
var node = RED.nodes.getNode(theNode.id);
@@ -520,12 +540,15 @@ module.exports = function (RED) {
function LoxoneOnlineNode(config) {
RED.nodes.createNode(this, config);
- var node = this;
- node.miniserver = RED.nodes.getNode(config.miniserver);
}
RED.nodes.registerType('loxone-online', LoxoneOnlineNode);
+ function LoxoneKeepaliveNode(config) {
+ RED.nodes.createNode(this, config);
+ }
+
+ RED.nodes.registerType('loxone-keepalive', LoxoneKeepaliveNode);
+
-}
-;
+};
diff --git a/package.json b/package.json
index 96e5a6c..4d7a4ab 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-loxone",
- "version": "0.2.2",
+ "version": "0.3.0",
"description": "Connecting the Loxone Miniserver to node-red via Websocket API",
"license": "MIT",
"keywords": [