Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core Files/Testing Update and introduce adapter-core #5

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# ioBroker.etamon
ioBroker adapter for ETA heating systems with XML Rest API (touch display)

> *The development of the adapter has shown issues when running on less performant devices such as NAS devices.*
> *You can still use the adapter if you run iobroker on a common desktop/laptop device.*

As a consequence I recommend using the following JS implementation - you will just need to map once the proper URI from your ETA device.
```
var http = require('http');
var xpath = require('xpath');
var dom = require('xmldom').DOMParser;

var etaIP = 'http://192.168.XYZ.XYZ:8080/user/var';

// 1. URI
// 2. iobroker Object
// 3. read
// 4. write
// 5. name
// 6. type
// 7. unit
// 8. role
// 9. CCU variable (optional)
var etaVars = [
["/120/10251/0/0/12242", "eta.puffer.oben", true, false, "Puffer oben", "number", "°C", "value.temperature", "hm-rega.0.1810"]
,["/120/10251/0/0/12244", "eta.puffer.unten", true, false, "Puffer unten", "number", "°C", "value.temperature", "hm-rega.0.1811"]
,["/120/10251/0/0/12207", "eta.puffer.aktion", true, false, "Puffer Aktion", "string", "", "state", "hm-rega.0.1809"]
,["/120/10251/0/0/12533", "eta.puffer.leistung", true, false, "Puffer Leistung", "number", "KW", "state", "hm-rega.0.5038"]
,["/120/10251/0/0/12129", "eta.puffer.zustand", true, false, "Puffer Zustand", "string", "", "state", ""]

,["/120/10101/0/0/12090", "eta.hk.1.zustand", true, false, "Heizkreis Zustand", "string", "", "state", "hm-rega.0.1812"]
,["/120/10101/0/0/12241", "eta.hk.1.vorlauf", true, false, "Heizkreis Vorlauf", "number", "°C", "value.temperature", "hm-rega.0.8047"]
,["/120/10101/0/0/12111", "eta.hk.1.heizkurve", true, false, "Heizkreis Heizkurve", "number", "°C", "value.temperature", "hm-rega.0.8048"]
,["/120/10101/0/11124/0", "eta.hk.1.pumpe", true, false, "Heizkreis Pumpe", "string", "", "state", "hm-rega.0.1813"]
,["/120/10101/0/11124/2001", "eta.hk.1.anforderung", true, false, "Heizkreis Anforderung", "string", "", "state", ""]

,["/40/10021/0/0/12000", "eta.kessel.aktion", true, false, "Kessel", "string", "", "state", "hm-rega.0.1822"]
,["/40/10021/0/0/12153", "eta.kessel.vollast", true, false, "Kessel Vollaststunden", "string", "", "state", "hm-rega.0.1814"]
,["/40/10021/0/0/12016", "eta.kessel.verbrauch", true, false, "Kessel Gesmtverbrauch", "number", "kg", "state", "hm-rega.0.1815"]
,["/40/10021/0/0/12013", "eta.kessel.aschebox", true, false, "Kessel Verbrauch seit Aschebox", "number", "kg", "state", ""]
,["/40/10021/0/0/12180", "eta.kessel.druck", true, false, "Kessel Druck", "number", "bar", "state", "hm-rega.0.1820"]
,["/40/10021/0/0/12001", "eta.kessel.soll", true, false, "Kessel Soll", "number", "°C", "state", "hm-rega.0.5037"]
,["/40/10021/0/0/12161", "eta.kessel.ist", true, false, "Kessel Ist", "number", "°C", "state", "hm-rega.0.3195"]
,["/40/10021/0/0/12162", "eta.kessel.abgasgtemp", true, false, "Kessel Abgastemperatur", "number", "°C", "state", "hm-rega.0.5040"]
,["/40/10021/0/0/12165", "eta.kessel.abgasgeblaese", true, false, "Kessel Abgasgebläse", "number", "U/min", "state", "hm-rega.0.5039"]
,["/40/10021/0/0/12164", "eta.kessel.restsauerstoff", true, false, "Kessel Restsauerstoff", "number", "%", "state", "hm-rega.0.5041"]
,["/40/10021/0/0/12080", "eta.kessel.zustand", true, false, "Kessel Zustand", "string", "", "state", "hm-rega.0.1808"]

,["/40/10201/0/0/12015", "eta.lager.silo", true, false, "Pellets Silo", "number", "kg", "state", "hm-rega.0.1817"]
,["/40/10021/0/0/12011", "eta.lager.tag", true, false, "Pellets Tagesbehälter", "number", "kg", "state", "hm-rega.0.9651"]
,["/40/10241/0/0/12197", "eta.system.aussentemperatur", true, false, "Aussentemperatur", "number", "°C", "state", "hm-rega.0.1821"]
];

etaVars.forEach(function(etaVar){
createState(etaVar[1], 0, {
read: etaVar[2],
write: etaVar[3],
name: etaVar[4],
type: etaVar[5],
unit: etaVar[6],
role: etaVar[7]
});
});

schedule("*/5 * * * *", function () {
pollETA();
});

pollETA();

function pollETA() {
// console.log("** Polling ETA Variables");
etaVars.forEach(function(etaVar){
http.get(etaIP + etaVar[0], function (http_res) {

// initialize the container for our data
var data = "";

// this event fires many times, each time collecting another piece of the response
http_res.on("data", function (chunk) {
// append this chunk to our growing `data` var
data += chunk;
// console.log("** ETA chunk: " + chunk);
});

// this event fires *one* time, after all the `data` events/chunks have been gathered
http_res.on("end", function () {
// console.log("** ETA data: " + data);

try {
var doc = new dom().parseFromString(data);
var select = xpath.useNamespaces({"eta": "http://www.eta.co.at/rest/v1"});

var strValue = (select('//eta:value/@strValue', doc)[0].nodeValue);
var text = (select('//eta:value/text()', doc)[0].nodeValue);
var scaleFactor = (select('//eta:value/@scaleFactor', doc)[0].nodeValue);
var unit = (select('//eta:value/@unit', doc)[0].nodeValue);
var value = "";

if (etaVar[5]=="number") {
value = text * 1.0 / scaleFactor;
} else {
value = strValue;
}

/* console.log("**** ETA " + etaVar[0] + " @strValue: " + strValue);
console.log("**** ETA " + etaVar[0] + " @unit: " + unit);
console.log("**** ETA " + etaVar[0] + " text() : " + text);
console.log("**** ETA " + etaVar[0] + " @scaleFactor: " + scaleFactor);
console.log("** ETA [" + etaVar[4] + "]: " + value + " " + unit); */

setState(etaVar[1], value);

// Schreibe Variablen zu CCU
if(etaVar[8]!="") {
setState(etaVar[8], value);
}
}
catch (e) {
log("ETA: Cannot set data "+ etaVar[2] +":" + e, 'error');
}
});
});
});

var dateFormat = require('dateformat');
var currentdate = new Date();
log(dateFormat(currentdate, "dd. mmm yyyy hh:MM"));
// optional last update in CCU3
setState("hm-rega.0.7022", dateFormat(currentdate, "dd. mmm yyyy hh:MM"));
}
```
15 changes: 7 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
version: 'test-{build}'
environment:
matrix:
- nodejs_version: '4'
- nodejs_version: '6'
- nodejs_version: '8'
- nodejs_version: '10'
- nodejs_version: '12'
- nodejs_version: '14'
- nodejs_version: '16'
platform:
- x86
- x64
clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%'
install:
- ps: 'Install-Product node $env:nodejs_version $env:platform'
- ps: 'Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform'
- ps: '$NpmVersion = (npm -v).Substring(0,1)'
- ps: 'if($NpmVersion -eq 5) { npm install -g npm@5 }'
- ps: npm --version
- npm install
- npm install [email protected]
- 'npm install https://github.com/ioBroker/ioBroker.js-controller/tarball/master --production'
test_script:
- echo %cd%
- node --version
- npm --version
- npm test
- 'npm run test:package'
- 'npm run test:unit'
- 'npm run test:integration'
build: 'off'
83 changes: 0 additions & 83 deletions lib/utils.js

