Skip to content

Commit

Permalink
Objects tree changed: New, more readable objects added
Browse files Browse the repository at this point in the history
  • Loading branch information
sebilm committed Feb 17, 2019
1 parent 6f1f03a commit cbaae28
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 10 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# ioBroker.nibeuplink
This adapter is still in development. You can use it but without support and help. Later I will document it here.

**Attention:**
In version 0.1.0 new, more readable objects were added to the object tree. In a later version the old objects in the child paths will be removed!

## Changelog

### 0.1.0
* Objects tree changed: New, more readable objects added

### 0.0.2
* Language support for objects tree

Expand Down
6 changes: 5 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"common": {
"name": "nibeuplink",
"version": "0.0.2",
"version": "0.1.0",
"news": {
"0.1.0": {
"en": "Objects tree changed: New, more readable objects added",
"de": "Objektbaum wurde geändert: Neue, besser lesbare Objekte wurden hinzugefügt"
},
"0.0.2": {
"en": "Language support for objects tree",
"de": "Unterstützung von Sprachen im Objektbaum"
Expand Down
40 changes: 35 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,21 +185,51 @@ function main() {

for (var i in data) {
var par = data[i];
var key = par["key"];
var title = par["title"];
var designation = par["designation"];
if ((designation != undefined) && (designation != ""))
{
title = title + " (" + designation + ")";
}
var categoryId = par["categoryId"];
createChannel(categoryId, par["categoryName"]);

var valuePath = categoryId + "." + key.toString().toUpperCase();
adapter.setObjectNotExists(valuePath, {
type: 'state',
common: {
name: title,
type: 'number',
role: 'value',
unit: par["unit"]
},
native: {}
});
adapter.setState(valuePath, {val: par["value"], ack: true});
var displayPath = categoryId + "." + key.toString().toUpperCase() + "_DISPLAY";
adapter.setObjectNotExists(displayPath, {
type: 'state',
common: {
name: title + " [Display]",
type: 'string',
role: 'text'
},
native: {}
});
adapter.setState(displayPath, {val: par["displayValue"], ack: true});

var parameterId = par["parameterId"];
var categoryId = par ["categoryId"];
var path = categoryId + "." + parameterId;
createChannel(path, title);

for (var p in par) {
var parPath = path + "." + p;
var value = par[p];
if ((p == "value") || (p == "rawValue" || (p == "divideBy") || (p == "parameterId")))
createNumberObject(parPath, p);
else if (p != "name")
createStringObject(parPath, p);
adapter.setState(parPath, {val: value, ack: true});
}
adapter.setState(parPath, {val: par[p], ack: true});
}
}
adapter.log.debug("Data processed.");
});
Expand Down
18 changes: 15 additions & 3 deletions nibe-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,27 @@ class Fetcher extends EventEmitter {
async.map(categories, (item, reply) => {
this.fetchParams(item.categoryId).then((result) => {
result.forEach((i) => {
const name = i.parameterId || (item.categoryId + '_' + i.title.split(/[^a-z]+/gi).join('_')).toUpperCase().replace(/[_]+$/, '');
const parameters = this.options.parameters[name];
var name = i.title;
if ((i.designation != undefined) && (i.designation != ""))
{
name = name + "_" + i.designation;
}
name = (name.split(/[^a-z]+/gi).join('_')).toUpperCase().replace(/[_]+$/, '');
const parameters = this.options.parameters[i.parameterId];
Object.assign(i, {
key: name,
categoryId: item.categoryId
categoryId: item.categoryId,
categoryName: item.name
}, parameters)

if (i.divideBy > 0)
{
i.value = i.rawValue / i.divideBy;
}
else
{
i.value = i.rawValue;
}
})
reply(null, result)
}, (error) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.nibeuplink",
"version": "0.0.2",
"version": "0.1.0",
"description": "nibeuplink",
"author": {
"name": "Sebastian Haesselbarth",
Expand Down

0 comments on commit cbaae28

Please sign in to comment.