Skip to content

Commit

Permalink
Language support for objects tree
Browse files Browse the repository at this point in the history
  • Loading branch information
sebilm committed Feb 17, 2019
1 parent 4b3486a commit e416fc0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ This adapter is still in development. You can use it but without support and hel

## Changelog

### 0.0.2
* Language support for objects tree

### 0.0.1
* initial release
* Initial release

## License
The MIT License (MIT)
Expand Down
19 changes: 17 additions & 2 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,31 @@
</div>
</div>
<div class="row">
<div class="input-field col s12 m6 l6">
<div class="input-field col s12 m4 l4">
<input type="number" class="value" id="SystemId" />
<label for="SystemId" class="translate">System ID</label>
<span class="translate">Log in at https://www.nibeuplink.com. It is the number in the URL.</span>
</div>
<div class="input-field col s12 m6 l6">
<div class="input-field col s12 m4 l4">
<input type="number" class="value" id="Interval" min="1" />
<label for="Interval" class="translate">Refresh interval</label>
<span class="translate">Time in minutes of fetching data from Nibe Uplink.</span>
</div>
<div class="input-field col s12 m4 l4">
<select class="value" id="Language">
<option value="en" class="translate">English</option>
<option value="de" class="translate">German</option>
<option value="cs" class="translate">Czech</option>
<option value="da" class="translate">Danish</option>
<option value="nl" class="translate">Dutch</option>
<option value="fi" class="translate">Finnish</option>
<option value="fr" class="translate">French</option>
<option value="pl" class="translate">Polish</option>
<option value="sv" class="translate">Swedish</option>
</select>
<label for="Language" class="translate">Language</label>
<span class="translate">The language for naming the data objects.</span>
</div>
</div>
</div>
</div>
Expand Down
11 changes: 8 additions & 3 deletions io-package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"common": {
"name": "nibeuplink",
"version": "0.0.1",
"version": "0.0.2",
"news": {
"0.0.2": {
"en": "Language support for objects tree",
"de": "Unterstützung von Sprachen im Objektbaum"
},
"0.0.1": {
"en": "initial adapter",
"en": "Initial adapter",
"de": "Initiale Version",
"ru": "Первоначальный адаптер",
"pt": "Versão inicial",
Expand Down Expand Up @@ -50,7 +54,8 @@
},
"native": {
"CallbackURL": "https://z0mt3c.github.io/nibe.html",
"Interval": 1
"Interval": 1,
"Language": "en"
},
"objects": [
]
Expand Down
3 changes: 2 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ function main() {
redirectUri: adapter.config.CallbackURL,
interval: refreshInterval * 60,
authCode: adapter.config.AuthCode,
systemId: adapter.config.SystemId
systemId: adapter.config.SystemId,
language: adapter.config.Language
}, adapter);

f.on('data', (data) => {
Expand Down
9 changes: 6 additions & 3 deletions nibe-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ const defaultOptions = {
},
interval: 60,
timezone: 'Europe/Berlin',
language: 'en',
renewBeforeExpiry: 5 * 60 * 1000,
sessionStore: Path.join(__dirname, './.session.json')
}
Expand Down Expand Up @@ -408,7 +409,8 @@ class Fetcher extends EventEmitter {
return new Promise((resolve, reject) => {
this.wreck.get(`/api/v1/systems/${systemId}/serviceinfo/categories`, {
headers: {
Authorization: 'Bearer ' + this.getSession('access_token')
Authorization: 'Bearer ' + this.getSession('access_token'),
'Accept-Language': this.options.language,
},
json: true
}, (error, response, payload) => {
Expand All @@ -428,7 +430,8 @@ class Fetcher extends EventEmitter {
return new Promise((resolve, reject) => {
this.wreck.get(`/api/v1/systems/${systemId}/serviceinfo/categories/status?categoryId=${category}`, {
headers: {
Authorization: 'Bearer ' + this.getSession('access_token')
Authorization: 'Bearer ' + this.getSession('access_token'),
'Accept-Language': this.options.language,
},
json: true
}, (error, response, payload) => {
Expand All @@ -448,7 +451,7 @@ 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('_')).toLowerCase().replace(/[_]+$/, '');
const name = i.parameterId || (item.categoryId + '_' + i.title.split(/[^a-z]+/gi).join('_')).toUpperCase().replace(/[_]+$/, '');
const parameters = this.options.parameters[name];
Object.assign(i, {
key: name,
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.1",
"version": "0.0.2",
"description": "nibeuplink",
"author": {
"name": "Sebastian Haesselbarth",
Expand Down

0 comments on commit e416fc0

Please sign in to comment.