Skip to content

Commit

Permalink
Erweiterung Statuspage
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ortenstein committed May 7, 2019
1 parent 479925a commit d077ace
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 55 deletions.
6 changes: 6 additions & 0 deletions modules/bezug_kostalplenticoreem300haus/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ fi
"cp" /var/www/html/openWB/ramdisk/temp_evuv2 /var/www/html/openWB/ramdisk/evuv2
# Spannung Phase 3
"cp" /var/www/html/openWB/ramdisk/temp_evuv3 /var/www/html/openWB/ramdisk/evuv3
# Power Faktor Phase 1
"cp" /var/www/html/openWB/ramdisk/temp_evupf1 /var/www/html/openWB/ramdisk/evupf1
# Power Faktor Phase 2
"cp" /var/www/html/openWB/ramdisk/temp_evupf2 /var/www/html/openWB/ramdisk/evupf2
# Power Faktor Phase 3
"cp" /var/www/html/openWB/ramdisk/temp_evupf3 /var/www/html/openWB/ramdisk/evupf3

# Rückgabe des Wertes Bezug EVU
bezugwatt=$(</var/www/html/openWB/ramdisk/wattbezug)
Expand Down
45 changes: 0 additions & 45 deletions modules/speicher_kostalplenticore/read_kostalplenticorebatt.py

This file was deleted.

57 changes: 47 additions & 10 deletions modules/wr_plenticore/read_kostalplenticore.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
# ist Lade-/Entladeleistung des angeschlossenen Speichers
# {charge=negativ, discharge=positiv}
reg_582 = client.read_holding_registers(582,1,unit=71)
# Plenticore Register 320: Total_yield [Wh]
# ist PV Gesamt-Ertrag
reg_320 = client.read_holding_registers(320,2,unit=71)
# Plenticore Register 575: Inverter_generation_power_actual [W]
# ist AC-Leistungsabgabe des Wechselrichters
reg_575 = client.read_holding_registers(575,1,unit=71)
Expand Down Expand Up @@ -88,12 +85,30 @@
# Phase 3
# Plenticore Register 250: Voltage_phase_3_(powermeter) [V]
reg_250 = client.read_holding_registers(250,2,unit=71)
#//TODO: weitere Register später hinzufügen für PV-Statistik
# Plenticore Register 150: Actual_cos_phi []
# ist Wirkfaktor
reg_150 = client.read_holding_registers(150,2,unit=71)
# Plenticore Register 320: Total_yield [Wh]
# ist PV Gesamtertrag
reg_320 = client.read_holding_registers(320,2,unit=71)
# Plenticore Register 322: Daily_yield [Wh]
# ist PV Tagesertrag
reg_322 = client.read_holding_registers(322,2,unit=71)
# Plenticore Register 324: Yearly_yield [Wh]
# ist PV Jahresertrag
reg_324 = client.read_holding_registers(324,2,unit=71)
# Plenticore Register 326: Monthly_yield [Wh]
# ist PV Monatsertrag
reg_326 = client.read_holding_registers(326,2,unit=71)

