diff --git a/src/plugins/zeroExport/powermeter.h b/src/plugins/zeroExport/powermeter.h index b3736648..aed861fb 100644 --- a/src/plugins/zeroExport/powermeter.h +++ b/src/plugins/zeroExport/powermeter.h @@ -103,8 +103,8 @@ class powermeter { 863.25 MHz - geht (ohne Tibber Probleme) => 3 & 4 Balken */ case zeroExportPowermeterType_t::Tibber: + if(mCfg->groups[group].pm_refresh < 3) mCfg->groups[group].pm_refresh = 3; result = getPowermeterWattsTibber(*mLog, group, &power); - mPreviousTsp += 2000; // Zusätzliche Pause break; #endif #if defined(ZEROEXPORT_POWERMETER_SHRDZM) @@ -114,15 +114,16 @@ class powermeter { #endif } - if (result) { + //if (mMqtt->isConnected()) mMqtt->publish(String("zero/state/groups/" + String(group) + "/result").c_str(), String(ret).c_str(), false); + + if (result) + { bufferWrite(power, group); // MQTT - Powermeter -// if (mCfg->debug) { - if (mMqtt->isConnected()) { - mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); - } -// } + if (mMqtt->isConnected()) { + mMqtt->publish(String("zero/state/groups/" + String(group) + "/powermeter/P").c_str(), String(ah::round1(power)).c_str(), false); + } } } } @@ -181,7 +182,7 @@ class powermeter { } /** onMqttMessage - * + * This function is needed for all mqtt connections between ahoy and other devices. */ void onMqttMessage(JsonObject obj) { String topic = String(obj["topic"]); @@ -492,20 +493,19 @@ class powermeter { {{0x01, 0x00, 0x02, 0x08, 0x00, 0xff}, &smlOBISWh, &_powerMeterExport}}; bool getPowermeterWattsTibber(JsonObject logObj, uint8_t group, float *power) { - mPreviousTsp = mPreviousTsp + 2000; // Zusätzliche Pause - bool result = false; logObj["mod"] = "getPowermeterWattsTibber"; String auth = mCfg->groups[group].pm_pass; - String url = String("http://") + mCfg->groups[group].pm_url + String("/") + String(mCfg->groups[group].pm_jsonPath); + String url = String("http://") + mCfg->groups[group].pm_src + String("/") + String(mCfg->groups[group].pm_jsonPath); setHeader(&http); http.begin(url); http.addHeader("Authorization", "Basic " + auth); - if (http.GET() == HTTP_CODE_OK && http.getSize() > 0) { + if (http.GET() == HTTP_CODE_OK && http.getSize() > 0) + { String myString = http.getString(); double readVal = 0; unsigned char c; diff --git a/src/web/html/setup.html b/src/web/html/setup.html index 506bda2e..1b0a9f07 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -1509,8 +1509,8 @@ } // add addEventListener - const selectElement = document.querySelector("#pm_type"); - selectElement.addEventListener("change", (event) => { pm_type_dropdown() }); + const se_pm_type = document.querySelector("#pm_type"); + se_pm_type.addEventListener("change", (event) => { pm_type_dropdown() }); // run event one time pm_type_dropdown(); @@ -1566,6 +1566,31 @@ } } + // add addEventListener + const se_battCfg = document.querySelector("#battCfg"); + se_battCfg.addEventListener("change", (event) => { battCfg_dropdown() }); + + // run event one time + battCfg_dropdown(); + + function battCfg_dropdown() + { + var e = document.getElementsByName("battCfg")[0]; + var value = e.options[e.selectedIndex].text; + + var divsToHide = document.getElementById("divBattery"); + + // Formular for Powermeter-DropDown + // show all DIVs and remove only what is not necessary + // 1 = pm_refresh, 2 = pm_target, 3 = pm_src, 4 = pm_jsonPath, 5 = pm_user, 6 = pm_pass + for(var i = 0; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = ''; + + if(value == "---") for(var i = 1; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = 'none'; + else if(value == "Inverter U dc") { + divsToHide.childNodes[1].style.display = 'none'; + } + } + function pm_type_dropdown() { var e = document.getElementsByName("pm_type")[0];