Skip to content

Commit

Permalink
Merge pull request snaptec#2574 from cshagen/master
Browse files Browse the repository at this point in the history
Colors theme: show autarchy and self usage, display temperatures
  • Loading branch information
benderl authored Jan 16, 2023
2 parents 9444912 + 9236d4a commit 7828294
Show file tree
Hide file tree
Showing 9 changed files with 1,593 additions and 1,227 deletions.
112 changes: 57 additions & 55 deletions web/themes/colors/batteryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,69 @@

class BatteryList {

div;
constructor() { };
div;
constructor() { };

// initialize after document is created
init() {
this.div = d3.select("div#batteryStatus");
}
// initialize after document is created
init() {
this.div = d3.select("div#batteryStatus");
}

// update if data has changed
update() {
this.div.selectAll("*").remove();
if (wbdata.isBatteryConfigured) {
d3.select("div#batteryWidget").classed("hide", false);
const table = this.div.append("table")
.attr("class", "table table-borderless table-condensed p-0 m-0");
const headers = ["Leistung", "Geladen", "Geliefert", "Ladestand"];
const thead = table.append("thead")
.selectAll("headers")
.data(headers).enter()
.append("th")
.attr("style", "text-align:center;")
.attr("class", "tablecell ")
.text((data) => data)
;
// update if data has changed
update() {
this.div.selectAll("*").remove();
if (wbdata.isBatteryConfigured) {
d3.select("div#batteryWidget").classed("hide", false);
const table = this.div.append("table")
.attr("class", "table table-borderless table-condensed p-0 m-0");
const headers = ["Leistung", "Geladen", "Geliefert", "Ladestand"];
const thead = table.append("thead")
.selectAll("headers")
.data(headers).enter()
.append("th")
.attr("style", "text-align:center;")
.attr("class", "tablecell ")
.text((data) => data)
;

const row = table.append("tbody")
.append("tr")
.style("color", wbdata.sourceSummary.batOut.color)
.style("text-align", "center");
const row = table.append("tbody")
.append("tr")
.style("color", wbdata.sourceSummary.batOut.color)
.style("text-align", "center");

// current power
const cell = row.append("td")
.attr("class", "tablecell py-1 px-1");
if (wbdata.batteryPowerImport > 0) {
cell.text("Ladung: " + formatWatt(wbdata.batteryPowerImport))
} else if (wbdata.batteryPowerExport > 0) {
cell.text("Lieferung: " + formatWatt(wbdata.batteryPowerExport))
} else {
cell.text("0 W")
}
// Daily Import
row.append("td")
.attr("class", "tablecell py-1 px-1")
.attr("style", "vertical-align: middle;")
.text(formatWattH(wbdata.batteryEnergyImport*1000));
// current power
const cell = row.append("td")
.attr("class", "tablecell py-1 px-1 d-flex align-items-center justify-content-center flex-wrap");
if (wbdata.batteryPowerImport > 0) {
cell.append("span").attr("class", "pr-1").text("Ladung: ");
cell.append("span").text(formatWatt(wbdata.batteryPowerImport));
} else if (wbdata.batteryPowerExport > 0) {
cell.append("span").attr("class", "pr-1").text("Lieferung: ");
cell.append("span").text(formatWatt(wbdata.batteryPowerExport));
} else {
cell.text("0 W")
}
// Daily Import
row.append("td")
.attr("class", "tablecell py-1 px-1")
.attr("style", "vertical-align: middle;")
.text(formatWattH(wbdata.batteryEnergyImport * 1000));

// Daily Export
row.append("td")
.attr("class", "tablecell py-1 px-1")
.attr("style", "vertical-align: middle;")
.text(formatWattH(wbdata.batteryEnergyExport*1000));
// Daily Export
row.append("td")
.attr("class", "tablecell py-1 px-1")
.attr("style", "vertical-align: middle;")
.text(formatWattH(wbdata.batteryEnergyExport * 1000));

// SoC
row.append("td")
.attr("class", "tablecell py-1 px-1")
.text(wbdata.batterySoc + " %");
}
else {
d3.select("div#batteryWidget").classed("hide", true);
}
}
// SoC
row.append("td")
.attr("class", "tablecell py-1 px-1")
.text(wbdata.batterySoc + " %");
}
else {
d3.select("div#batteryWidget").classed("hide", true);
}
}
}


Expand Down
Loading

0 comments on commit 7828294

Please sign in to comment.