NEWS
[Javascript] Midas (Aquatemp) Poolheizung
-
@oxident Ich werde mal eine andere Mailadresse probieren. Evtl. bringt es ja was.
Was ich nicht verstehe ist das der Adapter ja eigentlich gleich angebunden ist. Wenn was von der Pumpe nicht unterstützt wird wäre doch nur kein Signal da aber die Verbindung müsste doch aufgebaut werden?
-
@pietnb Ja, da hast Du eigentlich Recht. Beim Lesen der Quellen ist mir aber aufgefallen, dass jeder Hersteller scheinbar selber definiert, welche Werte unter welcher Bezeichnung übertragen werden.
Bei meinem InverPro 21 fragt das Skript den Wert von "T02" ab und weiß, dass es sich um die Temperatur am Wassereingang handelt. Bei anderen Modellen könnte dies ganz anders sein (und sogar die Bezeichnung abweichen).
Das haben die echt blöd gelöst. Ich frage mich aber, woher die App dann z. B. immer genau weiß, was sie fragen muss und wie die Antwort zu verstehen ist.
Die Lösung wird irgendwo in diesem Bereich hier stehen:
https://github.com/radical-squared/aquatemp#per-product-id -
@oxident Ich habe inzwischen einen neuen Benutzer mit "klarer" Emailadresse angelegt. Leider bisher noch keine Daten. Habe aber eine Fehlermeldung im Log:
17:36:43.119 info javascript.0 (1373) Start javascript script.js.Poolheizung 17:36:43.150 info javascript.0 (1373) script.js.Poolheizung: erstelle Objekte 17:36:43.159 info javascript.0 (1373) script.js.Poolheizung: registered 3 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions 17:36:43.312 error javascript.0 (1373) script.js.Poolheizung: TypeError: Cannot read property 'toString' of null 17:36:43.313 error javascript.0 (1373) at updateDeviceSetTemp (script.js.Poolheizung:485:36) 17:36:43.313 error javascript.0 (1373) at Object.<anonymous> (script.js.Poolheizung:576:5)
avascript.0 2023-06-26 17:57:00.282 info State value to set for "0_userdata.0.Poolheizung.state" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.246 info State value to set for "0_userdata.0.Poolheizung.silent" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.244 info State value to set for "0_userdata.0.Poolheizung.error" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.241 info State value to set for "0_userdata.0.Poolheizung.connection" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.239 warn at processImmediate (internal/timers.js:466:21) javascript.0 2023-06-26 17:57:00.239 warn at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2242:33) javascript.0 2023-06-26 17:57:00.238 warn You are assigning a string to the state "0_userdata.0.Poolheizung.state" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions. javascript.0 2023-06-26 17:57:00.235 warn at processImmediate (internal/timers.js:466:21) javascript.0 2023-06-26 17:57:00.235 warn at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2242:33) javascript.0 2023-06-26 17:57:00.234 warn You are assigning a string to the state "0_userdata.0.Poolheizung.silent" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions. javascript.0 2023-06-26 17:57:00.214 warn at processImmediate (internal/timers.js:466:21) javascript.0 2023-06-26 17:57:00.214 warn at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2242:33) javascript.0 2023-06-26 17:57:00.213 warn You are assigning a string to the state "0_userdata.0.Poolheizung.error" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions. javascript.0 2023-06-26 17:57:00.208 warn at processImmediate (internal/timers.js:466:21) javascript.0 2023-06-26 17:57:00.208 warn at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:2242:33) javascript.0 2023-06-26 17:57:00.207 warn You are assigning a string to the state "0_userdata.0.Poolheizung.connection" which expects a boolean. Please fix your code to use a boolean or change the state type to string. This warning might become an error in future versions. javascript.0 2023-06-26 17:57:00.169 info State value to set for "0_userdata.0.Poolheizung.state" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.168 info State value to set for "0_userdata.0.Poolheizung.silent" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.164 info State value to set for "0_userdata.0.Poolheizung.error" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.160 info State value to set for "0_userdata.0.Poolheizung.connection" has to be type "boolean" but received type "string" javascript.0 2023-06-26 17:57:00.157 warn Read-only state "0_userdata.0.Poolheizung.rawJSON" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.120 error at processImmediate (internal/timers.js:464:21) javascript.0 2023-06-26 17:57:00.120 error at Immediate.<anonymous> (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5708:41) javascript.0 2023-06-26 17:57:00.120 error at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:596:29) javascript.0 2023-06-26 17:57:00.119 error at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1214:38) javascript.0 2023-06-26 17:57:00.119 error at Object.<anonymous> (script.js.Poolheizung:577:5) javascript.0 2023-06-26 17:57:00.118 error at updateDeviceSetTemp (script.js.Poolheizung:486:36) javascript.0 2023-06-26 17:57:00.117 error script.js.Poolheizung: TypeError: Cannot read property 'toString' of null javascript.0 2023-06-26 17:57:00.106 warn Read-only state "0_userdata.0.Poolheizung.coilTemp" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.082 warn Read-only state "0_userdata.0.Poolheizung.suctionTemp" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.081 warn Read-only state "0_userdata.0.Poolheizung.tempOut" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.080 warn Read-only state "0_userdata.0.Poolheizung.tempIn" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.079 warn Read-only state "0_userdata.0.Poolheizung.errorLevel" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.078 warn Read-only state "0_userdata.0.Poolheizung.ambient" has been written without ack-flag with value "null" javascript.0 2023-06-26 17:57:00.022 info script.js.Poolheizung: ungülter Zustand! javascript.0 2023-06-26 17:57:00.022 warn at processTimers (internal/timers.js:500:7) javascript.0 2023-06-26 17:57:00.022 warn at listOnTimeout (internal/timers.js:557:17) javascript.0 2023-06-26 17:57:00.022 warn at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7) javascript.0 2023-06-26 17:57:00.022 warn at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28 javascript.0 2023-06-26 17:57:00.022 warn at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15) javascript.0 2023-06-26 17:57:00.021 warn at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1565:34) javascript.0 2023-06-26 17:57:00.021 warn at Object.<anonymous> (script.js.Poolheizung:554:35) javascript.0 2023-06-26 17:57:00.020 warn getState "0_userdata.0.Poolheizung.silent" not found (3) javascript.0 2023-06-26 17:57:00.020 warn at processTimers (internal/timers.js:500:7) javascript.0 2023-06-26 17:57:00.020 warn at listOnTimeout (internal/timers.js:557:17) javascript.0 2023-06-26 17:57:00.019 warn at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7) javascript.0 2023-06-26 17:57:00.019 warn at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28 javascript.0 2023-06-26 17:57:00.019 warn at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15) javascript.0 2023-06-26 17:57:00.019 warn at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1565:34) javascript.0 2023-06-26 17:57:00.019 warn at Object.<anonymous> (script.js.Poolheizung:553:9) javascript.0 2023-06-26 17:57:00.018 warn getState "0_userdata.0.Poolheizung.silent" not found (3) javascript.0 2023-06-26 17:57:00.017 info script.js.Poolheizung: ungülter Zustand! javascript.0 2023-06-26 17:57:00.017 warn at processTimers (internal/timers.js:500:7) javascript.0 2023-06-26 17:57:00.017 warn at listOnTimeout (internal/timers.js:557:17) javascript.0 2023-06-26 17:57:00.016 warn at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7) javascript.0 2023-06-26 17:57:00.016 warn at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28 javascript.0 2023-06-26 17:57:00.016 warn at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15) javascript.0 2023-06-26 17:57:00.016 warn at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1565:34) javascript.0 2023-06-26 17:57:00.016 warn at Object.<anonymous> (script.js.Poolheizung:551:35) javascript.0 2023-06-26 17:57:00.014 warn getState "0_userdata.0.Poolheizung.mode" not found (3) javascript.0 2023-06-26 17:57:00.014 warn at processTimers (internal/timers.js:500:7) javascript.0 2023-06-26 17:57:00.014 warn at listOnTimeout (internal/timers.js:557:17) javascript.0 2023-06-26 17:57:00.014 warn at Timeout._onTimeout (/opt/iobroker/node_modules/node-schedule/lib/Invocation.js:228:7) javascript.0 2023-06-26 17:57:00.014 warn at /opt/iobroker/node_modules/node-schedule/lib/Invocation.js:268:28 javascript.0 2023-06-26 17:57:00.014 warn at Job.invoke (/opt/iobroker/node_modules/node-schedule/lib/Job.js:171:15) javascript.0 2023-06-26 17:57:00.013 warn at Job.job (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1565:34) javascript.0 2023-06-26 17:57:00.013 warn at Object.<anonymous> (script.js.Poolheizung:550:9) javascript.0 2023-06-26 17:57:00.011 warn getState "0_userdata.0.Poolheizung.mode" not found (3) javascript.0 2023-06-26 17:56:59.922 info script.js.Poolheizung: registered 3 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions javascript.0 2023-06-26 17:56:59.913 info script.js.Poolheizung: erstelle Objekte javascript.0 2023-06-26 17:56:59.896 info Start javascript script.js.Poolheizung
Kannst du damit etwas anfangen?
-
@pietnb Ich verstehe nicht, warum er bei Dir den DP "Poolheizung.mode" nicht findet. Den sollte er eigentlich anlegen (bei "erstelle Objekte").
Mich beschleicht ein wenig das Gefühl, dass bei der Objekterstellung eventuell etwas nicht geklappt hat. Hast Du schonmal versucht, den ganzen Baum "0_userdata.0.Poolheizung" zu löschen und das Skript nochmal zu starten.
-
@oxident Habe den ganzen Raum schon mehrfach komplett neu erstellt. Eben gerade habe ich den Code von @znyde mal versucht. Da kommt auf jeden fall eine andere Fehlermeldung:
21:42:30.129 warn javascript.0 (1373) script.js.Poolheizung: Login-Fehler in updateToken(): [object Object] 21:42:31.685 info javascript.0 (1373) Stop script script.js.Poolheizung 21:42:31.696 info javascript.0 (1373) Start javascript script.js.Poolheizung 21:42:31.708 info javascript.0 (1373) script.js.Poolheizung: erstelle Objekte 21:42:31.710 info javascript.0 (1373) script.js.Poolheizung: Token Neuanforderung 21:42:31.721 info javascript.0 (1373) script.js.Poolheizung: registered 3 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions 21:42:31.862 info javascript.0 (1373) script.js.Poolheizung: null 21:42:31.862 info javascript.0 (1373) script.js.Poolheizung: {"statusCode":200,"body":{"error_code":"-1","error_msg":"Error username or password","error_msg_code":"","is_reuslt_suc":false},"headers":{"date":"Mon, 26 Jun 2023 19:42:31 GMT","content-type":"application/json;charset=UTF-8","transfer-encoding":"chunked","connection":"close","set-cookie":["JSESSIONID=64B4E7902212B3E3E71863E387CF8679; Path=/cloudservice; HttpOnly"]},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"cloud.linked-go.com","port":443,"hostname":"cloud.linked-go.com","hash":null,"search":null,"query":null,"pathname":"/cloudservice/api/app/user/login.json","path":"/cloudservice/api/app/user/login.json","href":"https://cloud.linked-go.com/cloudservice/api/app/user/login.json"},"method":"POST","headers":{"accept":"application/json","content-type":"application/json","content-length":71}}} 21:42:31.863 warn javascript.0 (1373) script.js.Poolheizung: Login-Fehler in updateToken(): [object Object] 21:43:00.004 info javascript.0 (1373) script.js.Poolheizung: Token Neuanforderung 21:43:00.103 info javascript.0 (1373) script.js.Poolheizung: null 21:43:00.104 info javascript.0 (1373) script.js.Poolheizung: {"statusCode":200,"body":{"error_code":"-1","error_msg":"Error username or password","error_msg_code":"","is_reuslt_suc":false},"headers":{"date":"Mon, 26 Jun 2023 19:43:00 GMT","content-type":"application/json;charset=UTF-8","transfer-encoding":"chunked","connection":"close","set-cookie":["JSESSIONID=05095B09FE1F60ED5DF5C496F5D09A98; Path=/cloudservice; HttpOnly"]},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"cloud.linked-go.com","port":443,"hostname":"cloud.linked-go.com","hash":null,"search":null,"query":null,"pathname":"/cloudservice/api/app/user/login.json","path":"/cloudservice/api/app/user/login.json","href":"https://cloud.linked-go.com/cloudservice/api/app/user/login.json"},"method":"POST","headers":{"accept":"application/json","content-type":"application/json","content-length":71}}} 21:43:00.105 warn javascript.0 (1373) script.js.Poolheizung: Login-Fehler in updateToken(): [object Object] 21:43:30.022 info javascript.0 (1373) script.js.Poolheizung: Token Neuanforderung 21:43:30.263 info javascript.0 (1373) script.js.Poolheizung: null 21:43:30.264 info javascript.0 (1373) script.js.Poolheizung: {"statusCode":200,"body":{"error_code":"-1","error_msg":"Error username or password","error_msg_code":"","is_reuslt_suc":false},"headers":{"date":"Mon, 26 Jun 2023 19:43:30 GMT","content-type":"application/json;charset=UTF-8","transfer-encoding":"chunked","connection":"close","set-cookie":["JSESSIONID=EFFFDCBA8843D7355F60A256C1D9B5E9; Path=/cloudservice; HttpOnly"]},"request":{"uri":{"protocol":"https:","slashes":true,"auth":null,"host":"cloud.linked-go.com","port":443,"hostname":"cloud.linked-go.com","hash":null,"search":null,"query":null,"pathname":"/cloudservice/api/app/user/login.json","path":"/cloudservice/api/app/user/login.json","href":"https://cloud.linked-go.com/cloudservice/api/app/user/login.json"},"method":"POST","headers":{"accept":"application/json","content-type":"application/json","content-length":71}}} 21:43:30.264 warn javascript.0 (1373) script.js.Poolheizung: Login-Fehler in updateToken(): [object Object]
Evtl. bringt das ja etwas ich ins dunkel. Wenn ich das richtig lese hat er Probleme mit dem Login? Passwort und User stimmen aber.
Dort steht ja bei product_ids nur eine, deshalb habe ich da meine eingegeben.
-
-
@oxident Kannst du bitte mal den ursprünglichen Code von dir nochmal posten? Würde dann Stück für Stück die Änderungen nochmal durchgehen. Nicht das sich bei den Änderungen doch was reingeschlichen hat?
So schnell möchte ich nicht aufgeben
-
@pietnb Mein Code ist noch unverändert im ersten Post, also ganz oben.
Dein Problem ist im allerersten Schritt, also bei updateToken(). Das ist quasi der Login. Wenn der nicht klappt, dann hört das Skript sofort auf.
Wesentlich wäre jetzt, dass einer von Euch den Login von der App mitschneiden kann. Dann wissen wir, was los ist.
-
@oxident Hab ich gemacht und dir im Chat mal zugesand. Mal sehen ob wir damit weiterkommen
-
@radi71 Vielen Dank Wenn nötig würde ich meine Zugangsdaten auch noch zu Verfügung stellen. Die ID habe ich schon aus der App ausgelesen.
-
Wir wissen jetzt mit Sicherheit, dass bei neuen Accounts das Kennwort nicht mehr als Klartext gespeichert wird.
Jetzt müssen wir nur noch herausfinden, wie das umgewandelt wird...
-
@oxident Super, das erklärt den Fehler beim anmelden. Die Frage ist nur, wie das Passwort umgeschlüsselt werden muss damit es durch den Dienst erkannt werden kann? Gibt es dafür Standards oder kann man das aus der App auslesen? Beim installieren der App gabt es einen Verificationscode den man eingeben musste. Die Mailadresse war goheating@cloud.go-heating.com. Könnte das der Schlüssel sein?
-
Also das Homeassistant-Plugin scheint in Kürze ein Update zu bekommen. Da werden wir spicken können.
Ich bin mit den Daten von @radi71 schon sehr weit gekommen und konnte sehen, dass wir einen Großteil des Codes weiterhin nutzen können.
Dauert aber leider noch... sorry!
-
@oxident ist MD5 verschlüsselt
-
@radi71 Hab mein Passwort mal in MD5 verschlüsselt und ins Script eingetragen aber so leicht funktioniert dann doch nicht
-
@pietnb nein da haben sich auch noch Pfade geändert, URL ist anders und vermutlich auch die eine oder andere Variable
-
@radi71 said in [Javascript] Midas (Aquatemp) Poolheizung:
@pietnb nein da haben sich auch noch Pfade geändert, URL ist anders und vermutlich auch die eine oder andere Variable
Korrekt. Auch die Parameter sind ein wenig verändert worden. Unterstriche weggelassen und so Kleinigkeiten.
Wir werden das schaffen...
-
Okay. MD5 passt und die neuen Parameter sind jetzt auch bekannt.
Wir werden das Skript wohl in Zukunft dreigleisig machen müssen:
- AquaTemp alt (<= v.1.5.8)
- AquaTemp neu
- HiTemp
Der Nutzer muss dann angeben, mit welcher App er sich registriert hat.
Ist eine Menge Arbeit
-
Jetzt hat es mich doch ein wenig in den Fingern gejuckt und ich habe mal etwas versucht. Es wäre toll, wenn speziell die User mit neueren Registrierungen (@PietNB @radi71) mal probieren könnten.
Wichtig ist, dass man nun neben den Benutzerdaten auch den APILevel angeben muss. Hier sollten die neuen User bitte unbedingt eine 3 eintragen. Die Bestandsuser müssen bei 1 bleiben.
// Midas Poolheizung // v0.0.8b // Changelog: // 0.0.8: Testweise Unterstützung von neu registrierten Anlagen // 0.0.7: Kleinigkeiten überarbeitet // weitere Modelle hinzugefügt // 0.0.6: Gültigkeitsprüfung des Zertifikats deaktiviert (Dank an znyde) // Kompatibilität mit Promo Next Modellen durch generische Product-ID (Dank an znyde) // 0.0.5: weitere Abfragewerte hinzugefügt (Kompressor- und Ansaugtemperatur) // 0.0.4: Tokenverfall jetzt 60min nach Skriptstart und nicht zu jeder vollen Stunde (Dank an dering) // 0.0.3: Datenpunkte beim Start automatisch anlegen (Dank an Andy200877) // 0.0.2: Token bei jedem Set-Vorgang prüfen und ggf. neu anfordern (Dank an dering) // ANFANG konfigurierbare Elemente ----- const username = "EMAIL"; var password = "KENNWORT"; const interval = 30; // Abfrageintervall in Sekunden const dpRoot = "0_userdata.0.Poolheizung"; // Stammordner der Datenpunkte var apilevel = 1; // 1: AquaTemp-Accounts, die vor v.1.5.8 erstellt wurden // 2: HiTemp-Accounts // 3: AquaTemp-Accounts, die mit neueren App-Versionen erstellt wurden // ENDE -------------------------------- var cloudURL; var token = ""; var tokenRefreshTimer; var device = ""; var reachable = false; function setupEndpoints() { if(apilevel==1) { cloudURL = "https://cloud.linked-go.com/cloudservice/api"; } else if(apilevel==2) { cloudURL = "https://cloud.linked-go.com/cloudservice/api"; } else if(apilevel==3) { cloudURL = "https://cloud.linked-go.com:449/crmservice/api"; password = require('crypto').createHash('md5').update(password).digest("hex"); } } function clearValues() { saveValue("error", true, "boolean"); saveValue("consumption", 0, "number"); saveValue("state", false, "boolean"); } function saveValue(key, value, sType) { var dp = dpRoot + "." + key; if ( !existsState(dp )) { createState(dp,value,{name: key, type: 'number', role: 'value'}, function () {}); } else { setState(dp,value,true); } } function findCodeVal(result, code) { //log(code); for(var i=0; i<result.length; i++) { //log(result[i].code); if(result[i].code.indexOf(code) >= 0) { return result[i].value; } } return ""; } function createobjects() { log ("erstelle Objekte"); createState(dpRoot + '.ambient', {read: true, write: false, type: "number", unit:"°C", role: "value.temperature", name: "Umgebungstemperatur"}); createState(dpRoot + '.connection', {read: true, write: false, type: "boolean", role: "state", name: "Verbindung", def: false}); createState(dpRoot + '.consumption', {read: true, write: false, type: "number", unit:"W", role: "value.power", name: "Stromverbrauch", def: 0}); createState(dpRoot + '.error', {read: true, write: false, type: "boolean", role: "state", name: "Fehler", def: false}); createState(dpRoot + '.errorCode', {read: true, write: false, type: "string", name: "Fehlercode", def: ""}); createState(dpRoot + '.errorLevel', {read: true, write: false, type: "number", name: "Fehlerlevel"}); createState(dpRoot + '.errorMessage', {read: true, write: false, type: "string", name: "Fehlermeldung", def: ""}); createState(dpRoot + '.mode', {read: true, write: true, type: "string", states: "-1:off;0:cool;1:heat;2:auto", name: "Modus", def: ""}); createState(dpRoot + '.rotor', {read: true, write: false, type: "number", unit:"rpm", def: 0, name: "Lüfterdrehzahl"}); createState(dpRoot + '.silent', {read: true, write: true, type: "boolean", role: "state", name: "Silent", def: false}); createState(dpRoot + '.state', {read: true, write: false, type: "boolean", role: "state", name: "Status", def: false}); createState(dpRoot + '.tempIn', {read: true, write: false, type: "number", unit:"°C", role: "value.temperature", name: "Eingangstemperatur"}); createState(dpRoot + '.tempOut', {read: true, write: false, type: "number", unit:"°C", role: "value.temperature", name: "Ausgangstemperatur"}); createState(dpRoot + '.tempSet', {read: true, write: true, type: "number", unit:"°C", role: "level.temperature", name: "Solltemperatur"}); createState(dpRoot + '.suctionTemp', {read: true, write: false, type: "number", unit:"°C", name: "Luftansaugtemperatur"}); createState(dpRoot + '.coilTemp', {read: true, write: false, type: "number", unit:"°C", role: "value.temperature", name: "Kompressortemperatur"}); createState(dpRoot + '.rawJSON', {read: true, write: false, type: "array", name: "komplette Rückgabe"}); } function updateToken() { if(token=="") { //log("Token Neuanforderung"); var request = require('request'); var options; if(apilevel<3) { options = { url: cloudURL + '/app/user/login.json', method: 'POST', json: { "user_name": username, "password": password, "type": "2" }, rejectUnauthorized: false }; } else { options = { url: cloudURL + '/app/user/login', method: 'POST', json: { "userName": username, "password": password, "type": "2" }, rejectUnauthorized: false }; } //log(JSON.stringify(options)); request(options,function (error, response, body){ //log(JSON.stringify(response)); if(parseInt(body.error_code)==0) { if(apilevel<3) { token = body.object_result["x-token"]; } else { token = body.objectResult["x-token"]; } //log("Login ok! Token " + token); updateDeviceID(); } else { // Login-Fehler //log("Login-Fehler in updateToken(): " + response.body, "error"); token = ""; saveValue("connection", false, "boolean"); } }); } else { updateDeviceID(); } } function updateDeviceID() { if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/deviceList.json', headers: { "x-token": token }, body: {"product_ids": [ "1132174963097280512", "1186904563333062656", "1158905952238313472", "1245226668902080512", "1442284873216843776", "1548963836789501952", ]}, method: 'POST', json: true, rejectUnauthorized: false }; } else { optionsDev = { url: cloudURL + '/app/device/deviceList', headers: { "x-token": token }, body: {"productIds": [ "1132174963097280512", "1186904563333062656", "1158905952238313472", "1245226668902080512", "1442284873216843776", "1548963836789501952", ]}, method: 'POST', json: true, rejectUnauthorized: false }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { //token = body.object_result["x-token"]; //log("Login ok! Token " + token); if(apilevel<3) { device = body.object_result[0].device_code; reachable = (body.object_result[0].device_status=="ONLINE"); } else { device = body.objectResult[0].deviceCode; reachable = (body.objectResult[0].deviceStatus=="ONLINE"); } if(reachable) { saveValue("connection", true, "boolean"); if(device!="") updateDeviceStatus(device); } else { // offline device = ""; saveValue("connection", false, "boolean"); } } else { // Login-Fehler //log("Fehler in updateDeviceID(): " + response.body, "error"); token = ""; device = ""; reachable = false; saveValue("connection", false, "boolean"); } }); } } function updateDeviceStatus(devicecode) { if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/getDeviceStatus.json', headers: { "x-token": token }, json: { "device_code": devicecode }, method: 'POST', rejectUnauthorized: false }; } else { optionsDev = { url: cloudURL + '/app/device/getDeviceStatus', headers: { "x-token": token }, json: { "deviceCode": devicecode }, method: 'POST', rejectUnauthorized: false }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { if(apilevel<3) { if(body.object_result["is_fault"]==true) { // TODO: Fehlerbeschreibung abrufen //clearValues(); saveValue("error", true, "boolean"); updateDeviceDetails(devicecode); updateDeviceErrorMsg(devicecode); } else { // kein Fehler saveValue("error", false, "boolean"); saveValue("errorMessage", "", "string"); saveValue("errorCode", "", "string"); saveValue("errorLevel", 0, "number"); updateDeviceDetails(devicecode); } } else { if(body.objectResult["is_fault"]==true) { // TODO: Fehlerbeschreibung abrufen //clearValues(); saveValue("error", true, "boolean"); updateDeviceDetails(devicecode); updateDeviceErrorMsg(devicecode); } else { // kein Fehler saveValue("error", false, "boolean"); saveValue("errorMessage", "", "string"); saveValue("errorCode", "", "string"); saveValue("errorLevel", 0, "number"); updateDeviceDetails(devicecode); } } //token = body.object_result["x-token"]; //log("Login ok! Token " + token); } else { // Login-Fehler //log("Fehler in updateDeviceStatus(): " + response.body, "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); } }); } } function updateDeviceErrorMsg(devicecode) { if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/getFaultDataByDeviceCode.json', headers: { "x-token": token }, json: { "device_code": devicecode }, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } else { optionsDev = { url: cloudURL + '/app/device/getFaultDataByDeviceCode', headers: { "x-token": token }, json: { "deviceCode": devicecode }, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { saveValue("error", true, "boolean"); if(apilevel<3) { saveValue("errorMessage", body.object_result[0].description, "string"); saveValue("errorCode", body.object_result[0].fault_code, "string"); saveValue("errorLevel", body.object_result[0].error_level, "string"); } else { saveValue("errorMessage", body.objectResult[0].description, "string"); saveValue("errorCode", body.objectResult[0].fault_code, "string"); saveValue("errorLevel", body.objectResult[0].error_level, "string"); } } else { // Login-Fehler //log("Fehler in updateDeviceErrorMsg(): " + response.body, "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); } }); } } function updateDeviceDetails(devicecode) { if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/getDataByCode.json', headers: { "x-token": token }, json: { "device_code": devicecode, "protocal_codes":["Power","Mode","Manual-mute","T01","T02","2074","2075","2076","2077","H03","Set_Temp","R08","R09","R10","R11","R01","R02","R03","T03","1158","1159","F17","H02","T04","T05","T07","T14","T17"] }, // "protocal_codes":["Power","Mode","Manual-mute","T01","T02","2074","2075","2076","2077","H03","Set_Temp","R08","R09","R10","R11","R01","R02","R03","T03","1158","1159","F17","H02","T04","T05"] method: 'POST', rejectUnauthorized: false }; } else { optionsDev = { url: cloudURL + '/app/device/getDataByCode', headers: { "x-token": token }, json: { "deviceCode": devicecode, "protocalCodes":["Power","Mode","Manual-mute","T01","T02","2074","2075","2076","2077","H03","Set_Temp","R08","R09","R10","R11","R01","R02","R03","T03","1158","1159","F17","H02","T04","T05","T07","T14","T17"] }, // "protocal_codes":["Power","Mode","Manual-mute","T01","T02","2074","2075","2076","2077","H03","Set_Temp","R08","R09","R10","R11","R01","R02","R03","T03","1158","1159","F17","H02","T04","T05"] method: 'POST', rejectUnauthorized: false }; } var request = require('request'); request(optionsDev,function (error, response, body){ if(parseInt(body.error_code)==0) { if(apilevel<3) { saveValue("rawJSON", body.object_result, "string"); if(findCodeVal(body.object_result, "Power")=="1") { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.object_result, "T07")) * parseFloat(findCodeVal(body.object_result, "T14")), "number"); // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.object_result, "T17")), "number"); // Luftansaug-Temperatur T01 saveValue("suctionTemp", parseFloat(findCodeVal(body.object_result, "T01")), "number"); // Inlet-Temperatur T02 saveValue("tempIn", parseFloat(findCodeVal(body.object_result, "T02")), "number"); // outlet-Temperatur T03 saveValue("tempOut", parseFloat(findCodeVal(body.object_result, "T03")), "number"); // Coil-Temperatur T04 saveValue("coilTemp", parseFloat(findCodeVal(body.object_result, "T04")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "Set_Temp")), "number"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.object_result, "T05")), "number"); // Flüstermodus Manual-mute if(findCodeVal(body.object_result, "Manual-mute")=="1") { saveValue("silent", true, "boolean"); } else { saveValue("silent", false, "boolean"); } // Zustand Power if(findCodeVal(body.object_result, "Power")=="1") { saveValue("state", true, "boolean"); saveValue("mode", findCodeVal(body.object_result,"Mode"), "string"); } else { saveValue("state", false, "boolean"); saveValue("mode", "-1", "string"); } saveValue("connection", true, "boolean"); // Durchlauf ENDE //log(findCodeVal(body.object_result, "T07")); } else { saveValue("rawJSON", body.objectResult, "string"); if(findCodeVal(body.objectResult, "Power")=="1") { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.objectResult, "T07")) * parseFloat(findCodeVal(body.objectResult, "T14")), "number"); // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.objectResult, "T17")), "number"); // Luftansaug-Temperatur T01 saveValue("suctionTemp", parseFloat(findCodeVal(body.objectResult, "T01")), "number"); // Inlet-Temperatur T02 saveValue("tempIn", parseFloat(findCodeVal(body.objectResult, "T02")), "number"); // outlet-Temperatur T03 saveValue("tempOut", parseFloat(findCodeVal(body.objectResult, "T03")), "number"); // Coil-Temperatur T04 saveValue("coilTemp", parseFloat(findCodeVal(body.objectResult, "T04")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "Set_Temp")), "number"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.objectResult, "T05")), "number"); // Flüstermodus Manual-mute if(findCodeVal(body.objectResult, "Manual-mute")=="1") { saveValue("silent", true, "boolean"); } else { saveValue("silent", false, "boolean"); } // Zustand Power if(findCodeVal(body.objectResult, "Power")=="1") { saveValue("state", true, "boolean"); saveValue("mode", findCodeVal(body.objectResult,"Mode"), "string"); } else { saveValue("state", false, "boolean"); saveValue("mode", "-1", "string"); } saveValue("connection", true, "boolean"); // Durchlauf ENDE //log(findCodeVal(body.object_result, "T07")); } } else { // Login-Fehler //log("Fehler in updateDeviceDetails(): " + response.body, "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); } }); } } function updateDevicePower(devicecode, power) { var powerOpt; var powerMode = 2; if(power==-1) { // aus powerOpt = 0; powerMode = -1; } else if(power==0) { // an und kühlen powerOpt = 1; powerMode = 0; } else if(power==1) { // an und heizen powerOpt = 1; powerMode = 1; } else if(power==2) { // an und auto powerOpt = 1; powerMode = 2; } else { log("ungülter Zustand!"); return; } if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/control.json', headers: { "x-token": token }, json: {"param":[{ "device_code": devicecode, "protocol_code": "Power","value": powerOpt }]}, method: 'POST', rejectUnauthorized: false }; } else { optionsDev = { url: cloudURL + '/app/device/control', headers: { "x-token": token }, json: {"param":[{ "deviceCode": devicecode, "protocolCode": "Power","value": powerOpt }]}, method: 'POST', rejectUnauthorized: false }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(devicecode); //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { saveValue("mode", power, "string"); if(power>=0) updateDeviceMode(device, power); } else { log("Zustandsänderung fehlgeschlagen!", "error"); } }); } } function updateDeviceMode(devicecode, mode) { if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/control.json', headers: { "x-token": token }, json: {"param":[{ "device_code": devicecode, "protocol_code": "mode","value": mode }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } else { optionsDev = { url: cloudURL + '/app/device/control', headers: { "x-token": token }, json: {"param":[{ "deviceCode": devicecode, "protocolCode": "mode","value": mode }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(devicecode); //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { saveValue("mode", mode, "string"); } else { log("Zustandsänderung fehlgeschlagen!", "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); } }); } } function updateDeviceSilent(devicecode, silent) { var silentMode; if(silent) { silentMode = "1"; } else { silentMode = "0"; } if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/control.json', headers: { "x-token": token }, json: {"param":[{ "device_code": devicecode, "protocol_code": "Manual-mute","value": silentMode }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } else { optionsDev = { url: cloudURL + '/app/device/control', headers: { "x-token": token }, json: {"param":[{ "deviceCode": devicecode, "protocolCode": "Manual-mute","value": silentMode }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(devicecode); //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { saveValue("silent", silent, "boolean"); } else { log("Zustandsänderung fehlgeschlagen!", "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); } }); } } function updateDeviceSetTemp(devicecode, temperature) { var sTemperature = temperature.toString().replace(",", "."); var sMode = getState(dpRoot + ".mode").val; if(sMode=="-1") { //log("Gerät einschalten um Temperatur zu ändern!", 'warn'); return; } else if(sMode=="0") { sMode = "R01"; // Kühlen } else if(sMode=="1") { sMode = "R02"; // Heizen } else if(sMode=="2") { sMode = "R03"; // Auto } if(token!="") { var optionsDev; if(apilevel<3) { optionsDev = { url: cloudURL + '/app/device/control.json', headers: { "x-token": token }, json: {"param":[{ "device_code": devicecode, "protocol_code": "R01","value": sTemperature },{ "device_code": devicecode, "protocol_code": "R02","value": sTemperature },{ "device_code": devicecode, "protocol_code": "R03","value": sTemperature },{ "device_code": devicecode, "protocol_code": "Set_Temp","value": sTemperature }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } else { optionsDev = { url: cloudURL + '/app/device/control', headers: { "x-token": token }, json: {"param":[{ "deviceCode": devicecode, "protocolCode": "R01","value": sTemperature },{ "deviceCode": devicecode, "protocolCode": "R02","value": sTemperature },{ "deviceCode": devicecode, "protocolCode": "R03","value": sTemperature },{ "deviceCode": devicecode, "protocolCode": "Set_Temp","value": sTemperature }]}, method: 'POST', rejectUnauthorized: false //headers: {"content-type": "application/json"}, //charset: 'utf8', //json: true }; } var request = require('request'); request(optionsDev,function (error, response, body){ //log(devicecode); //log(JSON.stringify(response)); //log(JSON.stringify(body.object_result)); if(parseInt(body.error_code)==0) { saveValue("tempSet", temperature, "number"); } else { log("Zustandsänderung fehlgeschlagen!", "error"); token = ""; device = ""; saveValue("connection", false, "boolean"); //log(JSON.stringify(response)); } }); } } // Beginn des Skripts setupEndpoints(); createobjects(); // DPs anlegen updateToken(); // Zugriffstoken erfragen und aktuelle Werte lesen schedule('*/' + interval + ' * * * * *', function () { // regelmäßig Token und Zustand abfragen updateToken(); // gewünschte Änderungen ausführen if(!getState(dpRoot + ".mode").ack) { updateDevicePower(device, getState(dpRoot + ".mode").val); } if(!getState(dpRoot + ".silent").ack) { updateDevicePower(device, getState(dpRoot + ".silent").val); } }); tokenRefreshTimer = setInterval(function () { // Token verfällt nach 60min token = ""; //log("Token nach Intervall verworfen.") updateToken(); }, 3600000); on({id: dpRoot + ".mode", change: "ne", ack: false}, function (obj) { updateToken(); updateDevicePower(device, getState(dpRoot + ".mode").val); }); on({id: dpRoot + ".silent", change: "ne", ack: false}, function (obj) { updateToken(); updateDeviceSilent(device, getState(dpRoot + ".silent").val); }); on({id: dpRoot + ".tempSet", change: "ne", ack: false}, function (obj) { updateToken(); updateDeviceSetTemp(device, getState(dpRoot + ".tempSet").val); });
-
@oxident Prima das es dir keine Ruhe gelassen hat .
Gute Nachrichten. Ein erster Test zeigt das jetzt schonmal die Verbindung steht. Jetzt muss ich noch ein paar Parameter anpassen die bei meiner Pumpe anders sind. Der Parameter "Mode" wird schonmal aktualisiert von "off" auf "heat". Den Rest probiere ich heute Abend bestimmt noch aus. Ein paar Fehlermeldungen stehen auch noch an.
javascript.0 2023-06-28 19:34:05.796 error at processImmediate (internal/timers.js:464:21) javascript.0 2023-06-28 19:34:05.796 error at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5708:41) javascript.0 2023-06-28 19:34:05.796 error at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:596:29) javascript.0 2023-06-28 19:34:05.796 error at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1214:38) javascript.0 2023-06-28 19:34:05.796 error at Object.<anonymous> (script.js.Poolheizung:825:5) javascript.0 2023-06-28 19:34:05.795 error at updateDeviceSetTemp (script.js.Poolheizung:716:36) javascript.0 2023-06-28 19:34:05.793 error Error in callback: TypeError: Cannot read property 'toString' of null javascript.0 2023-06-28 19:34:05.755 warn Read-only state "0_userdata.0.Poolheizung.rawJSON" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.755 warn Read-only state "0_userdata.0.Poolheizung.coilTemp" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.754 warn Read-only state "0_userdata.0.Poolheizung.suctionTemp" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.750 warn Read-only state "0_userdata.0.Poolheizung.tempOut" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.742 warn Read-only state "0_userdata.0.Poolheizung.tempIn" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.740 warn Read-only state "0_userdata.0.Poolheizung.errorLevel" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.725 warn Read-only state "0_userdata.0.Poolheizung.ambient" has been written without ack-flag with value "null" javascript.0 2023-06-28 19:34:05.575 info script.js.Poolheizung: registered 3 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions javascript.0 2023-06-28 19:34:05.541 info script.js.Poolheizung: erstelle Objekte javascript.0 2023-06-28 19:34:05.514 info Start javascript script.js.Poolheizung javascript.0 2023-06-28 19:34:02.824 info Stop script script.js.Poolheizung
Mir ist aufgefallen das die App jetzt bei Anmeldung jetzt die Meldung "Token ist abgelaufen" meldet. Um die App zu nutzen muss ich mich neu anmelden. Wenn die App dann auf ist kommt immer sporadisch eine Einblendung "IOT irgendwas...?
Danke nochmal..