@KLVN said in [Gelöst] Helios KWL - Zugriff auf xml:
console.log(xml);
Die Dateien werden im Entwicklertool aktualisiert.
In der LOG steht jetzt:
javascript.0 2020-12-22 20:55:25.301 error (21624) Request error: Error: socket hang up
javascript.0 2020-12-22 20:55:25.301 error (21624) Error in request callback: TypeError: Cannot read property 'matchAll' of undefined
javascript.0 2020-12-22 20:55:25.300 info (21624) script.js.helios2: undefined
Ich hatte ein älteres Script vorher benutzt welches aber nur die Werte ausgelesen hat. Dieses hat alle Werte ständig aktualisiert:
var position_anfang, result, position_ende;
var request= require('request');
var Hlogin = {headers: {
'Host': '192.168.1.39',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0',
'Accept': '*/*',
'Accept-Language': 'de,en-US;q=0.7,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Referer': 'http://192.168.1.39/',
'Content-Type': 'text/plain;charset=UTF-8',
'Content-Length': '15',
'DNT': '1',
'Connection': 'keep-alive',
},
url: 'http://192.168.1.39/info.htm',
body: 'v00402=!helios!', /*Passwort*/
method: 'POST',};
var Hwerte8 = {headers: {
'Host': '192.168.1.39',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0',
'Accept': '*/*',
'Accept-Language': 'de,en-US;q=0.7,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Referer': 'http://192.168.1.39/anzeig.htm',
'Content-Type': 'text/plain;charset=UTF-8',
'Content-Length': '20',
'DNT': '1',
'Connection': 'keep-alive'
},
url: 'http://192.168.1.39/data/werte8.xml',
body: 'xml=/data/werte8.xml',
method: 'POST'};
//Datenpunkte erzeugen
createState("HeliosKWL.Aussentemperatur");
createState("HeliosKWL.Zulufttemperatur");
createState("HeliosKWL.Ablufttemperatur");
createState("HeliosKWL.Fortlufttemperatur");
createState("HeliosKWL.Lüfterstufe");
createState("HeliosKWL.Betriebsart");
//createState("HeliosKWL.Bypass");
//Login alle 5 Min
setInterval(function() {
request(Hlogin);
}, 300000);
//Datenabfrage alle 5 Sek
setInterval(function() {
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00104') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 3;
setState('HeliosKWL.Aussentemperatur', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00105') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 3;
setState('HeliosKWL.Zulufttemperatur', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00107') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 3;
setState('HeliosKWL.Ablufttemperatur', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00106') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 3;
setState('HeliosKWL.Fortlufttemperatur', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00102') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 0;
setState('HeliosKWL.Lüfterstufe', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
request(Hwerte8, function (error, response, result) {
position_anfang = result.indexOf('v00101') + 1;
position_anfang = (typeof position_anfang == 'number' ? position_anfang : 0) + 16;
position_ende = position_anfang;
position_ende = (typeof position_ende == 'number' ? position_ende : 0) + 0;
setState('HeliosKWL.Betriebsart', (result.slice((position_anfang - 1), position_ende)), true, parseInt(0, 10), false);
});
}, 5000);