NEWS
[Javascript] Midas (Aquatemp) Poolheizung
-
@michael-roling Jepp, hatte ich vorhin gemacht, aber ich glaube, das war zwischen zwei Commits
Checke ich später nochmal.Danke auch für die Einladung.
-
@oxident gerne. Lass uns aber vorher sprechen bevor du etwas anpassen möchtest. Damit wir uns nicht gegenseitig überschreiben.
-
@michael-roling Na klar
-
@sunnylaila Habe zwar noch keine Lösung, aber schreibe hier mal als "Referenz", dass der Fehler
Fehler in updateDeviceID(): {"error_msg":"请重新登录","error_msg_code":"","isReusltSuc":false,"objectResult":null,"error_code":"-100"}
auf eine Doppelnutzung des Accounts (z. B. gleichzeitig mit der Aquatemp-App) hindeutet.
Ich weiß, bei Dir ist der Fehler anders, daher können wir den Grund schonmal ausschließen
-
@oxident
habe jetzt den Adapter nochmal neu installiert jetzt habe ich eine andere Fehlermeldung
siehe Log2024-07-14 17:23:52.912 error undefined is not a valid state value midas-aquatemp.0 2024-07-14 17:23:52.911 error Error: undefined is not a valid state value at Object.maybeCallbackWithError (/opt/iobroker/node_modules/@iobroker/js-controller-common/build/lib/common/maybeCallback.js:35:17) at MidasAquatemp._setState (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/adapter.js:5446:49) at MidasAquatemp.setState (/opt/iobroker/node_modules/@iobroker/js-controller-adapter/build/lib/adapter/adapter.js:5406:21) at saveValue (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/src/lib/saveValue.js:28:11) at updateDeviceID (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/src/lib/updateDeviceId.js:50:35) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async updateToken (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/src/lib/token.js:49:13) at async MidasAquatemp.onReady (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/src/main.js:73:9) midas-aquatemp.0 2024-07-14 17:23:52.908 error unhandled promise rejection: undefined is not a valid state value midas-aquatemp.0 2024-07-14 17:23:52.908 error Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). midas-aquatemp.0 2024-07-14 17:23:52.850 info Login ok! Token: HSYRiZJgddla9xnG/vGhRRFYWLCFWkUH+KG+rEGMYlOXimAxZlSOzN9zhxis/UxiXPFacEkw0HogOrNnmbsXTw== midas-aquatemp.0 2024-07-14 17:23:52.408 info Request token
zusätzlich stürzt der Adapter ab
wie gesagt in der app läuft es.
grüße und danke für eure Mühen -
@oxident Läuft es bei dir denn jetzt? Die Pipeline läuft jetzt auch wieder sauber durch
-
Bitte noch mal von Github installieren und dann den Adapter auf debug log setzen, wie im Bild zusehen. Wenn dann noch Fehler auftauchen hier posten
-
@michael-roling
habe es jetzt neu installiert und auch auf debug gestellt der Adapter wird jetzt nicht mehr vom iobroker alleine geschlossen geht aber auf Punkt drei nicht auf grün und im log habe ich wieder diesen updatedevice Fehler2024-07-15 20:12:12.860 info Login ok! Token: 8mP9bo+x3spcde95ANtvYCt/rtf1U4NljAiSRLoq98O46DBPdGq/qftOjflw6AGXXPFacEkw0HogOrNnmbsXTw== midas-aquatemp.0 2024-07-15 20:12:12.655 info Request token midas-aquatemp.0 2024-07-15 20:11:12.652 error Error in updateDeviceID(): "TypeError: Cannot read properties of undefined (reading 'deviceCode')\n at updateDeviceID (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/lib/updateDeviceId.js:66:206)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async updateToken (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/lib/token.js:75:7)\n at async MidasAquatemp.onReady (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/main.js:76:5)" midas-aquatemp.0 2024-07-15 20:11:12.650 error Error in updateDeviceID(): {}
dieser wiederholt sich alle 60 Sekunden.
mit dem Adapter auf debug stellen kann ich da irgendwo etwas auslesen um es dir zur verfügung zu stellen? -
@sunnylaila ja das ist aber schon mal ein fortschritt. Ich gucke mir das log später in Ruhe an.
-
@sunnylaila Ich habe noch mal wieder ein paar Änderungen vor genommen, wir müssen einfach mal testen. Was für eine Wärmepumpe hast du denn eigentlich? Anscheinend bekommt die Anfrage kein device zurück.
-
ich habe eine Poolsana Promo Next 5 Wärmepumpe mit dem Wlan Modul von Poolsana..
Habe es jetzt auch nochmal neu installiert und hier der neue Log
2024-07-16 07:43:36.428 error Response: {"sessionid":null,"error_code":"0","error_msg":"Success","error_msg_code":"","totalSize":null,"totalPage":null,"nextPage":null,"objectResult":[],"isReusltSuc":true} midas-aquatemp.0 2024-07-16 07:43:36.427 error Error in updateDeviceID(): No device code found midas-aquatemp.0 2024-07-16 07:43:36.359 info Login ok! Token: 5CqvwvNH0tQ85m8hk0DATZHOTOEsF1K/kDQSTpKjxWRFYbVNJboSqmZwqSFBt3sbXPFacEkw0HogOrNnmbsXTw== midas-aquatemp.0 2024-07-16 07:43:35.921 info Request token midas-aquatemp.0 2024-07-16 07:43:35.919 info Objects created midas-aquatemp.0 2024-07-16 07:43:35.916 info Create object: midas-aquatemp.0.rawJSON midas-aquatemp.0 2024-07-16 07:43:35.913 info Create object: midas-aquatemp.0.DeviceCode midas-aquatemp.0 2024-07-16 07:43:35.911 info Create object: midas-aquatemp.0.ProductCode midas-aquatemp.0 2024-07-16 07:43:35.908 info Create object: midas-aquatemp.0.exhaust midas-aquatemp.0 2024-07-16 07:43:35.905 info Create object: midas-aquatemp.0.coilTemp midas-aquatemp.0 2024-07-16 07:43:35.903 info Create object: midas-aquatemp.0.suctionTemp midas-aquatemp.0 2024-07-16 07:43:35.900 info Create object: midas-aquatemp.0.tempSet midas-aquatemp.0 2024-07-16 07:43:35.897 info Create object: midas-aquatemp.0.tempOut midas-aquatemp.0 2024-07-16 07:43:35.894 info Create object: midas-aquatemp.0.tempIn midas-aquatemp.0 2024-07-16 07:43:35.891 info Create object: midas-aquatemp.0.state midas-aquatemp.0 2024-07-16 07:43:35.888 info Create object: midas-aquatemp.0.silent midas-aquatemp.0 2024-07-16 07:43:35.885 info Create object: midas-aquatemp.0.rotor midas-aquatemp.0 2024-07-16 07:43:35.882 info Create object: midas-aquatemp.0.mode midas-aquatemp.0 2024-07-16 07:43:35.879 info Create object: midas-aquatemp.0.errorMessage midas-aquatemp.0 2024-07-16 07:43:35.876 info Create object: midas-aquatemp.0.errorLevel midas-aquatemp.0 2024-07-16 07:43:35.873 info Create object: midas-aquatemp.0.errorCode midas-aquatemp.0 2024-07-16 07:43:35.868 info Create object: midas-aquatemp.0.error midas-aquatemp.0 2024-07-16 07:43:35.859 info Create object: midas-aquatemp.0.consumption midas-aquatemp.0 2024-07-16 07:43:35.851 info Create object: midas-aquatemp.0.info.connection midas-aquatemp.0 2024-07-16 07:43:35.814 info Create object: midas-aquatemp.0.ambient midas-aquatemp.0 2024-07-16 07:43:35.777 info starting. Version 0.0.1 (non-npm: MiRo1310/ioBroker.midas-aquatemp#1eafbd195d1db6ca646dbdda7f8dced23b9ab2fd) in /opt/iobroker/node_modules/iobroker.midas-aquatemp, node: v20.15.1, js-controller: 5.0.19 midas-aquatemp.0 2024-07-16 07:43:30.008 info terminating midas-aquatemp.0 2024-07-16 07:43:29.507 info Terminated (ADAPTER_REQUESTED_TERMINATION): Without reason midas-aquatemp.0 2024-07-16 07:43:29.505 info terminating midas-aquatemp.0 2024-07-16 07:43:29.503 info Got terminate signal TERMINATE_YOURSELF midas-aquatemp.0 2024-07-16 07:43:09.289 error Error in getToken(): {"message":"","name":"AggregateError","stack":"AggregateError\n at AxiosError.from (/opt/iobroker/node_modules/iobroker.midas-aquatemp/node_modules/axios/dist/node/axios.cjs:841:14)\n at RedirectableRequest.handleRequestError (/opt/iobroker/node_modules/iobroker.midas-aquatemp/node_modules/axios/dist/node/axios.cjs:3106:25)\n at RedirectableRequest.emit (node:events:519:28)\n at eventHandlers.<computed> (/opt/iobroker/node_modules/follow-redirects/index.js:38:24)\n at ClientRequest.emit (node:events:519:28)\n at Socket.socketErrorListener (node:_http_client:500:9)\n at Socket.emit (node:events:519:28)\n at emitErrorNT (node:internal/streams/destroy:169:8)\n at emitErrorCloseNT (node:internal/streams/destroy:128:3)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)\n at Axios.request (/opt/iobroker/node_modules/iobroker.midas-aquatemp/node_modules/axios/dist/node/axios.cjs:4224:41)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async getToken (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/lib/token.js:48:24)\n at async updateToken (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/lib/token.js:73:5)\n at async MidasAquatemp.onReady (/opt/iobroker/node_modules/iobroker.midas-aquatemp/build/main.js:76:5)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"adapter":["xhr","http","fetch"],"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"env":{},"headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/json","User-Agent":"axios/1.7.2","Content-Length":"72","Accept-Encoding":"gzip, compress, deflate, br"},"method":"post","url":"/app/user/login","data":"{\"userName\":\"\",\"password\":\"d41d8cd98f00b204e9800998ecf8427e\",\"type\":\"2\"}"},"code":"ECONNREFUSED","status":null} midas-aquatemp.0 2024-07-16 07:43:09.207 info Request token
Leider geht es noch nicht
-
@sunnylaila Es ist so das der Adapter das Device nicht erkennt. Das was im log kommt sind von mir die erwarteten Logs. Jetzt müssen wir als nächstes schauen warum das Gerät nicht erkannt wird. Evtl hat @oxident da eine Idee zu. Ich bin aber dran
-
@michael-roling
ich hatte ganz am Anfang auch Probleme mit dem Javascript da hat der User znyde
der die gleiche Pumpe hat wie ich eine Änderung im Javascript gepostet mit der es dann
auch bei mir ging.
Ich glaube es war Post 77 oder 78Vielleicht hilft es dir ja bei der Fehlersuche.
Ich bin leider nur User und kenne mich damit null aus.Danke dir
-
@sunnylaila wenn du Zeit hast kannst du ja mal den Post raus suchen.
-
@znyde said in [Javascript] Midas (Aquatemp) Poolheizung:
@sunnylaila
hiermit ignorierst du die SSL Zertifkats meldung
Copy to Clipboard function updateToken() { if(token=="") { log("Token Neuanforderung"); var request = require('request'); var options = { url: cloudURL + '/app/user/login.json', method: 'POST', json: { "user_name": username, "password": password, "type": "2" }, rejectUnauthorized: false }; request(options,function (error, response, body){ console.log(error); console.log(JSON.stringify(response)); if(parseInt(body.error_code)==0) { token = body.object_result["x-token"]; log("Login ok! Token " + token); updateDeviceID(); } else { // Login-Fehler log("Login-Fehler in updateToken(): " + response.body, "warn"); token = ""; } }); } else { updateDeviceID(); } }einmal der Post
-
@znyde said in [Javascript] Midas (Aquatemp) Poolheizung:
Bei mir ist das Modul an eine Promo Next 5 angeschlossen, das Mapping mit den Temperaturen habe ich geändert... übrigens kannst Du das in deiner App abfragen Burgermenü oben rechts -> Parametereinstellungen -> Kennwort: 022 (so war es bei mir)
// Midas Poolheizung // v0.0.5 // Changelog: // 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) const username = "xxx@xxxx.com"; const password = "xxxxxx"; const interval = 30; const cloudURL = "https://cloud.linked-go.com/cloudservice/api"; const dpRoot = "0_userdata.0.Poolheizung"; var token = ""; var tokenRefreshTimer; var device = ""; var reachable = false; 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", 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", 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 + '.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", name: "Eingangstemperatur"}); createState(dpRoot + '.tempOut', {read: true, write: false, type: "number", unit:"°C", name: "Ausgangstemperatur"}); createState(dpRoot + '.tempSet', {read: true, write: true, type: "number", unit:"°C", 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", 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 = { url: cloudURL + '/app/user/login.json', method: 'POST', json: { "user_name": username, "password": password, "type": "2" }, rejectUnauthorized: false }; request(options,function (error, response, body){ console.log(error); console.log(JSON.stringify(response)); if(parseInt(body.error_code)==0) { token = body.object_result["x-token"]; log("Login ok! Token " + token); updateDeviceID(); } else { // Login-Fehler log("Login-Fehler in updateToken(): " + response.body, "warn"); token = ""; } }); } else { updateDeviceID(); } } function updateDeviceID() { if(token!="") { var optionsDev = { url: cloudURL + '/app/device/deviceList.json', headers: { "x-token": token}, body: {product_ids: ["1442284873216843776"]}, method: 'POST', json: true, rejectUnauthorized: false }; var request = require('request'); request(optionsDev,function (error, response, body1){ // console.log(parseInt(body1.error_code)); // console.log(JSON.stringify(response)); // log(JSON.stringify(body1.object_result)); if(parseInt(body1.error_code)==0) { //token = body.object_result["x-token"]; log("Login ok! Token " + token); device = body1.object_result[0].device_code; // device=1; console.log(device); reachable = (body1.object_result[0].device_status=="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); token = ""; device = ""; reachable = false; saveValue("connection", false, "boolean"); } }); } } function updateDeviceStatus(devicecode) { if(token!="") { var optionsDev = { url: cloudURL + '/app/device/getDeviceStatus.json', headers: { "x-token": token }, json: { "device_code": 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(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); } //token = body.object_result["x-token"]; //log("Login ok! Token " + token); } else { // Login-Fehler log("Fehler in updateDeviceStatus(): " + response.body); token = ""; device = ""; } }); } } function updateDeviceErrorMsg(devicecode) { if(token!="") { var 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 }; 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"); 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 { // Login-Fehler log("Fehler in updateDeviceErrorMsg(): " + response.body); token = ""; device = ""; } }); } } function updateDeviceDetails(devicecode) { if(token!="") { var optionsDev = { url: cloudURL + '/app/device/getDataByCode.json', headers: { "x-token": token }, // json: { "device_code": devicecode }, // R02=Heatin-Set Point,T2=inlet Water Temp, T3=Outlet Water Temp,T5=Ambient-Temp, json: { "device_code": devicecode, "protocal_codes":["R02","T1","T2","T3","T5","P01","P02","Power","Mode"] }, // 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 }; var request = require('request'); request(optionsDev,function (error, response, body){ console.log("update detail" + JSON.stringify(response)); if(parseInt(body.error_code)==0) { 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, "T1")), "number"); // Inlet-Temperatur T02 saveValue("tempIn", parseFloat(findCodeVal(body.object_result, "T2")), "number"); // outlet-Temperatur T03 saveValue("tempOut", parseFloat(findCodeVal(body.object_result, "T3")), "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, "T5")), "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"); } //log(findCodeVal(body.object_result, "T07")); } else { // Login-Fehler log("Fehler in updateDeviceDetails(): " + response.body); token = ""; device = ""; } }); } } 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 = { url: cloudURL + '/app/device/control.json', headers: { "x-token": token }, json: {"param":[{ "device_code": devicecode, "protocol_code": "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!"); } }); } } function updateDeviceMode(devicecode, mode) { if(token!="") { var 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 }; 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!"); } }); } } function updateDeviceSilent(devicecode, silent) { var silentMode; if(silent) { silentMode = "1"; } else { silentMode = "0"; } if(token!="") { var 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 }; 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!"); } }); } } 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 = { 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 }; 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!"); log(JSON.stringify(response)); } }); } } // Beginn des Skripts 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(async function () { // Token verfällt nach 60min token = ""; //log("Token nach Intervall verworfen.") updateToken(); }, 3600000); on({id: dpRoot + ".mode", change: "ne", ack: false}, async function (obj) { updateToken(); updateDevicePower(device, getState(dpRoot + ".mode").val); }); on({id: dpRoot + ".silent", change: "ne", ack: false}, async function (obj) { updateToken(); updateDeviceSilent(device, getState(dpRoot + ".silent").val); }); on({id: dpRoot + ".tempSet", change: "ne", ack: false}, async function (obj) { updateToken(); updateDeviceSetTemp(device, getState(dpRoot + ".tempSet").val); });
und einmal hier das komplette Javascript
was dann funktioniert hat -
@sunnylaila Ich habe das jetzt für 2 Funktionen eingebaut, wahrscheinlich muss das für alle anderen Funktionen auch noch implementiert werden. Wenn das dann alles funktioniert wird man dieses speziell im Adapter unchecken müssen das man die ssl zertifikat meldungen ignorieren möchte, was ein Sicherheitsrisiko ist. Aber erstmal testen ob es wie gesagt jetzt anders wird.
-
habe es gerade neu installiert aber leider noch kein erfolg siehe log
midas-aquatemp.0 2024-07-17 18:38:47.258 error Response: {"sessionid":null,"error_code":"0","error_msg":"Success","error_msg_code":"","totalSize":null,"totalPage":null,"nextPage":null,"objectResult":[],"isReusltSuc":true} midas-aquatemp.0 2024-07-17 18:38:47.258 error Error in updateDeviceID(): No device code found midas-aquatemp.0 2024-07-17 18:38:47.092 info Login ok! Token: TVhfM4yFTdnqTRMIchl7Rt+ILOZsLixeSOXBNvoowdNppxVNabU6Mj1mYkyWloTMXPFacEkw0HogOrNnmbsXTw== midas-aquatemp.0 2024-07-17 18:38:46.550 info Request token midas-aquatemp.0 2024-07-17 18:38:46.546 info Objects created midas-aquatemp.0 2024-07-17 18:38:46.539 info Create object: midas-aquatemp.0.rawJSON midas-aquatemp.0 2024-07-17 18:38:46.521 info Create object: midas-aquatemp.0.DeviceCode midas-aquatemp.0 2024-07-17 18:38:46.514 info Create object: midas-aquatemp.0.ProductCode midas-aquatemp.0 2024-07-17 18:38:46.506 info Create object: midas-aquatemp.0.exhaust midas-aquatemp.0 2024-07-17 18:38:46.501 info Create object: midas-aquatemp.0.coilTemp midas-aquatemp.0 2024-07-17 18:38:46.497 info Create object: midas-aquatemp.0.suctionTemp midas-aquatemp.0 2024-07-17 18:38:46.493 info Create object: midas-aquatemp.0.tempSet midas-aquatemp.0 2024-07-17 18:38:46.488 info Create object: midas-aquatemp.0.tempOut midas-aquatemp.0 2024-07-17 18:38:46.483 info Create object: midas-aquatemp.0.tempIn midas-aquatemp.0 2024-07-17 18:38:46.478 info Create object: midas-aquatemp.0.state midas-aquatemp.0 2024-07-17 18:38:46.473 info Create object: midas-aquatemp.0.silent midas-aquatemp.0 2024-07-17 18:38:46.468 info Create object: midas-aquatemp.0.rotor midas-aquatemp.0 2024-07-17 18:38:46.463 info Create object: midas-aquatemp.0.mode midas-aquatemp.0 2024-07-17 18:38:46.459 info Create object: midas-aquatemp.0.errorMessage midas-aquatemp.0 2024-07-17 18:38:46.454 info Create object: midas-aquatemp.0.errorLevel midas-aquatemp.0 2024-07-17 18:38:46.447 info Create object: midas-aquatemp.0.errorCode midas-aquatemp.0 2024-07-17 18:38:46.438 info Create object: midas-aquatemp.0.error midas-aquatemp.0 2024-07-17 18:38:46.423 info Create object: midas-aquatemp.0.consumption midas-aquatemp.0 2024-07-17 18:38:46.415 info Create object: midas-aquatemp.0.info.connection midas-aquatemp.0 2024-07-17 18:38:46.358 info Create object: midas-aquatemp.0.ambient midas-aquatemp.0 2024-07-17 18:38:46.312 info starting. Version 0.0.1 (non-npm: MiRo1310/ioBroker.midas-aquatemp#fe2980f6c63f14269805862155e182f5f2bed22b) in /opt/iobroker/node_modules/iobroker.midas-aquatemp, node: v20.15.1, js-controller: 5.0.19
-
@sunnylaila sorry. Ich muss dann noch mal schauen.
-
@sunnylaila Das ist echt tricky ... hat aber mit den SSL-Sachen nix zu tun. Ich schaue parallel auch nochmal!