This file was deleted.

2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';

const request = require('request-promise');
const utils = require(__dirname + '/lib/utils');
const utils = require('@iobroker/adapter-core');
const adapter = new utils.Adapter('etamon');
const xpath = require('xpath');
const xmldom = require('xmldom').DOMParser;
Expand Down
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@
"request": "^2.88.0",
"request-promise": "^4.2.2",
"xpath": "^0.0.27",
"xmldom": "0.1.27"
"xmldom": "0.1.27",
"@iobroker/adapter-core": "^1.0.3"
},
"devDependencies": {
"gulp": "^3.9.1",
"mocha": "^4.1.0",
"chai": "^4.1.2"
"chai": "^4.1.2",
"@iobroker/testing": "^1.1.10"
},
"main": "main.js",
"scripts": {
"test": "node node_modules/mocha/bin/mocha --exit"
"test": "npm run test:package && npm run test:unit",
"test:package": "mocha test/package --exit",
"test:unit": "mocha test/unit --exit",
"test:integration": "mocha test/integration --exit"
},
"bugs": {
"url": "https://github.com/frankhirsch/ioBroker.etamon/issues"
},
"readmeFilename": "README.md"
}
}
5 changes: 5 additions & 0 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require('path');
const { tests } = require('@iobroker/testing');

// Run integration tests - See https://github.com/ioBroker/testing for a detailed explanation and further options
tests.integration(path.join(__dirname, '..'));
Loading