# ausgelesene Register dekodieren
FRegister_100 = BinaryPayloadDecoder.fromRegisters(reg_100.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_150 = BinaryPayloadDecoder.fromRegisters(reg_150.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_582 = BinaryPayloadDecoder.fromRegisters(reg_582.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_320 = BinaryPayloadDecoder.fromRegisters(reg_320.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_322 = BinaryPayloadDecoder.fromRegisters(reg_322.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_324 = BinaryPayloadDecoder.fromRegisters(reg_324.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_326 = BinaryPayloadDecoder.fromRegisters(reg_326.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_575 = BinaryPayloadDecoder.fromRegisters(reg_575.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_514 = BinaryPayloadDecoder.fromRegisters(reg_514.registers, byteorder=Endian.Big, wordorder=Endian.Little)
FRegister_222 = BinaryPayloadDecoder.fromRegisters(reg_222.registers, byteorder=Endian.Big, wordorder=Endian.Little)
Expand All @@ -112,6 +127,9 @@
Total_DC_power = int(FRegister_100.decode_32bit_float())
Actual_batt_ch_disch_power = int(FRegister_582.decode_16bit_int())
Total_yield = int(FRegister_320.decode_32bit_float())
Daily_yield = round((FRegister_322.decode_32bit_float()/1000),2)
Yearly_yield = round((FRegister_324.decode_32bit_float()/1000),2)
Monthly_yield = round((FRegister_326.decode_32bit_float()/1000),2)
Inverter_generation_power_actual = int(FRegister_575.decode_16bit_int())
Battery_actual_SOC = int(FRegister_514.decode_16bit_int())
Current_phase_1_powermeter = round(FRegister_222.decode_32bit_float(),2)
Expand All @@ -125,6 +143,7 @@
Voltage_phase_1_powermeter = round(FRegister_230.decode_32bit_float(),2)
Voltage_phase_2_powermeter = round(FRegister_240.decode_32bit_float(),2)
Voltage_phase_3_powermeter = round(FRegister_250.decode_32bit_float(),2)
Actual_cos_phi = round(FRegister_150.decode_32bit_float(),3)

# AC-Leistung der PV-Module bestimmen
# da ggf. Batterie DC-seitig in Total_DC_power enthalten ist,
Expand All @@ -139,14 +158,15 @@
else:
# wird PV-DC-Leistung erzeugt, müssen die Wandlungsverluste betrachtet werden
# Kostal liefert nur DC-seitige Werte
if Actual_batt_ch_disch_power < 0:
# wird die Batterie geladen, ist die PV-Leistung die Summe aus
# verlustbehafteter AC-Leistungsabgabe des WR und der DC-Ladeleistung,
# die Wandlungsverluste werden also nur in der PV-Leistung ersichtlich
PV_power_ac = Inverter_generation_power_actual - Actual_batt_ch_disch_power
else:
# zunächst Annahme, die Batterie wird geladen:
# die PV-Leistung die Summe aus verlustbehafteter AC-Leistungsabgabe des WR
# und der DC-Ladeleistung, die Wandlungsverluste werden also nur in der PV-Leistung
# ersichtlich
PV_power_ac = Inverter_generation_power_actual - Actual_batt_ch_disch_power
if Actual_batt_ch_disch_power > 0 and Total_DC_power != 0:
# wird die Batterie entladen, werden die Wandlungsverluste anteilig an der
# DC-Leistung auf PV und Batterie verteilt
# dazu muss der Divisor Total_DC_power != 0 sein
PV_power_ac = int((PV_power_dc / float(Total_DC_power)) * Inverter_generation_power_actual)
Actual_batt_ch_disch_power = Inverter_generation_power_actual - PV_power_ac

Expand All @@ -167,6 +187,15 @@
# Gesamtertrag in Kilowattstunden
with open('/var/www/html/openWB/ramdisk/pvkwhk', 'w') as f:
f.write(str(Total_yield / 1000))
# Tagesertrag in Kilowattstunden
with open('/var/www/html/openWB/ramdisk/daily_pvkwhk', 'w') as f:
f.write(str(Daily_yield))
# Jahresertrag in Kilowattstunden
with open('/var/www/html/openWB/ramdisk/yearly_pvkwhk', 'w') as f:
f.write(str(Yearly_yield))
# Monatsertrag in Kilowattstunden
with open('/var/www/html/openWB/ramdisk/monthly_pvkwhk', 'w') as f:
f.write(str(Monthly_yield))

# Nachfolgende Werte nur in temporäre ramdisk, da die Module
# Speicher und Bezug für die globalen Variablen zuständig sind
Expand Down Expand Up @@ -210,3 +239,11 @@
#Spannung Phase 3
with open('/var/www/html/openWB/ramdisk/temp_evuv3', 'w') as f:
f.write(str(Voltage_phase_3_powermeter))
#Wirkfaktor, wird nur einmal vom Wechselrichter ausgegeben,
#und ist demnach für alle Phasen identisch
with open('/var/www/html/openWB/ramdisk/temp_evupf1', 'w') as f:
f.write(str(Actual_cos_phi))
with open('/var/www/html/openWB/ramdisk/temp_evupf2', 'w') as f:
f.write(str(Actual_cos_phi))
with open('/var/www/html/openWB/ramdisk/temp_evupf3', 'w') as f:
f.write(str(Actual_cos_phi))
12 changes: 12 additions & 0 deletions runs/atreboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ touch /var/www/html/openWB/ramdisk/llas22
touch /var/www/html/openWB/ramdisk/llas23
touch /var/www/html/openWB/ramdisk/llkwh
touch /var/www/html/openWB/ramdisk/pvkwh
touch /var/www/html/openWB/ramdisk/daily_pvkwhk
touch /var/www/html/openWB/ramdisk/yearly_pvkwhk
touch /var/www/html/openWB/ramdisk/monthly_pvkwhk
touch /var/www/html/openWB/ramdisk/llkwhs1
touch /var/www/html/openWB/ramdisk/einspeisungkwh
touch /var/www/html/openWB/ramdisk/bezugkwh
Expand Down Expand Up @@ -64,6 +67,9 @@ touch /var/www/html/openWB/ramdisk/temp_bezugw3
touch /var/www/html/openWB/ramdisk/temp_evuv1
touch /var/www/html/openWB/ramdisk/temp_evuv2
touch /var/www/html/openWB/ramdisk/temp_evuv3
touch /var/www/html/openWB/ramdisk/temp_evupf1
touch /var/www/html/openWB/ramdisk/temp_evupf2
touch /var/www/html/openWB/ramdisk/temp_evupf3
# Werte initialisieren
echo 0 > /var/www/html/openWB/ramdisk/temp_wattbezug
echo 0 > /var/www/html/openWB/ramdisk/temp_peicherleistung
Expand All @@ -78,6 +84,9 @@ echo 0 > /var/www/html/openWB/ramdisk/temp_bezugw3
echo 0 > /var/www/html/openWB/ramdisk/temp_evuv1
echo 0 > /var/www/html/openWB/ramdisk/temp_evuv2
echo 0 > /var/www/html/openWB/ramdisk/temp_evuv3
echo 0 > /var/www/html/openWB/ramdisk/temp_evupf1
echo 0 > /var/www/html/openWB/ramdisk/temp_evupf2
echo 0 > /var/www/html/openWB/ramdisk/temp_evupf3

echo 0 > /var/www/html/openWB/ramdisk/zielladenkorrektura
echo 0 > /var/www/html/openWB/ramdisk/nachtladenstate
Expand Down Expand Up @@ -155,6 +164,9 @@ echo "--" > /var/www/html/openWB/ramdisk/restzeitlp2
echo "--" > /var/www/html/openWB/ramdisk/restzeitlp3
echo 0 > /var/www/html/openWB/ramdisk/pvkwh
echo 0 > /var/www/html/openWB/ramdisk/pvkwhk
echo 0 > /var/www/html/openWB/ramdisk/daily_pvkwhk
echo 0 > /var/www/html/openWB/ramdisk/yearly_pvkwhk
echo 0 > /var/www/html/openWB/ramdisk/monthly_pvkwhk
echo 0 > /var/www/html/openWB/ramdisk/bezugkwh
echo 0 > /var/www/html/openWB/ramdisk/einspeisungkwh
echo 0 > /var/www/html/openWB/ramdisk/llkwhs1
Expand Down
59 changes: 59 additions & 0 deletions web/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,45 @@ function getfile() {
doInterval = setInterval(getfile, 2000);
</script>

<script type='text/javascript'>
var doInterval;
function getfile() {
$.ajax({
url: "/openWB/ramdisk/daily_pvkwhk",
complete: function(request){
$("#daily_pvkwhdiv").html(request.responseText);
}
});
}
doInterval = setInterval(getfile, 2000);
</script>

<script type='text/javascript'>
var doInterval;
function getfile() {
$.ajax({
url: "/openWB/ramdisk/monthly_pvkwhk",
complete: function(request){
$("#monthly_pvkwhdiv").html(request.responseText);
}
});
}
doInterval = setInterval(getfile, 2000);
</script>

<script type='text/javascript'>
var doInterval;
function getfile() {
$.ajax({
url: "/openWB/ramdisk/yearly_pvkwhk",
complete: function(request){
$("#yearly_pvkwhdiv").html(request.responseText);
}
});
}
doInterval = setInterval(getfile, 2000);
</script>

<script type='text/javascript'>
var doInterval;
function getfile() {
Expand Down Expand Up @@ -1033,6 +1072,26 @@ function getfile() {
<div id="pvkwhdiv"></div>
</div>
</div>
<div class="row" style="background-color:#BEFEBE">
<div class="col-xs-2 text-center">
PV Tagesertrag [kWh]
</div>
<div class="col-xs-2 text-center">
<div id="daily_pvkwhdiv"></div>
</div>
<div class="col-xs-2 text-center">
PV Monatsertrag [kWh]
</div>
<div class="col-xs-2 text-center">
<div id="monthly_pvkwhdiv"></div>
</div>
<div class="col-xs-2 text-center">
PV Jahresertrag [kWh]
</div>
<div class="col-xs-2 text-center">
<div id="yearly_pvkwhdiv"></div>
</div>
</div>
<hr>
<div class="row">
<div class="col-xs-2 text-center bg-info">
Expand Down

0 comments on commit d077ace

Please sign in to comment.