NEWS
[Javascript] Midas (Aquatemp) Poolheizung
-
@flyer99 Das sieht beeindruckend aus!
-
@flyer99 said in [Javascript] Midas (Aquatemp) Poolheizung:
... weil die Eingangstemp. eingefroren war. Kein Problem wenn man es weiß ...
Komisch, also bei mir aktualisiert es sich auch dann. Zumindest, solange die Pumpe läuft.
Eventuell liegt es aber auch an den Einstellungen in der Heizung.
Wusstet ihr, dass es zusätzlich zum 022-Menü auch ein 066-Menü gibt? Vielleicht hat ja jemand Ahnung davon und Lust, uns da was zu zeigen.
-
@oxident Das ist keine große Kunst, die große Kunst ist DEIN Script um an die Daten zu kommen ...
Komisch, also bei mir aktualisiert es sich auch dann. Zumindest, solange die Pumpe läuft.
Das was ich meinte, wenn die Pumpe aus ist bleiben die Werte eingefroren ... -
@flyer99 said in [Javascript] Midas (Aquatemp) Poolheizung:
Das was ich meinte, wenn die Pumpe aus ist bleiben die Werte eingefroren ...
Hab mich vielleicht blöd ausgedrückt. Ich meine in diesem Fall die "Wasserpumpe", nicht die "Wärmepumpe"
Andererseits habe ich gerade mal den "ambient"-DP geprüft. Dieser hat sich bei mir brav die ganze Nacht über ständig aktualisiert. Nur "tempIn" und "tempOut" blieben halt eingefroren.
Meintest Du das?
-
@oxident Genau, ich hatte tempIn verwendet ...
-
@oxident Ich habe mal alle Variablen die in der App sind durchgeschaut. Einige Werte wie "Rotor", "Silent", "Consumtion", "TempSet"werden wohl bei der Poolsana Prime nicht unterstützt und deshalb auch nicht angezeigt.
Dafür gibt es aber z.B. den "S02-FlowSwitch", "O01-Compressor" und "R01-CoolingSet,R02-HeatingSet, R03-AutoSet". Könntest du die in dein Script mit aufnehmen. Ich habe versucht das selber zu ergänzen, bin aber leider gescheitert Dann könnte ich wenigstens sehen was die Pumpe gerade macht.
Bei mir überträgt die WP nur Daten wenn sie läuft (Pumpe ist an und WP arbeitet) oder wenn die Pumpe aus ist und die WP in E03 geht.
-
@pietnb Klar, gerne. Magst Du mal folgendes versuchen und die rawJSON posten?
// Midas Poolheizung // v0.0.10b // Changelog: // 0.0.10: Weitere Parameter für andere Gerätetypen hinzugefügt // 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 = "BENUTZER"; var password = "KENNWORT"; const interval = 30; // Abfrageintervall in Sekunden const dpRoot = "0_userdata.0.Poolheizung"; // Stammordner der Datenpunkte const 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 const debugLevel = 0; // 0: keine erweiterten Informationen protokollieren // 1: Debug-Informationen protokollieren // ENDE -------------------------------- var cloudURL; var token = ""; var tokenRefreshTimer; var device = ""; // ProductIDs: // Gruppe 1: // 1132174963097280512: Midas/Poolsana InverPro const AQUATEMP_POOLSANA="1132174963097280512"; // Gruppe 2: // 1442284873216843776: const AQUATEMP_OTHER1="1442284873216843776"; var product = ""; 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"); } printLog("API-Level " + apilevel, 1); } 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 )) { printLog("Schreibe in NEUEN Datenpunkt: " + dp + " - " + value, 1); createState(dp,value,{name: key, type: 'number', role: 'value'}, function () {}); } else { printLog("Schreibe in Datenpunkt: " + dp + " - " + value, 1); setState(dp,value,true); } } function findCodeVal(result, code) { //log(code); printLog("Suche Wert " + code, 1); for(var i=0; i<result.length; i++) { //log(result[i].code); printLog(result[i].code, 1); if(result[i].code.indexOf(code) >= 0) { printLog("Wert gefunden: " + result[i].value, 1); 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=="") { printLog("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){ printLog("Login-Antwort: " + JSON.stringify(response)); if(parseInt(body.error_code)==0) { if(apilevel<3) { token = body.object_result["x-token"]; } else { token = body.objectResult["x-token"]; } printLog("Login ok! Token " + token); updateDeviceID(); } else { // Login-Fehler printLog("Login-Fehler in updateToken(): " + response.body); 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){ printLog("DeviceList: " + 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; product = body.object_result[0].product_id; reachable = (body.object_result[0].device_status=="ONLINE"); } else { device = body.objectResult[0].deviceCode; product = body.objectResult[0].productId; reachable = (body.objectResult[0].deviceStatus=="ONLINE"); } printLog("DeviceCode: " + device + ", ProductID: " + product + ", DeviceStatus: " + reachable); 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){ printLog("DeviceStatus: " + 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) { if(product==AQUATEMP_POOLSANA) { 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"] }, method: 'POST', rejectUnauthorized: false }; } else if(product==AQUATEMP_OTHER1) { optionsDev = { url: cloudURL + '/app/device/getDataByCode.json', headers: { "x-token": token }, json: { "device_code": devicecode, "protocal_codes":[ "Power", "Mode", "Manual-mute", "O01", "T1", "T2", "T3", "T4", "T5", "2074", "2075", "2076", "2077", "H03", "Set_Temp", "R01", "R02", "R03", "R08", "R09", "R10", "R11", "R01", "R02", "R03", "S02", "T03", "1158", "1159", "F17", "H02", "T7", "T14", "T17"] }, method: 'POST', rejectUnauthorized: false }; } } else { if(product==AQUATEMP_POOLSANA) { 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"] }, method: 'POST', rejectUnauthorized: false }; } else if (product==AQUATEMP_OTHER1) { optionsDev = { url: cloudURL + '/app/device/getDataByCode', headers: { "x-token": token }, json: { "deviceCode": devicecode, "protocalCodes":[ "Power", "Mode", "Manual-mute", "O01", "T1", "T2", "T3", "T4", "T5", "2074", "2075", "2076", "2077", "H03", "Set_Temp", "R01", "R02", "R03", "R08", "R09", "R10", "R11", "R01", "R02", "R03", "S02", "T03", "1158", "1159", "F17", "H02", "T7", "T14", "T17"] }, method: 'POST', rejectUnauthorized: false }; } } var request = require('request'); request(optionsDev,function (error, response, body){ printLog("DeviceDetails: " + JSON.stringify(response)); if(parseInt(body.error_code)==0) { if(apilevel<3) { saveValue("rawJSON", body.object_result, "string"); if(findCodeVal(body.object_result, "Power")=="1") { if(product==AQUATEMP_POOLSANA) { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.object_result, "T07")) * parseFloat(findCodeVal(body.object_result, "T14")), "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"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.object_result, "T05")), "number"); } else if (product==AQUATEMP_OTHER1) { // Stromverbrauch T7 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.object_result, "T7")) * parseFloat(findCodeVal(body.object_result, "T14")), "number"); // Luftansaug-Temperatur T1 saveValue("suctionTemp", parseFloat(findCodeVal(body.object_result, "T1")), "number"); // Inlet-Temperatur T2 saveValue("tempIn", parseFloat(findCodeVal(body.object_result, "T2")), "number"); // outlet-Temperatur T3 saveValue("tempOut", parseFloat(findCodeVal(body.object_result, "T3")), "number"); // Coil-Temperatur T4 saveValue("coilTemp", parseFloat(findCodeVal(body.object_result, "T4")), "number"); // Umgebungs-Temperatur T5 saveValue("ambient", parseFloat(findCodeVal(body.object_result, "T5")), "number"); } // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.object_result, "T17")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "Set_Temp")), "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 } else { saveValue("rawJSON", body.objectResult, "string"); if(findCodeVal(body.objectResult, "Power")=="1") { if(product==AQUATEMP_POOLSANA) { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.objectResult, "T07")) * parseFloat(findCodeVal(body.objectResult, "T14")), "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"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.objectResult, "T05")), "number"); } else if (product==AQUATEMP_OTHER1) { // Stromverbrauch T7 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.objectResult, "T7")) * parseFloat(findCodeVal(body.objectResult, "T14")), "number"); // Luftansaug-Temperatur T1 saveValue("suctionTemp", parseFloat(findCodeVal(body.objectResult, "T1")), "number"); // Inlet-Temperatur T2 saveValue("tempIn", parseFloat(findCodeVal(body.objectResult, "T2")), "number"); // outlet-Temperatur T3 saveValue("tempOut", parseFloat(findCodeVal(body.objectResult, "T3")), "number"); // Coil-Temperatur T4 saveValue("coilTemp", parseFloat(findCodeVal(body.objectResult, "T4")), "number"); // Umgebungs-Temperatur T5 saveValue("ambient", parseFloat(findCodeVal(body.objectResult, "T5")), "number"); } // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.objectResult, "T17")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "Set_Temp")), "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 } } 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)); } }); } } function printLog(sMsg, minLevel = 1) { if(debugLevel>=minLevel) { log(sMsg); } } // 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); });
Wenn die Werte da dann enthalten sind, dann kann ich sie auch auf einen Datenpunkt schreiben.
Das Setzen der Zieltemperatur müsste aber bei Dir auch möglich sein. Dies geschieht ja über die Parameter R01-R03 ... genau wie bei meiner Heizung auch.Du hast natürlich Recht, wenn die Pumpe generell AUS ist, dann wird nix mehr aktualisiert.
-
@pietnb said in [Javascript] Midas (Aquatemp) Poolheizung:
Dafür gibt es aber z.B. den "S02-FlowSwitch", "O01-Compressor" und "R01-CoolingSet,R02-HeatingSet, R03-AutoSet".
Sorry, habe noch schnell mal etwas versucht und umgehe jetzt Set-Temp komplett. Damit müsste auch die Steuerung der Temperatur funktionieren. Bedenke aber, dass für die verschiedenen Modi unterschiedliche Temperaturen gespeichert werden.
Will sagen: Wenn Du jetzt im Heizmodus bist, dann verändert der tempSet-DP die Temperatur für diesen Modus. Wechselst Du zum Kühl- oder Auto-Modus, dann wird der Wert zurückgesetzt. Ich denke, Du verstehst, was ich meine
// Midas Poolheizung // v0.0.10c // Changelog: // 0.0.10: Weitere Parameter für andere Gerätetypen hinzugefügt // 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 = "NAME"; var password = "KENNWORT"; const interval = 30; // Abfrageintervall in Sekunden const dpRoot = "0_userdata.0.Poolheizung"; // Stammordner der Datenpunkte const 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 const debugLevel = 0; // 0: keine erweiterten Informationen protokollieren // 1: Debug-Informationen protokollieren // ENDE -------------------------------- var cloudURL; var token = ""; var tokenRefreshTimer; var device = ""; // ProductIDs: // Gruppe 1: // 1132174963097280512: Midas/Poolsana InverPro const AQUATEMP_POOLSANA="1132174963097280512"; // Gruppe 2: // 1442284873216843776: const AQUATEMP_OTHER1="1442284873216843776"; var product = ""; 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"); } printLog("API-Level " + apilevel, 1); } 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 )) { printLog("Schreibe in NEUEN Datenpunkt: " + dp + " - " + value, 1); createState(dp,value,{name: key, type: 'number', role: 'value'}, function () {}); } else { printLog("Schreibe in Datenpunkt: " + dp + " - " + value, 1); setState(dp,value,true); } } function findCodeVal(result, code) { //log(code); printLog("Suche Wert " + code, 1); for(var i=0; i<result.length; i++) { //log(result[i].code); printLog(result[i].code, 1); if(result[i].code.indexOf(code) >= 0) { printLog("Wert gefunden: " + result[i].value, 1); 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=="") { printLog("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){ printLog("Login-Antwort: " + JSON.stringify(response)); if(parseInt(body.error_code)==0) { if(apilevel<3) { token = body.object_result["x-token"]; } else { token = body.objectResult["x-token"]; } printLog("Login ok! Token " + token); updateDeviceID(); } else { // Login-Fehler printLog("Login-Fehler in updateToken(): " + response.body); 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){ printLog("DeviceList: " + 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; product = body.object_result[0].product_id; reachable = (body.object_result[0].device_status=="ONLINE"); } else { device = body.objectResult[0].deviceCode; product = body.objectResult[0].productId; reachable = (body.objectResult[0].deviceStatus=="ONLINE"); } printLog("DeviceCode: " + device + ", ProductID: " + product + ", DeviceStatus: " + reachable); 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){ printLog("DeviceStatus: " + 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) { if(product==AQUATEMP_POOLSANA) { 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"] }, method: 'POST', rejectUnauthorized: false }; } else if(product==AQUATEMP_OTHER1) { optionsDev = { url: cloudURL + '/app/device/getDataByCode.json', headers: { "x-token": token }, json: { "device_code": devicecode, "protocal_codes":[ "Power", "Mode", "Manual-mute", "O01", "T1", "T2", "T3", "T4", "T5", "2074", "2075", "2076", "2077", "H03", "Set_Temp", "R01", "R02", "R03", "R08", "R09", "R10", "R11", "R01", "R02", "R03", "S02", "T03", "1158", "1159", "F17", "H02", "T7", "T14", "T17"] }, method: 'POST', rejectUnauthorized: false }; } } else { if(product==AQUATEMP_POOLSANA) { 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"] }, method: 'POST', rejectUnauthorized: false }; } else if (product==AQUATEMP_OTHER1) { optionsDev = { url: cloudURL + '/app/device/getDataByCode', headers: { "x-token": token }, json: { "deviceCode": devicecode, "protocalCodes":[ "Power", "Mode", "Manual-mute", "O01", "T1", "T2", "T3", "T4", "T5", "2074", "2075", "2076", "2077", "H03", "Set_Temp", "R01", "R02", "R03", "R08", "R09", "R10", "R11", "R01", "R02", "R03", "S02", "T03", "1158", "1159", "F17", "H02", "T7", "T14", "T17"] }, method: 'POST', rejectUnauthorized: false }; } } var request = require('request'); request(optionsDev,function (error, response, body){ printLog("DeviceDetails: " + JSON.stringify(response)); if(parseInt(body.error_code)==0) { if(apilevel<3) { saveValue("rawJSON", body.object_result, "string"); if(findCodeVal(body.object_result, "Power")=="1") { if(product==AQUATEMP_POOLSANA) { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.object_result, "T07")) * parseFloat(findCodeVal(body.object_result, "T14")), "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"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.object_result, "T05")), "number"); } else if (product==AQUATEMP_OTHER1) { // Stromverbrauch T7 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.object_result, "T7")) * parseFloat(findCodeVal(body.object_result, "T14")), "number"); // Luftansaug-Temperatur T1 saveValue("suctionTemp", parseFloat(findCodeVal(body.object_result, "T1")), "number"); // Inlet-Temperatur T2 saveValue("tempIn", parseFloat(findCodeVal(body.object_result, "T2")), "number"); // outlet-Temperatur T3 saveValue("tempOut", parseFloat(findCodeVal(body.object_result, "T3")), "number"); // Coil-Temperatur T4 saveValue("coilTemp", parseFloat(findCodeVal(body.object_result, "T4")), "number"); // Umgebungs-Temperatur T5 saveValue("ambient", parseFloat(findCodeVal(body.object_result, "T5")), "number"); } // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.object_result, "T17")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp //saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "Set_Temp")), "number"); // Ziel-Temperatur anhand Modus if(findCodeVal(body.object_result,"Mode") == 1) { // Heiz-Modus (-> R02) saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "R02")), "number"); } else if(findCodeVal(body.object_result,"Mode") == 0) { // Kühl-Modus (-> R01) saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "R01")), "number"); } else if(findCodeVal(body.object_result,"Mode") == 2) { // Auto-Modus (-> R03) saveValue("tempSet", parseFloat(findCodeVal(body.object_result, "R03")), "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 } else { saveValue("rawJSON", body.objectResult, "string"); if(findCodeVal(body.objectResult, "Power")=="1") { if(product==AQUATEMP_POOLSANA) { // Stromverbrauch T07 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.objectResult, "T07")) * parseFloat(findCodeVal(body.objectResult, "T14")), "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"); // Umgebungs-Temperatur T05 saveValue("ambient", parseFloat(findCodeVal(body.objectResult, "T05")), "number"); } else if (product==AQUATEMP_OTHER1) { // Stromverbrauch T7 x T14 in Watt saveValue("consumption", parseFloat(findCodeVal(body.objectResult, "T7")) * parseFloat(findCodeVal(body.objectResult, "T14")), "number"); // Luftansaug-Temperatur T1 saveValue("suctionTemp", parseFloat(findCodeVal(body.objectResult, "T1")), "number"); // Inlet-Temperatur T2 saveValue("tempIn", parseFloat(findCodeVal(body.objectResult, "T2")), "number"); // outlet-Temperatur T3 saveValue("tempOut", parseFloat(findCodeVal(body.objectResult, "T3")), "number"); // Coil-Temperatur T4 saveValue("coilTemp", parseFloat(findCodeVal(body.objectResult, "T4")), "number"); // Umgebungs-Temperatur T5 saveValue("ambient", parseFloat(findCodeVal(body.objectResult, "T5")), "number"); } // Lüfter-Drehzahl T17 saveValue("rotor", parseInt(findCodeVal(body.objectResult, "T17")), "number"); } else { saveValue("consumption", 0, "number"); saveValue("rotor", 0, "number"); } // Ziel-Temperatur Set_Temp //saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "Set_Temp")), "number"); // Ziel-Temperatur anhand Modus if(findCodeVal(body.objectResult,"Mode") == 1) { // Heiz-Modus (-> R02) saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "R02")), "number"); } else if(findCodeVal(body.objectResult,"Mode") == 0) { // Kühl-Modus (-> R01) saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "R01")), "number"); } else if(findCodeVal(body.objectResult,"Mode") == 2) { // Auto-Modus (-> R03) saveValue("tempSet", parseFloat(findCodeVal(body.objectResult, "R03")), "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 } } 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)); } }); } } function printLog(sMsg, minLevel = 1) { if(debugLevel>=minLevel) { log(sMsg); } } // 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 Moin, vielen Dank. Funktioniert! Endlich kann ich die Temperaturen
über meine Dashboard einbinden.Hier nochmal die rawJSON
[{"value":"1","code":"Power"},{"value":"1","code":"Mode"},{"value":"0","code":"Manual-mute"},{"value":"0","code":"O01"},{"value":"17.0","code":"T1"},{"value":"24.0","code":"T2"},{"value":"26.0","code":"T3"},{"value":"9.5","code":"T4"},{"value":"24.5","code":"T5"},{"value":"0","code":"2074"},{"value":"0","code":"2075"},{"value":"0","code":"2076"},{"value":"0","code":"2077"},{"value":"0","code":"H03"},{"value":"0","code":"Set_Temp"},{"value":"25.0","code":"R01"},{"value":"25.0","code":"R02"},{"value":"25.0","code":"R03"},{"value":"8.0","code":"R08"},{"value":"35.0","code":"R09"},{"value":"15.0","code":"R10"},{"value":"40.0","code":"R11"},{"value":"25.0","code":"R01"},{"value":"25.0","code":"R02"},{"value":"25.0","code":"R03"},{"value":"0","code":"S02"},{"value":"0","code":"T03"},{"value":"0","code":"1158"},{"value":"0","code":"1159"},{"value":"114","code":"F17"},{"value":"1","code":"H02"},{"value":"0","code":"T7"},{"value":"0","code":"T14"},{"value":"0","code":"T17"}]
Leider kommt auf S02 O02 noch nichts an. Laut App werden die aber unterstützt. Egal wichtig ist das ich die Temperatur einstellen kann.
Ich werde schon eine Möglichkeit finden zu sehen ob die WP nur Status "Heat" steht oder ob sie auch heizt.
Nochmal vielen Dank.
-
@pietnb Schau doch mal unter https://github.com/radical-squared/aquatemp/blob/Custom-component/custom_components/aqua_temp/parameters/entity_description.1442284873216843776.json
Vielleicht findest du da noch Werte, die helfen könnten!
Alternativ hätte ich jetzt einfach stumpf tempIn und tempOut verglichen
-
@oxident Bin schon dabei die Github Werte durchzuschauen. Das mit der Temperaturdifferenz werde ich mal versuchen
-
@oxident Ist es möglich das ich alle Werte die mich bei Github interessieren, einfach in dem Script ergänze um dann in der rawJSON zu sehen welche Signale zurück kommen?
-
@pietnb Klar! Der Einfachheit halber solltest Du in beiden (!) Auflistungen in denen jetzt auch die T1, T2, ... enthalten sind die gewünschten Parameter hinzufügen.
Ich denke, das Prinzip erkennst Du
-
Ich glaube, der Hersteller des WLAN-Moduls hat angefangen, auch die älteren Accounts jetzt umzustellen bzw. sogar abzustellen!
Seit 14.08. bekomme ich mit apilevel=1 einen fehlerhaften Login und mit apilevel=3 eine "offline"-Warnung. In der App sieht es auch düster aus.Hat jemand ein ähnliches Verhalten?
Ansonsten würde ich jetzt mal versuchen, die Poolheizung komplett neu zu koppeln.Update: Ein Neustart der WP (stromlos setzen) hat gereicht. Aber auch ich muss jetzt den apilevel 3 verwenden.
-
@oxident Bei mir läuft noch alles wie bisher. Nochmal vielen Dank für deine Ausdauer
Leider bekomme ich aus meiner Poolsana Prime 10.0 nicht mehr Daten heraus. Die wichtigsten Funktionen sind ja gegeben. Ich kann die Temperatur auf dem Dashboard ablesen und und die WP von innen an und aus schalten. Schade ist halt nur das wenn sie aus ist, keine aktuellen Temperaturdaten mehr überträgt. Meine Familie hat sich inzwischen damit arrangiert.
Grüße Piet
-
@pietnb War das denn von Anfang an so?
Du meinst die "ambient"-Temperatur, richtig? -
Kann mir jemand sagen, ob das auch mit dieser WP funktioniert: https://verkauf-bochum.de/products/dc-inverter-pool-warmepumpe-cop-16-17kw
Soweit ich sehe wird die über die TUYA Smart Life APP gesteuert.
Danke
Gruß
-
Eine Registrierung in der App Aqua Temp funktioniert gar nicht mehr. Super.
-
@zeroqool Gute Frage, ich denke aber, dass diese WP nur mit den TUYA-Servern spricht und demnach nicht über Aqua Temp.
Aber die werben ja sogar selbst von einer Home Assistant Integration. Ich glaube, für ioBroker gibt es auch einen guten Adapter für Tuya-Geräte. Hast Du da schonmal geschaut?
-
Nein, noch nicht. Ich stehe nun vor der Frage welche WP ich kaufen soll.