Skip to content

Commit

Permalink
first working version on input-node
Browse files Browse the repository at this point in the history
first public commit to github
  • Loading branch information
codmpm committed Feb 26, 2017
1 parent f8f5e47 commit d14e59c
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 79 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.AppleDouble*
.DS_Store
.idea
node_modules*

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Patrik Mayer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
node-red-contrib-loxone
=
This is a work-in-progress node to connect 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).

The connection is encrypted (hashed) via node-lox-ws-api.

> Help, pull requests and feedback in general are very welcome!
I've only tested it with a Temperature Sensor and a Switch module so far as I don't
have an own Loxone-Installation. Gladly a friend of mine lent me his spare miniserver.

![image of node-red editor](node-red-loxone-editor.png)
![image node-red dashboard](node-red-loxone-dashboard.png)

Currently working
-
* Configure a miniserver connection
* Loxone-In node
* Load structure file into node-red's editor to choose from
* Select a control and a state to "listen to" which then gets passed to node-red
* Control-name State-Name are given back in the `msg`-object

You can narrow the result by choosing a room or a category.

Your structure file can be retrieved via `http://<miniserver>/data/LoxAPP3.json`
An explanation of the file can be found [here](https://www.loxone.com/dede/wp-content/uploads/sites/2/2016/08/loxone-structure-file.pdf)

Currently partially working, caveats
-
* You have to load the structure file every time you edit a node - should be cached
* The "connected" info under the node in the editor is buggy atm
* Only `controls` are parsed, no `mediaServer`, `weatherServer`, etc.
Is this enough?
* ...

I've discovered that a switch element emits it's current state (`active`) two times.
One when the trigger-button is pressed and another when the button is released.

Maybe you can point me out, how to get I1-I8 directly via the WS-API.

ToDo
-
* Convenience / Testing!
* More info in `msg`-object based on structure file
* Configuration of the encryption mehthod - currently only "Hash"
* Loxone-Out
* better logging, more failsaveness
* ...

Installation
-
As the node has not reached an initial version it is not published via npm.

So currently you have to checkout the repository manually, see
https://nodered.org/docs/creating-nodes/packaging#testing-a-node-module-locally

git clone [email protected]:codmpm/node-red-contrib-loxone.git
cd node-red-contrib-loxone
sudo npm link
cd ~/.node-red
npm link node-red-contrib-loxone

After that, restart node-red.

Contributing
-

1. Fork it!
2. Create your feature branch: git checkout -b my-new-feature
3. Commit your changes: git commit -am 'Add some feature'
4. Push to the branch: git push origin my-new-feature
5. Submit a pull request :D

Credits
-
Patrik Mayer, 2017 - I'm not affiliated to [Loxone](https://www.loxone.com/) in any way.

Many thanks to [Nick O'Leary](https://github.com/knolleary), [Dave Conway-Jones](https://github.com/dceejay/)
and everyone else from the node-red Slack-Channel.

License
-
MIT

82 changes: 29 additions & 53 deletions loxone/loxone.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<script type="text/x-red" data-help-name="loxone-in">
<p>bla bla</p>








</script>


Expand All @@ -20,8 +13,11 @@
color: '#83B817',
defaults: {
name: {value: ''},
miniserver: {type: "loxone-miniserver", required: true},
stateUUID: {value: '', required: true}
miniserver: {type: 'loxone-miniserver', required: true},
control: {value: '', required: true},
controlName: {value: ''}, //TODO: take from structure file
stateName: {value: ''}, //TODO: take from structure file
uuid: {value: '', required: true}
},
inputs: 0,
outputs: 1,
Expand All @@ -30,13 +26,15 @@
return this.name || "loxone";
},
oneditprepare: function () {

$('#node-input-loadstruct').on('click', loadStructureFile);



//TODO: check for already loaded structure and select the saved uuid
},
oneditsave: function () {

//not needed it taken from structure file
this.controlName = $('#node-input-control option:selected').text();
this.stateName = $('#node-input-uuid option:selected').text();

disableChangeEvents();
},
oneditcancel: function () {
Expand All @@ -52,12 +50,11 @@

$.getJSON(url).done(function (data) {

console.log(data);
//console.log(data);

if (data.state == 'ok') {
miniserverStructure = data.structure;


var $roomSelect = $('#node-input-room');
var $categorySelect = $('#node-input-category');
var $controlSelect = $('#node-input-control');
Expand Down Expand Up @@ -102,6 +99,7 @@
}

$('#node-input-room, #node-input-category').on('change', fillControl);
$controlSelect.on('change', fillState);
}

$('#return-msg').text(data.msg);
Expand All @@ -124,7 +122,7 @@

$controlSelect.empty();

console.log(miniserverStructure);
//console.log(miniserverStructure);

var options = [];
for (var uuid in miniserverStructure.controls) {
Expand All @@ -142,25 +140,27 @@
}
$controlSelect.append(options.join(''));

$controlSelect.on('change', fillState);
if (options.length == 1) {
$controlSelect.trigger('change');
}

}

function fillState(e) {
console.log('fill state');
var $stateSelect = $('#node-input-stateUUID');
var $stateSelect = $('#node-input-uuid');
$stateSelect.empty();
$stateSelect.append('<option value=""></option>');

if (typeof miniserverStructure.controls[this.value] != 'undefined') {
for (var statename in miniserverStructure.controls[this.value].states) {
if (miniserverStructure.controls[this.value].states.hasOwnProperty(statename)) {
$stateSelect.append('<option value="' +
miniserverStructure.controls[this.value].states.statename + '">' +
statename + '</option>');

var control = miniserverStructure.controls[this.value];

for (var statename in control.states) {
if (control.states.hasOwnProperty(statename)) {
$stateSelect.append(
'<option value="' + control.states[statename] + '">' +
statename +
'</option>');
}
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@
<i class="icon-home"></i>
Room
</label>
<select id="node-input-room" name="node-input-room">
<select id="node-input-room">
</select>
</div>

Expand All @@ -205,7 +205,7 @@
<i class="icon-list"></i>
Category
</label>
<select id="node-input-category" name="node-input-category">
<select id="node-input-category">
</select>
</div>

Expand All @@ -214,16 +214,16 @@
<i class="icon-cog"></i>
Control
</label>
<select id="node-input-control" name="node-input-control">
<select id="node-input-control">
</select>
</div>

<div class="form-row">
<label for="node-input-stateUUID">
<label for="node-input-uuid">
<i class="fa fa-sticky-note-o" ></i>
State
</label>
<select id="node-input-stateUUID" name="node-input-stateUUID">
<select id="node-input-uuid">
</select>
</div>

Expand All @@ -240,15 +240,6 @@












</script>


Expand Down Expand Up @@ -292,21 +283,6 @@
<input type="password" id="node-config-input-password">
</div>
















</script>


Loading

0 comments on commit d14e59c

Please sign in to comment.