Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PV Gesamt-Anlagendaten (automatische Nachführung für Monatsertrag und … Jahresertrag) / angepasst allerneuste Nightly #1859

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion loadvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,15 @@ loadvars(){
pvallwh=$(echo "$pvkwh + $pv2kwh" |bc)
echo $pvallwh > /var/www/html/openWB/ramdisk/pvallwh
fi

# monthly / yearly fuer status rechnen (csv aus cronnight und laufend)
pvdaily=$(</var/www/html/openWB/ramdisk/daily_pvkwhk)
pvyearlycsv=$(</var/www/html/openWB/ramdisk/yearly_pvkwhk_csv)
pvmonthlycsv=$(</var/www/html/openWB/ramdisk/monthly_pvkwhk_csv)
pvyearly=$(echo "$pvdaily + $pvyearlycsv" |bc)
pvmonthly=$(echo "$pvdaily + $pvmonthlycsv" |bc)
echo $pvyearly > /var/www/html/openWB/ramdisk/yearly_pvkwhk
echo $pvmonthly > /var/www/html/openWB/ramdisk/monthly_pvkwhk
# rechnen ende
if [[ $speichermodul == "speicher_e3dc" ]] || [[ $speichermodul == "speicher_tesvoltsma" ]] || [[ $speichermodul == "speicher_solarwatt" ]] || [[ $speichermodul == "speicher_rct" ]]|| [[ $speichermodul == "speicher_lgessv1" ]] || [[ $speichermodul == "speicher_bydhv" ]] || [[ $speichermodul == "speicher_kostalplenticore" ]] || [[ $speichermodul == "speicher_powerwall" ]] || [[ $speichermodul == "speicher_sbs25" ]] || [[ $speichermodul == "speicher_solaredge" ]] || [[ $speichermodul == "speicher_sonneneco" ]] || [[ $speichermodul == "speicher_varta" ]] ; then
ra='^-?[0-9]+$'
watt2=$(</var/www/html/openWB/ramdisk/speicherleistung)
Expand Down
48 changes: 36 additions & 12 deletions runs/csvcalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ def outfiledefyear(jjjjinput):
# heutiges Jahr nachgerechnet, ramdisk nehmen
file_stringo = outputa + 'logaktyearonl.csv'
file_stringos = outputa + 'logaktyearonls.csv'
akt_year = 1
else:
file_stringo = outputp + str(jjjjinput) + 'onl.csv'
file_stringos = outputp + str(jjjjinput) + 'onls.csv'
return (file_stringo,file_stringos)
akt_year = 0
return (file_stringo,file_stringos,akt_year)
def outfiledef(jjjjmminput):
if (str(jjjjmminput) == str(aktjjjjmm)):
# heutiger Monat nachgerechnet, ramdisk nehmen
file_stringo = outputa + 'logaktmonthonl.csv'
file_stringos = outputa + 'logaktmonthonls.csv'
akt_month = 1
else:
file_stringo = outputp + str(jjjjmminput) + 'onl.csv'
file_stringos = outputp + str(jjjjmminput) + 'onls.csv'
return (file_stringo,file_stringos)
akt_month = 0
return (file_stringo,file_stringos,akt_month)
def exceldate(datestring):
datestringexcel = datestring[-2:] + '.' + datestring[4:6] + '.' + datestring[:4]
return datestringexcel
Expand Down Expand Up @@ -284,7 +288,7 @@ def fillcount(row, datestring ,file_stringo,firstfile):
sumcsv [i] = float(0)
return

def fillcounts(monhtrow,file_stringos,lastdate,lastzeit):
def fillcounts(monhtrow,file_stringos,lastdate,lastzeit,akt_month):
f1 = open( file_stringos, 'w')
line='Anzahl Spalten,' + str(SUMCOLUMNSTART*2) + ',Letzes Datum,' + lastdate + ',Letzte Zeit,' + lastzeit + ', \n'
f1.write(str(line))
Expand All @@ -305,13 +309,23 @@ def fillcounts(monhtrow,file_stringos,lastdate,lastzeit):
f1.write(str(line))
f1.close()
os.chmod(file_stringos, 0o777)
#hier aktuelle pv Leistung fuer diesen Monat schreiben
if (akt_month == 1):
f1 = open('/var/www/html/openWB/ramdisk/monthly_pvkwhk_csv', 'w')
# pv pos 3
sumt=float(sumcsvt [3]/1000)
f1.write(str(float("%.3f" % sumt)))
f1.close()
os.chmod('/var/www/html/openWB/ramdisk/monthly_pvkwhk_csv', 0o777)
print ('%s %s written' % (getTime(),file_stringos))
for i in range(1,SUMCOLUMNSTART):
if (i < len(monhtrow)):
monhtrow [i] = float(0)
sumcsvt [i] = float(0)
return
def reyeardet(calcyear):
for i in range(1,SUMCOLUMNSTART):
sumcsvtj [i] = float(0)
firstfile=1
validdata=0
#print ('%s actyear ' % (calcyear))
Expand All @@ -323,9 +337,9 @@ def reyeardet(calcyear):
dds = '0' + str (dd)
datestring = int(str(calcyear) + dds[-2:])
#summenfile montssuchen
(file_stringi,file_stringis) = outfiledef(datestring)
(file_stringi,file_stringis,akt_month) = outfiledef(datestring)
#outputfile year
(file_stringo,file_stringos) = outfiledefyear(calcyear)
(file_stringo,file_stringos,akt_year) = outfiledefyear(calcyear)
if os.path.isfile(file_stringis):
ifile=1
else:
Expand Down Expand Up @@ -361,7 +375,9 @@ def reyeardet(calcyear):
f1.write(str(headerline))
sumline=''
for i in range(1,startspalten+2):
#print ('I %s ' % (str(i-1)))
if (i > int(startspalten/2)) and (i < startspalten):
sumcsvtj [i - int(startspalten/2)] = float (sumcsvtj [i - int(startspalten/2)] ) + float( sumrow [i] )
#print ('I %s %s ' % (str(i),str(sumrow [i])))
sumline=sumline+ str(sumrow [i-1])
if i < (startspalten+1):
sumline=sumline+ ','
Expand All @@ -378,6 +394,13 @@ def reyeardet(calcyear):
f1.write(str(headerline))
f1.close()
os.chmod(file_stringos, 0o777)
#hier aktuelle pv Leistung fuer diesen jahr schreiben
if (akt_year == 1):
f1 = open('/var/www/html/openWB/ramdisk/yearly_pvkwhk_csv', 'w')
# pv pos 3
f1.write(str(float("%.3f" % sumcsvtj [3])))
f1.close()
os.chmod('/var/www/html/openWB/ramdisk/yearly_pvkwhk_csv', 0o777)
print ('%s %s written' % (getTime(),file_stringos))
return
def remonth(jjjjmm):
Expand All @@ -397,7 +420,7 @@ def remonth(jjjjmm):
dds = '0' + str (dd)
datestring = str(jjjjmm) + dds[-2:]
file_stringi = inputp + datestring + '.csv'
(file_stringo,file_stringos) = outfiledef(jjjjmm)
(file_stringo,file_stringos,akt_month) = outfiledef(jjjjmm)
if os.path.isfile(file_stringi):
ifile=1
else:
Expand Down Expand Up @@ -464,7 +487,7 @@ def remonth(jjjjmm):
except Exception as e:
print ('%s error1 %s inhalt %s' % (getTime(),datestring, str(e) ))
#summenfile schreiben
fillcounts(monhtrow,file_stringos,lastdate,lastzeit)
fillcounts(monhtrow,file_stringos,lastdate,lastzeit,akt_month)
return
def checkyear(calcyear):
#lesen summenfile year
Expand All @@ -476,7 +499,7 @@ def checkyear(calcyear):
lastspalten = 0
dfile=0
ifile=0
(file_stringo,file_stringos) = outfiledefyear(calcyear)
(file_stringo,file_stringos,akt_year) = outfiledefyear(calcyear)
try:
if os.path.isfile(file_stringos):
ifile=1
Expand All @@ -493,7 +516,7 @@ def checkyear(calcyear):
dds = '0' + str (dd)
datestring = int(str(calcyear) + dds[-2:])
#letzses summenfile montssuchen
(file_stringi,file_stringis) = outfiledef(datestring)
(file_stringi,file_stringis,akt_month) = outfiledef(datestring)
if os.path.isfile(file_stringis):
dfile=1
f = open( file_stringis, 'r')
Expand Down Expand Up @@ -527,7 +550,7 @@ def checkmonth(jjjjmm):
compspalten = 0
dfile=0
ifile=0
(file_stringo,file_stringos) = outfiledef(jjjjmm)
(file_stringo,file_stringos,akt_month) = outfiledef(jjjjmm)
try:
if os.path.isfile(file_stringos):
ifile=1
Expand Down Expand Up @@ -648,11 +671,12 @@ def reyear():
countercsv = []
sumcsv = []
sumcsvt = []
sumcsvtj = []
for i in range (1,SUMCOLUMNSTART+1):
countercsv.append("0")
sumcsv.append("0")
sumcsvt.append(float(0))

sumcsvtj.append(float(0))
prep()
print ('%s csvcalc.py processing mode %s date jjjjmm %6d' % (getTime(),mode,jjjjmm))
if (mode == 'M'):
Expand Down
2 changes: 2 additions & 0 deletions runs/initRamdisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ initRamdisk(){
echo 0 > $RamdiskPath/daily_pvkwhk1
echo 0 > $RamdiskPath/daily_pvkwhk2
echo 0 > $RamdiskPath/monthly_pvkwhk
echo 0 > $RamdiskPath/monthly_pvkwhk_csv
echo 0 > $RamdiskPath/monthly_pvkwhk1
echo 0 > $RamdiskPath/monthly_pvkwhk2
echo 0 > $RamdiskPath/nurpv70dynstatus
Expand All @@ -268,6 +269,7 @@ initRamdisk(){
echo 0 > $RamdiskPath/pvwatt1
echo 0 > $RamdiskPath/pvwatt2
echo 0 > $RamdiskPath/yearly_pvkwhk
echo 0 > $RamdiskPath/yearly_pvkwhk_csv
echo 0 > $RamdiskPath/yearly_pvkwhk1
echo 0 > $RamdiskPath/yearly_pvkwhk2

Expand Down