Skip to content

Commit

Permalink
added stream-in node, removed keepalive log message
Browse files Browse the repository at this point in the history
closes #15
closes #16
  • Loading branch information
codmpm committed Nov 5, 2017
1 parent 8b38fe9 commit 814b32a
Show file tree
Hide file tree
Showing 5 changed files with 288 additions and 65 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.7.0
* added stream-in node
* removed keepalive log message
* refactored event handling and building of msg-object

### 0.6.2
* fixed missing msg-object data in control-in node introduced in `0.6.1`

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Tested with loxone-config V9.0.9.26, node-red 0.17.5, nodeJS 6.11.4 LTS
* **Webservice**: Send direct webservice calls through the existing websocket, see the [webservice documenation](https://www.loxone.com/enen/kb/web-services/).
Please use URI's in form of `jdev/sps/io/foo` (no leading `/`), simply replace `dev/` from the documentation with `jdev/`. The returned
value will be in `msg.payload`.
* **Stream-In**: Receive all (!) occuring events from a selected room and/or category. Could be handy to put every temperature (e.g.) into
a database or something - see the node for more info.
* **Online**: Emit's `true`/`false` for the state of the connection to the selected miniserver. Be careful as every failed
connection attempt sends a `false` over and over again till a connection could be established.
* **Keepalive**: outputs the current time (in ms) from the keepalive request done by the underlying library (node-lox-ws-api)
Expand Down Expand Up @@ -103,7 +105,7 @@ take care of this as it might give you unexpected results. This could be catched
Also keep in mind, that this element sends `1/0` but expects to be fed with `On/Off/Pulse`.

### nodeJS
I advice you to use the latest [LTS version](https://github.com/nodejs/LTS) of nodeJS - currently `6.10.3`.
I advice you to use the latest [LTS version](https://github.com/nodejs/LTS) of nodeJS - currently `6.11.5`.

If you realy can not update to a supported version of nodeJS, the last version of node-red-contrib-loxone running with
nodeJS `< 4.5` is `0.4.0` which can be installed with:
Expand Down
175 changes: 160 additions & 15 deletions loxone/loxone.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@
}
}

$controlSelect.append('<option value=""></option>');
for (uuid in data.structure.controls) {
if (data.structure.controls.hasOwnProperty(uuid)) {
var $option = $('<option value="' + uuid + '">' +
(data.structure.controls[uuid].parent ? ' └─ ' : '') +
data.structure.controls[uuid].name +
'</option>');
$option.appendTo($controlSelect);
if ($controlSelect.length) {
$controlSelect.append('<option value=""></option>');
for (uuid in data.structure.controls) {
if (data.structure.controls.hasOwnProperty(uuid)) {
var $option = $('<option value="' + uuid + '">' +
(data.structure.controls[uuid].parent ? ' └─ ' : '') +
data.structure.controls[uuid].name +
'</option>');
$option.appendTo($controlSelect);
}
}
}

Expand Down Expand Up @@ -208,6 +210,10 @@







</script>

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







</script>

<script type="text/javascript">
Expand Down Expand Up @@ -305,7 +315,7 @@
$controlSelect.on('change', fillState);
$('#node-input-room, #node-input-category').on('change', fillControl);

if (node.control) {
if (node.control && data.structure.controls.hasOwnProperty(node.control)) {

//select proper room and category for selected control
var controlFromStructure = data.structure.controls[node.control];
Expand Down Expand Up @@ -353,6 +363,10 @@







</script>


Expand Down Expand Up @@ -407,6 +421,10 @@







</script>

<script type="text/javascript">
Expand Down Expand Up @@ -440,7 +458,7 @@

var $controlSelect = $('#node-input-control');

if (node.control) {
if (node.control && data.structure.controls.hasOwnProperty(node.control)) {

//select proper room and category for selected control
var controlFromStructure = data.structure.controls[node.control];
Expand Down Expand Up @@ -489,6 +507,10 @@
</p>






</script>


Expand Down Expand Up @@ -549,6 +571,10 @@
</div>






</script>

<script type="text/javascript">
Expand Down Expand Up @@ -600,6 +626,10 @@







</script>


Expand Down Expand Up @@ -651,6 +681,10 @@







</script>

<script type="text/javascript">
Expand Down Expand Up @@ -686,6 +720,10 @@







</script>


Expand Down Expand Up @@ -713,6 +751,10 @@







</script>

<script type="text/javascript">
Expand Down Expand Up @@ -744,15 +786,62 @@
See page 17 of the <a href="https://www.loxone.com/dede/wp-content/uploads/sites/2/2016/08/loxone-communicating-with-the-miniserver.pdf" target="_blank">
webservice documentation</a>.
</p>
</script>

<script type="text/x-red" data-template-name="loxone-keepalive">

<div class="form-row">
<label for="node-input-miniserver">
<i class="fa fa-globe"></i>
Miniserver
</label>
<input type="text" id="node-input-miniserver">
</div>

<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>

<div class="form-row">
<span id="return-msg"></span>
</div>

</script>

<script type="text/javascript">
RED.nodes.registerType('loxone-keepalive', {
category: 'loxone',
paletteLabel: 'keepalive',
color: '#83B817',
defaults: {
name: {value: ''},
miniserver: {type: 'loxone-miniserver', required: true},
},
inputs: 0,
outputs: 1,
icon: "loxone.png",
align: "left",
label: function () {
return this.name || "keepalive";
}
});
</script>

<script type="text/x-red" data-template-name="loxone-keepalive">

<script type="text/x-red" data-help-name="loxone-stream-in">
<p>
This node will hook up to a combination of room and/or category
to receive all events generated by items in that room and/or category.<br>
<br>
For example, you can use this to receive temeprature data from all controls of a category
and feed it to a database for analysis of historical data afterwards.<br>
<br>
<b>Note:</b> You have to select at least a room or a category!
</p>
</script>

<script type="text/x-red" data-template-name="loxone-stream-in">

<div class="form-row">
<label for="node-input-miniserver">
Expand All @@ -762,11 +851,43 @@
<input type="text" id="node-input-miniserver">
</div>

<div class="form-row">
<label for="node-input-room">
<i class="icon-home"></i>
Room
</label>
<select id="node-input-room">
</select>
</div>

<div class="form-row">
<label for="node-input-category">
<i class="icon-list"></i>
Category
</label>
<select id="node-input-category">
</select>
</div>

<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>

<div class="form-tips">
<b>Warning:</b> For EVERY state on every control from the selected room/category
there will be a message on occurance. See <code>msg.state</code> to know which state
triggered the event.<br>
On reconnect, including full-deploy, every state gets send. So you will get a message
for every state present in the control for your selected room/category.<br>
<br>
For Example: AutomaticBlinds have 8 states. So for every state you will get a
message on connect/reconnect.<br>
On occurance only the state that caused the event gives a message.<br>
<br>
Controls without a state are ignored as they don't fire events.
</div>

<div class="form-row">
<span id="return-msg"></span>
</div>
Expand All @@ -779,21 +900,45 @@
</script>

<script type="text/javascript">
RED.nodes.registerType('loxone-keepalive', {
RED.nodes.registerType('loxone-stream-in', {
category: 'loxone',
paletteLabel: 'keepalive',
paletteLabel: 'stream in',
color: '#83B817',
defaults: {
name: {value: ''},
miniserver: {type: 'loxone-miniserver', required: true},
category: {value: ''},
room: {value: ''}
},
inputs: 0,
outputs: 1,
icon: "loxone.png",
align: "left",
label: function () {
return this.name || "keepalive";
}
return this.name || "stream in";
},
oneditprepare: function () {
var node = this;

function prepareInput() {
disableChangeEvents();
$('#node-input-miniserver').on('change', prepareInput);
$('#node-input-category, #node-input-room').removeClass('input-error');

getStructureFile(function (data) {
$('#node-input-category').val(node.category);
$('#node-input-room').val(node.room);

if(!node.category && !node.room){
$('#node-input-category, #node-input-room').addClass('input-error');
}
});
}

prepareInput();
},
oneditsave: disableChangeEvents,
oneditcancel: disableChangeEvents
});
</script>

Expand Down
Loading

0 comments on commit 814b32a

Please sign in to comment.