Show current export price in export gauge

This commit is contained in:
Gunnar Skjold
2024-04-14 14:47:53 +02:00
parent 3a980fac4c
commit ce67ef2bea
6 changed files with 47 additions and 33 deletions

File diff suppressed because one or more lines are too long

View File

@@ -38,11 +38,14 @@
translations = update;
});
let it,et,threePhase;
let it,et,threePhase, l1e, l2e, l3e;
$: {
it = formatUnit(data?.ic * 1000, "Wh");
et = formatUnit(data?.ec * 1000, "Wh");
threePhase = data?.l1?.u > 100 && data?.l2?.u > 100 && data?.l3?.u > 100;
l1e = data?.l1?.u > 0.0 || data?.l1?.i > 0.0 || data?.l1?.p > 0.0 || data?.l1?.q > 0.0;
l2e = data?.l2?.u > 0.0 || data?.l2?.i > 0.0 || data?.l2?.p > 0.0 || data?.l2?.q > 0.0;
l3e = data?.l3?.u > 0.0 || data?.l3?.i > 0.0 || data?.l3?.p > 0.0 || data?.l3?.q > 0.0;
threePhase = l1e && l2e && l3e;
}
</script>
@@ -62,7 +65,7 @@
<div class="cnt">
<div class="grid grid-cols-2">
<div class="col-span-2">
<PowerGauge val={data.e ? data.e : 0} max={data.om ? data.om * 1000 : 10000} unit="W" label={translations.common?.export ?? "Export"} colorFn={exportcol}/>
<PowerGauge val={data.e ? data.e : 0} max={data.om ? data.om * 1000 : 10000} unit="W" label={translations.common?.export ?? "Export"} sub={data.px} subunit={data.pc} colorFn={exportcol}/>
</div>
<div></div>
<div class="text-right">{et[0]} {et[1]}</div>

View File

@@ -64,17 +64,25 @@
let ticks = [];
if(maxExport) {
let num = maxExport > maxImport ? 4 : (maxExport*4)/maxImport;
ticks.push({ value: -maxExport, label: '-100%' });
ticks.push({ value: (-maxExport/4)*3, label: '-75%' });
ticks.push({ value: -maxExport/2, label: '-50%' });
ticks.push({ value: -maxExport/4, label: '-25%' });
if(num >= 4)
ticks.push({ value: (-maxExport/4)*3, label: '-75%' });
if(num >= 2)
ticks.push({ value: -maxExport/2, label: '-50%' });
if(num >= 4)
ticks.push({ value: -maxExport/4, label: '-25%' });
}
ticks.push({ value: 0, label: '0%' });
if(maxImport) {
let num = maxImport > maxExport ? 4 : (maxImport*4)/maxExport;
ticks.push({ value: maxImport/4, label: '25%' });
ticks.push({ value: maxImport/2, label: '50%' });
ticks.push({ value: (maxImport/4)*3, label: '75%' });
ticks.push({ value: maxImport, label: '100%' });
if(num >= 4)
ticks.push({ value: maxImport/2, label: '50%' });
if(num >= 2)
ticks.push({ value: (maxImport/4)*3, label: '75%' });
if(num >= 4)
ticks.push({ value: maxImport, label: '100%' });
}
config = {

View File

@@ -17,24 +17,24 @@ export default defineConfig({
plugins: [svelte()],
server: {
proxy: {
"/data.json": "http://192.168.233.115",
"/energyprice.json": "http://192.168.233.115",
"/dayplot.json": "http://192.168.233.115",
"/monthplot.json": "http://192.168.233.115",
"/temperature.json": "http://192.168.233.115",
"/sysinfo.json": "http://192.168.233.115",
"/configuration.json": "http://192.168.233.115",
"/tariff.json": "http://192.168.233.115",
"/realtime.json": "http://192.168.233.115",
"/priceconfig.json": "http://192.168.233.115",
"/save": "http://192.168.233.115",
"/reboot": "http://192.168.233.115",
"/configfile": "http://192.168.233.115",
"/upgrade": "http://192.168.233.115",
"/mqtt-ca": "http://192.168.233.115",
"/mqtt-cert": "http://192.168.233.115",
"/mqtt-key": "http://192.168.233.115",
"/logo.svg": "http://192.168.233.115",
"/data.json": "http://192.168.233.184",
"/energyprice.json": "http://192.168.233.184",
"/dayplot.json": "http://192.168.233.184",
"/monthplot.json": "http://192.168.233.184",
"/temperature.json": "http://192.168.233.184",
"/sysinfo.json": "http://192.168.233.184",
"/configuration.json": "http://192.168.233.184",
"/tariff.json": "http://192.168.233.184",
"/realtime.json": "http://192.168.233.184",
"/priceconfig.json": "http://192.168.233.184",
"/save": "http://192.168.233.184",
"/reboot": "http://192.168.233.184",
"/configfile": "http://192.168.233.184",
"/upgrade": "http://192.168.233.184",
"/mqtt-ca": "http://192.168.233.184",
"/mqtt-cert": "http://192.168.233.184",
"/mqtt-key": "http://192.168.233.184",
"/logo.svg": "http://192.168.233.184",
}
}
})

View File

@@ -44,6 +44,7 @@
"mm" : %d,
"me" : %d,
"p" : %s,
"px" : %s,
"mt" : %d,
"ds" : %d,
"ea" : {

View File

@@ -516,6 +516,7 @@ void AmsWebServer::dataJson() {
}
float price = ea->getPriceForHour(PRICE_DIRECTION_IMPORT, 0);
float exportPrice = ea->getPriceForHour(PRICE_DIRECTION_EXPORT, 0);
String peaks = "";
for(uint8_t i = 1; i <= ea->getConfig()->hours; i++) {
@@ -569,6 +570,7 @@ void AmsWebServer::dataJson() {
mqttStatus,
mqttHandler == NULL ? 0 : (int) mqttHandler->lastError(),
price == PRICE_NO_VALUE ? "null" : String(price, 2).c_str(),
exportPrice == PRICE_NO_VALUE ? "null" : String(exportPrice, 2).c_str(),
meterState->getMeterType(),
distributionSystem,
ea->getMonthMax(),