Skip to content

Commit

Permalink
updated node-lox-ws-api to 0.3.4 for interim lox9 communication
Browse files Browse the repository at this point in the history
added "activate connection" checkbox
  • Loading branch information
codmpm committed Sep 29, 2017
1 parent d2a56d0 commit e90336e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 0.5.0
* updated `node-lox-ws-api` to `0.3.4` for an intermediate solution working with Loxone 9
* added checkbox to activate a miniserver connection

### 0.4.2
* `node-lox-ws-api` updated to `0.3.2`

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# node-red-contrib-loxone

> **Attention: node-red-contrib-loxone is currently not working with Loxone 9 - we are working on a solution**
> **Attention:**
> Beginning with version 0.5 Loxone 9 is supported. Still work needed for a propper communication.
> @alladdin implemented an interim solution in `node-lox-ws-api 0.3.4` to get it to work with Loxone 9.

This node connects the Loxone Miniserver to node-red. It uses [node-lox-ws-api](https://github.com/alladdin/node-lox-ws-api)
by Ladislav Dokulil based on Loxone's documenation for the [Websocket API](https://www.loxone.com/dede/wp-content/uploads/sites/2/2016/08/loxone-communicating-with-the-miniserver.pdf).
Expand Down
22 changes: 21 additions & 1 deletion loxone/loxone.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@




</script>

<script type="text/x-red" data-template-name="loxone-control-in">
Expand Down Expand Up @@ -265,6 +266,7 @@




</script>

<script type="text/javascript">
Expand Down Expand Up @@ -344,6 +346,7 @@




</script>


Expand Down Expand Up @@ -395,6 +398,7 @@




</script>

<script type="text/javascript">
Expand Down Expand Up @@ -479,6 +483,7 @@




</script>


Expand All @@ -504,6 +509,13 @@
<label for="node-config-input-password"><i class="fa fa-lock"></i> Password</label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label></label>
<input type="checkbox" id="node-config-input-active" style="display:inline-block; width:auto; vertical-align:top;">
<label style="width: 70%;" for="node-config-input-active">
Activate connection?
</label>
</div>
<div class="form-row">
<label></label>
<input type="checkbox" id="node-config-input-encrypted" style="display:inline-block; width:auto; vertical-align:top;">
Expand All @@ -514,6 +526,7 @@




</script>

<script type="text/javascript">
Expand All @@ -522,7 +535,8 @@
defaults: {
host: {value: "", required: true},
port: {value: 80, required: true, validate: RED.validators.number()},
encrypted: {value: false}
encrypted: {value: false},
active: {value: true}
},
credentials: {
username: {type: "text", required: true},
Expand Down Expand Up @@ -560,6 +574,7 @@
}</pre>
</p>


</script>


Expand Down Expand Up @@ -608,6 +623,7 @@




</script>

<script type="text/javascript">
Expand Down Expand Up @@ -640,6 +656,7 @@




</script>


Expand All @@ -664,6 +681,7 @@




</script>

<script type="text/javascript">
Expand Down Expand Up @@ -698,6 +716,7 @@




</script>

<script type="text/x-red" data-template-name="loxone-keepalive">
Expand All @@ -721,6 +740,7 @@




</script>

<script type="text/javascript">
Expand Down
40 changes: 38 additions & 2 deletions loxone/loxone.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ module.exports = function (RED) {
structure: {}
};

if (configNode && configNode.connected) {
if(configNode.active !== true){
result.msg = 'connection disabled'
}

if (configNode && configNode.active && configNode.connected) {

result = {
state: 'ok',
Expand All @@ -42,13 +46,19 @@ module.exports = function (RED) {
var password = req.query.password;

var configNode = RED.nodes.getNode(req.query.id);

if (configNode) {
if (!username) {
username = configNode.credentials.username;
}
if (!password) {
password = configNode.credentials.password;
}

if(configNode.active !== true){
result.msg = 'connection disabled'
}

}

http.get({
Expand Down Expand Up @@ -107,6 +117,12 @@ module.exports = function (RED) {
node._outputNodes = [];
node._webserviceNodes = []; //only webservice nodes which have a message sent will be here

//do nothing if miniserver is not active
if(config.active !== true){
node.log('connection to ' + config.host + ':' + config.port + ' disabled');
return;
}

var text_logger_limit = 100;
var ws_auth = config.encrypted ? 'AES-256-CBC' : 'Hash';

Expand Down Expand Up @@ -151,9 +167,10 @@ module.exports = function (RED) {
node.connected = false;
node.authenticated = false;
node.connection = null;
client.abort();

node.setConnectionState("yellow", "connection closed", "ring");
sendOnlineMsg(false, config.id);
//sendOnlineMsg(false, config.id);
});

client.on('send', function (message) {
Expand Down Expand Up @@ -316,8 +333,12 @@ module.exports = function (RED) {
shape: shape,
text: text
});

//console.log(item.status);
};

//console.log(this._inputNodes);

this._inputNodes.forEach(newState);
this._outputNodes.forEach(newState);
};
Expand Down Expand Up @@ -455,9 +476,17 @@ module.exports = function (RED) {
node.miniserver.registerInputNode(node);

this.on('close', function (done) {

node.status({
fill: 'yellow',
shape: 'dot',
text: 'offline'
});

if (node.miniserver) {
node.miniserver.deregisterInputNode(node);
}

done();
});
}
Expand All @@ -483,6 +512,13 @@ module.exports = function (RED) {
});

this.on('close', function (done) {

node.status({
fill: 'yellow',
shape: 'dot',
text: 'offline'
});

if (node.miniserver) {
node.miniserver.deregisterOutputNode(node);
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-loxone",
"version": "0.4.2",
"version": "0.5.0",
"description": "Connecting the Loxone Miniserver to node-red via Websocket API",
"license": "MIT",
"keywords": [
Expand All @@ -12,7 +12,7 @@
}
},
"dependencies": {
"node-lox-ws-api": "^0.3.2"
"node-lox-ws-api": "^0.3.4"
},
"repository": "codmpm/node-red-contrib-loxone"
}

0 comments on commit e90336e

Please sign in to comment.