Skip to content

Commit

Permalink
Color theme: adapt to Smarthome2.0 changes (#1528)
Browse files Browse the repository at this point in the history
* bug fixes

* month name fix

* bug fix

* Improve battery SOC display

* Fix heading in power graph widget

* adapt colors theme to Smarthome 2.0 changes
  • Loading branch information
cshagen committed Aug 20, 2021
1 parent 1adb00f commit 0ed5edb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
16 changes: 12 additions & 4 deletions web/themes/colors/powerdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WbData {
this.chargePower = 0;
this.chargeSum = 0;
this.housePower = 0;
this.smartHomePower = 0;
this.houseEnergy = 0;
this.batteryEnergyExport = 0;
this.batteryEnergyImport = 0;
Expand Down Expand Up @@ -157,9 +158,12 @@ class WbData {
this.updateUsageSummary("charging", "energy", value)
break;
case 'houseEnergy':
console.log("Update House Energy: " + value);
this.updateUsageSummary("house", "energy", value);
break;
case 'smarthomePower':
this.updateConsumerSummary();
powerMeter.update();
break;
case 'currentPowerPrice':
chargePointList.update();
default:
Expand All @@ -175,7 +179,6 @@ class WbData {
break;
case 'pvDailyYield':
this.updateSourceSummary("pv", "energy", this.pvDailyYield);
console.log("Update PV Energy: " + value);
break;
default:
break;
Expand Down Expand Up @@ -295,8 +298,13 @@ class WbData {
}

updateConsumerSummary(cat) {
this.updateUsageSummary("devices", cat, this.shDevice.filter(dev => dev.configured).reduce((sum, consumer) => sum + consumer[cat], 0)
+ this.consumer.filter(dev => dev.configured).reduce((sum, consumer) => sum + consumer[cat], 0));
if (cat == 'energy') {
this.updateUsageSummary("devices", 'energy', this.shDevice.filter(dev => dev.configured).reduce((sum, consumer) => sum + consumer.energy, 0)
+ this.consumer.filter(dev => dev.configured).reduce((sum, consumer) => sum + consumer.energy, 0));
} else {
this.updateUsageSummary("devices", 'power', this.smarthomePower
+ this.consumer.filter(dev => dev.configured).reduce((sum, consumer) => sum + consumer.power, 0));
}
}

//update cookie
Expand Down
14 changes: 14 additions & 0 deletions web/themes/colors/processAllMqttMsg.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function handlevar(mqttmsg, mqttpayload) {
else if (mqttmsg.match(/^openwb\/hook\//i)) { processHookMessages(mqttmsg, mqttpayload); }
else if (mqttmsg.match(/^openwb\/SmartHome\/Devices\//i)) { processSmartHomeDevicesMessages(mqttmsg, mqttpayload); }
else if (mqttmsg.match(/^openwb\/config\/get\/SmartHome\/Devices\//i)) { processSmartHomeDevicesConfigMessages(mqttmsg, mqttpayload); }
else if (mqttmsg.match(/^openwb\/SmartHome\/Status\//i)) { processSmartHomeDevicesStatusMessages(mqttmsg, mqttpayload); }
else if (mqttmsg.match(/^openwb\/config\/get\/sofort\/lp\//i)) { processSofortConfigMessages(mqttmsg, mqttpayload); }
else if (mqttmsg.match(/^openwb\/config\/get\/pv\//i)) { processPvConfigMessages(mqttmsg, mqttpayload); }
} // end handlevar
Expand Down Expand Up @@ -1224,6 +1225,18 @@ function processSmartHomeDevicesConfigMessages(mqttmsg, mqttpayload) {
window['d' + index + 'name'] = mqttpayload;
}
}
function processSmartHomeDevicesStatusMessages(mqttmsg, mqttpayload) {
processPreloader(mqttmsg);
// color theme

if (mqttmsg.match(/^openwb\/SmartHome\/Status\/wattnichtHaus$/i)) {
var SHPower = parseInt(mqttpayload, 10);
if (isNaN(SHPower)) {
SHPower = 0;
}
wbdata.updateGlobal ("smarthomePower", SHPower) ;
}
}
function subscribeMqttGraphSegments() {
for (var segments = 1; segments < 17; segments++) {
topic = "openWB/graph/" + segments + "alllivevalues";
Expand Down Expand Up @@ -1296,3 +1309,4 @@ function makeFloat(message) {
}
return number;
}

1 change: 1 addition & 0 deletions web/themes/colors/setupMqttServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ var topicsToSubscribe = [
["openWB/config/get/SmartHome/Devices/7/mode", 1],
["openWB/config/get/SmartHome/Devices/8/mode", 1],
["openWB/config/get/SmartHome/Devices/9/mode", 1],
["openWB/SmartHome/Status/wattnichtHaus", 1],
// Config Vars Sofort current
["openWB/config/get/sofort/lp/1/current", 1],
["openWB/config/get/sofort/lp/2/current", 1],
Expand Down

0 comments on commit 0ed5edb

Please sign in to comment.