diff --git a/web/display/minimal/index.php b/web/display/minimal/index.php index fbd54a75f..5cce40a73 100644 --- a/web/display/minimal/index.php +++ b/web/display/minimal/index.php @@ -45,6 +45,13 @@ list($key, $value) = explode("=", $line, 2); ${$key."old"} = trim( $value, " '\t\n\r\0\x0B" ); // remove all garbage and single quotes } + if ($lastmanagementold == "1") { + // filter local connections + $valid_evsecon = ["modbusevse", "daemon", "ipevse", "dac"]; + if (!in_array($evsecons1old, $valid_evsecon)) { + $lastmanagementold = "0"; + } + } ?> @@ -190,7 +197,7 @@ function checkTime(i) { // functions for processing messages 'display/minimal/processAllMqttMsg.js?ver=20230204', // functions performing mqtt and start mqtt-service - 'display/minimal/setupMqttServices.js?ver=20221229', + 'display/minimal/setupMqttServices.js?ver=20230818', ]; scriptsToLoad.forEach(function(src) { diff --git a/web/display/minimal/setupMqttServices.js b/web/display/minimal/setupMqttServices.js index e4d674f87..395e9b247 100644 --- a/web/display/minimal/setupMqttServices.js +++ b/web/display/minimal/setupMqttServices.js @@ -17,14 +17,19 @@ var topicsToSubscribe = [ ["openWB/lp/1/boolPlugStat", 1], ["openWB/lp/1/boolChargeStat", 1], ["openWB/lp/1/ChargePointEnabled", 1], - ["openWB/lp/2/W", 1], - ["openWB/lp/2/%Soc", 1], - ["openWB/lp/2/boolSocConfigured"], - ["openWB/lp/2/boolPlugStat", 1], - ["openWB/lp/2/ChargePointEnabled", 1], - ["openWB/lp/2/boolChargeStat", 1], ]; +if (lastmanagementold == 1) { + topicsToSubscribe.push( + ["openWB/lp/2/W", 1], + ["openWB/lp/2/%Soc", 1], + ["openWB/lp/2/boolSocConfigured"], + ["openWB/lp/2/boolPlugStat", 1], + ["openWB/lp/2/ChargePointEnabled", 1], + ["openWB/lp/2/boolChargeStat", 1], + ); +} + // holds number of topics flagged 1 initially var countTopicsNotForPreloader = topicsToSubscribe.filter(row => row[1] === 1).length; diff --git a/web/status/processAllMqttMsg.js b/web/status/processAllMqttMsg.js index 24db13ad9..43d434687 100644 --- a/web/status/processAllMqttMsg.js +++ b/web/status/processAllMqttMsg.js @@ -25,7 +25,7 @@ function getIndex(topic) { // since this is supposed to be the index like in openwb/lp/4/w // no lookbehind supported by safari, so workaround with replace needed var index = topic.match(/(?:\/)([0-9]+)(?=\/)/g)[0].replace(/[^0-9]+/g, ''); - if ( typeof index === 'undefined' ) { + if (typeof index === 'undefined') { index = ''; } return index; @@ -34,35 +34,35 @@ function getIndex(topic) { function handlevar(mqttmsg, mqttpayload) { // receives all messages and calls respective function to process them processPreloader(mqttmsg); - if ( mqttmsg.match( /^openwb\/lp\//i) ) { + if (mqttmsg.match(/^openwb\/lp\//i)) { processLpMsg(mqttmsg, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/evu\//i) ) { + else if (mqttmsg.match(/^openwb\/evu\//i)) { processEvuMsg(mqttmsg, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/pv\//i) ) { + else if (mqttmsg.match(/^openwb\/pv\//i)) { processPvMsg(mqttmsg, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/Verbraucher\//i) ) { + else if (mqttmsg.match(/^openwb\/Verbraucher\//i)) { processVerbraucherMsg(mqttmsg, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/housebattery\//i) ) { + else if (mqttmsg.match(/^openwb\/housebattery\//i)) { processBatMsg(mqttmsg, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/SmartHome\//i) ) { + else if (mqttmsg.match(/^openwb\/SmartHome\//i)) { processSmartHomeMsg(mqttmsg, mqttpayload); } - - else if ( mqttmsg.match( /^openwb\/global\//i) ) { + + else if (mqttmsg.match(/^openwb\/global\//i)) { processGlobalMsg(mqttmsg, mqttpayload); } else { - console.log("Unknown topic: "+mqttmsg+": "+mqttpayload); + console.log("Unknown topic: " + mqttmsg + ": " + mqttpayload); } } // end handlevar -function processGlobalMsg (mqttmsg, mqttpayload) { - switch(mqttmsg){ +function processGlobalMsg(mqttmsg, mqttpayload) { + switch (mqttmsg) { case "openWB/global/WAllChargePoints": directShow(mqttpayload, '#ladeleistungAll'); break; @@ -74,8 +74,8 @@ function processGlobalMsg (mqttmsg, mqttpayload) { } } -function processEvuMsg (mqttmsg, mqttpayload) { - switch(mqttmsg){ +function processEvuMsg(mqttmsg, mqttpayload) { + switch (mqttmsg) { case "openWB/evu/ASchieflast": directShow(mqttpayload, '#schieflastdiv'); break; @@ -136,16 +136,13 @@ function processEvuMsg (mqttmsg, mqttpayload) { } } -function processPvMsg (mqttmsg, mqttpayload) { - if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/.*$/i) ) - { +function processPvMsg(mqttmsg, mqttpayload) { + if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/.*$/i)) { var index = getIndex(mqttmsg); // extract number between two / / - if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/W$/i) ) - { + if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/W$/i)) { absShow(mqttpayload, '#inverter' + index + ' .powerInverter'); } - else if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/WhCounter$/i) ) - { + else if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/WhCounter$/i)) { kShow(mqttpayload, '#inverter' + index + ' .yieldInverter'); } // no data in openWB 1.x @@ -161,21 +158,18 @@ function processPvMsg (mqttmsg, mqttpayload) { // { // fractionDigitsShow(mqttpayload, '#inverter' + index + ' .yYieldInverter'); // } - else if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/faultState$/i) ) - { + else if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/faultState$/i)) { setWarningLevel(mqttpayload, '#inverter' + index + ' .faultStrPvRow'); } - else if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/faultStr$/i) ) - { + else if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/faultStr$/i)) { textShow(formatJsonString(mqttpayload), '#inverter' + index + ' .faultStrPv'); } - else if ( mqttmsg.match(/^openWB\/pv\/[0-9]+\/boolPVConfigured$/i) ) - { + else if (mqttmsg.match(/^openWB\/pv\/[0-9]+\/boolPVConfigured$/i)) { visibilityCard('#inverter' + index, mqttpayload); } } else { - switch(mqttmsg){ + switch (mqttmsg) { case "openWB/pv/CounterTillStartPvCharging": directShow(mqttpayload, '#pvcounterdiv'); break; @@ -190,16 +184,26 @@ function processPvMsg (mqttmsg, mqttpayload) { break; case "openWB/pv/MonthlyYieldKwh": fractionDigitsShow(mqttpayload, '#monthly_pvkwhdiv'); + if (mqttpayload != "0") { + showSection("#monatsertragRow"); + } else { + hideSection("#monatsertragRow"); + } break; case "openWB/pv/YearlyYieldKwh": fractionDigitsShow(mqttpayload, '#yearly_pvkwhdiv'); + if (mqttpayload != "0") { + showSection("#jahresertragRow"); + } else { + hideSection("#jahresertragRow"); + } break; } } } -function processBatMsg (mqttmsg, mqttpayload) { - switch(mqttmsg){ +function processBatMsg(mqttmsg, mqttpayload) { + switch (mqttmsg) { case "openWB/housebattery/boolHouseBatteryConfigured": visibilityCard('#speicher', mqttpayload); break; @@ -227,8 +231,8 @@ function processBatMsg (mqttmsg, mqttpayload) { } } -function processSmartHomeMsg (mqttmsg, mqttpayload) { - switch(mqttmsg){ +function processSmartHomeMsg(mqttmsg, mqttpayload) { + switch (mqttmsg) { case "openWB/SmartHome/Status/maxspeicherladung": directShow(mqttpayload, '#wmaxspeicherladung'); break; @@ -247,74 +251,74 @@ function processSmartHomeMsg (mqttmsg, mqttpayload) { } } -function processVerbraucherMsg (mqttmsg, mqttpayload) { +function processVerbraucherMsg(mqttmsg, mqttpayload) { var index = getIndex(mqttmsg); // extract number between two / / - if ( mqttmsg.match( /^openwb\/Verbraucher\/[1-2]\/Configured$/i ) ) { - visibilityCard('#loads'+index, mqttpayload); + if (mqttmsg.match(/^openwb\/Verbraucher\/[1-2]\/Configured$/i)) { + visibilityCard('#loads' + index, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/Verbraucher\/[1-2]\/Watt$/i ) ) { - directShow(mqttpayload, '#loads'+index+' .verbraucherWatt'); + else if (mqttmsg.match(/^openwb\/Verbraucher\/[1-2]\/Watt$/i)) { + directShow(mqttpayload, '#loads' + index + ' .verbraucherWatt'); } - else if ( mqttmsg.match( /^openwb\/Verbraucher\/[1-2]\/WhImported$/i ) ) { - kShow(mqttpayload, '#loads'+index+' .importVerbraucher'); + else if (mqttmsg.match(/^openwb\/Verbraucher\/[1-2]\/WhImported$/i)) { + kShow(mqttpayload, '#loads' + index + ' .importVerbraucher'); } - else if ( mqttmsg.match( /^openwb\/Verbraucher\/[1-2]\/WhExported$/i ) ) { - kShow(mqttpayload, '#loads'+index+' .exportVerbraucher'); + else if (mqttmsg.match(/^openwb\/Verbraucher\/[1-2]\/WhExported$/i)) { + kShow(mqttpayload, '#loads' + index + ' .exportVerbraucher'); } } -function processLpMsg (mqttmsg, mqttpayload) { +function processLpMsg(mqttmsg, mqttpayload) { var index = getIndex(mqttmsg); // extract number between two / / - if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/boolChargePointConfigured$/i ) ) { + if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/boolChargePointConfigured$/i)) { visibilityCard('#lp' + index, mqttpayload); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/APhase1$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/APhase1$/i)) { directShow(mqttpayload, '#lp' + index + ' .stromstaerkeP1'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/APhase2$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/APhase2$/i)) { directShow(mqttpayload, '#lp' + index + ' .stromstaerkeP2'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/APhase3$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/APhase3$/i)) { directShow(mqttpayload, '#lp' + index + ' .stromstaerkeP3'); - } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/AConfigured$/i ) ) { + } + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/AConfigured$/i)) { directShow(mqttpayload, '#lp' + index + ' .stromvorgabe'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/kWhCounter$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/kWhCounter$/i)) { fractionDigitsShow(mqttpayload, '#lp' + index + ' .kWhCounter'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/VPhase1$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/VPhase1$/i)) { directShow(mqttpayload, '#lp' + index + ' .spannungP1'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/VPhase2$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/VPhase2$/i)) { directShow(mqttpayload, '#lp' + index + ' .spannungP2'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/VPhase3$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/VPhase3$/i)) { directShow(mqttpayload, '#lp' + index + ' .spannungP3'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/W$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/W$/i)) { directShow(mqttpayload, '#lp' + index + ' .ladeleistung'); } - else if ( mqttmsg.match( /^openWB\/lp\/[1-9][0-9]*\/boolSocConfigured$/i )) { - if( mqttpayload == "1" ){ + else if (mqttmsg.match(/^openWB\/lp\/[1-9][0-9]*\/boolSocConfigured$/i)) { + if (mqttpayload == "1") { showSection('#lp' + index + ' .socRow'); } else { hideSection('#lp' + index + ' .socRow'); } } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/%Soc$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/%Soc$/i)) { directShow(mqttpayload, '#lp' + index + ' .soc'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/faultState$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/faultState$/i)) { setWarningLevel(mqttpayload, '#lp' + index + ' .faultStrLpRow'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/faultStr$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/faultStr$/i)) { textShow(formatJsonString(mqttpayload), '#lp' + index + ' .faultStrLp'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/socFaultState$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/socFaultState$/i)) { setWarningLevel(mqttpayload, '#lp' + index + ' .faultStrSocLpRow'); } - else if ( mqttmsg.match( /^openwb\/lp\/[1-9][0-9]*\/socFaultStr$/i ) ) { + else if (mqttmsg.match(/^openwb\/lp\/[1-9][0-9]*\/socFaultStr$/i)) { textShow(formatJsonString(mqttpayload), '#lp' + index + ' .faultStrSocLp'); } else { @@ -339,18 +343,18 @@ function processLpMsg (mqttmsg, mqttpayload) { // don't parse value function directShow(mqttpayload, variable) { - var value = parseFloat(mqttpayload); - if ( isNaN(value) ) { - value = 0; - } - var valueStr = value.toLocaleString(undefined) ; - $(variable).text(valueStr); + var value = parseFloat(mqttpayload); + if (isNaN(value)) { + value = 0; + } + var valueStr = value.toLocaleString(undefined); + $(variable).text(valueStr); } // show missing value or zero value as -- function noZeroShow(mqttpayload, variable) { var value = parseFloat(mqttpayload); - if ( isNaN(value) || (value == 0) ) { + if (isNaN(value) || (value == 0)) { valueStr = "--"; } else { @@ -364,7 +368,7 @@ function impExpShow(mqttpayload, variable) { // zur Anzeige Wert um "Bezug"/"Einspeisung" ergänzen var value = parseInt(mqttpayload); var valueStr = Math.abs(value).toLocaleString(undefined); - if(value < 0) { + if (value < 0) { valueStr += " (Exp.)"; } else if (value > 0) { valueStr += " (Imp.)"; @@ -376,24 +380,24 @@ function impExpShow(mqttpayload, variable) { function kShow(mqttpayload, variable) { var value = parseFloat(mqttpayload); value = (value / 1000); - var valueStr = value.toLocaleString(undefined, {minimumFractionDigits: 3, maximumFractionDigits: 3}) ; + var valueStr = value.toLocaleString(undefined, { minimumFractionDigits: 3, maximumFractionDigits: 3 }); $(variable).text(valueStr); } // show absolute value (always >0) function absShow(mqttpayload, variable) { var value = Math.abs(parseInt(mqttpayload)); - var valueStr = value.toLocaleString(undefined) ; + var valueStr = value.toLocaleString(undefined); $(variable).text(valueStr); } //show kilo-payloads with 3 fraction digits function fractionDigitsShow(mqttpayload, variable) { var value = parseFloat(mqttpayload); - if ( isNaN(value) ) { + if (isNaN(value)) { value = 0; } - var valueStr = value.toLocaleString(undefined, {minimumFractionDigits: 3, maximumFractionDigits: 3}); + var valueStr = value.toLocaleString(undefined, { minimumFractionDigits: 3, maximumFractionDigits: 3 }); $(variable).text(valueStr); } @@ -423,7 +427,7 @@ function setWarningLevel(mqttpayload, variable) { //Der String ist mit einem Tausender-Punkt versehen. Daher den Payload für die if-Abfrage verwenden. function visibilityMin(row, mqttpayload) { var value = parseFloat(mqttpayload) * -1; - if (value>100) { + if (value > 100) { showSection(row); } else { @@ -432,15 +436,15 @@ function visibilityMin(row, mqttpayload) { } //show/hide row with only one value -function visibilityValue(row, variable){ +function visibilityValue(row, variable) { var value = parseFloat($(variable).text()); // zu Berücksichtigung von 0,00 - if (( value != 0) && ( $(variable).text() != "")) { + if ((value != 0) && ($(variable).text() != "")) { showSection(row); } else { hideSection(row); } - var valueStr = value.toLocaleString(undefined, {minimumFractionDigits: 3, maximumFractionDigits: 3}); + var valueStr = value.toLocaleString(undefined, { minimumFractionDigits: 3, maximumFractionDigits: 3 }); $(variable).text(valueStr); } @@ -449,9 +453,9 @@ function visibilityRow(row, var1, var2, var3) { var val1 = parseFloat($(var1).text()); // zu Berücksichtigung von 0,00 var val2 = parseFloat($(var2).text()); var val3 = parseFloat($(var3).text()); - if ( ( (val1 == 0) || ($(var1).text() == "") ) && - ( (val2 == 0) || ($(var2).text() == "") ) && - ( (val3 == 0) || ($(var3).text() == "") ) ) { + if (((val1 == 0) || ($(var1).text() == "")) && + ((val2 == 0) || ($(var2).text() == "")) && + ((val3 == 0) || ($(var3).text() == ""))) { hideSection(row); } else { @@ -470,17 +474,17 @@ function visibilityCard(card, mqttpayload) { hideSection(card); } else { showSection(card); - if ( (card.match( /^[#]lp[2-8]$/i)) && lpGesCardShown == false ) { + if ((card.match(/^[#]lp[2-8]$/i)) && lpGesCardShown == false) { showSection('#lpges'); lpGesCardShown = true; - } else if ( card.match(/^[#]inverter[1-2]+$/i) ) { - if ( card == "#inverter1" ) { + } else if (card.match(/^[#]inverter[1-2]+$/i)) { + if (card == "#inverter1") { pv1 = mqttpayload; } else { pv2 = mqttpayload; } - if ( (pv1 + pv2) > 0 ) { + if ((pv1 + pv2) > 0) { showSection('#pvGes'); } else { hideSection('#pvGes'); diff --git a/web/status/status.php b/web/status/status.php index d59b68fc8..9164b72c9 100644 --- a/web/status/status.php +++ b/web/status/status.php @@ -364,11 +364,11 @@ function llanbindunglog() {