Basierend auf diesem Wiki-Eintrag:
https://wiki.fhem.de/wiki/Datenbankgest%C3%BCtzte_Erstellung_der_Energiebilanz_einer_SMA_PV-Anlage_mit_%C3%9Cberschusseinspeisung (https://wiki.fhem.de/wiki/Datenbankgest%C3%BCtzte_Erstellung_der_Energiebilanz_einer_SMA_PV-Anlage_mit_%C3%9Cberschusseinspeisung)
habe ich die Visualisierung etwas erweitert.
Ergebnis: siehe angehängten Screenshot
Meine Hardware:
- B+G Zähler (saldierend gemacht lt. https://forum.fhem.de/index.php/topic,50196.msg1214239.html#msg1214239 (https://forum.fhem.de/index.php/topic,50196.msg1214239.html#msg1214239))
- Fronius Wechselrichter mit FroniusAPI Modul (https://forum.fhem.de/index.php/topic,113850.0.html (https://forum.fhem.de/index.php/topic,113850.0.html)) (ist aber sicher einfach auf andere zu übertragen
Ein noch ungelöstes Problem: Wenn sich der Stromtarif ändert, werden alle Werte mit dem neuen Tarif berechnet. Auch die historischen.
Vielleicht ist jemand motiviert, sich diesem Problem anzunehmen ;-)
Die 99_EnergyUtils.pm gehört ins <FHEM>/FHEM Verzeichnis. (Rechte beachten und FHEM neustarten.)
Anbei die Definitionen meiner Objekte:
Die dbreps für die Auswertungen:
defmod Rep.EM.Bezug.Jahr DbRep LogSQL
attr Rep.EM.Bezug.Jahr aggregation no
attr Rep.EM.Bezug.Jahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.Jahr device Strom_Import
attr Rep.EM.Bezug.Jahr event-on-update-reading state
attr Rep.EM.Bezug.Jahr reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.Jahr room GH->PV
attr Rep.EM.Bezug.Jahr showproctime 1
attr Rep.EM.Bezug.Jahr timeout 180
attr Rep.EM.Bezug.Jahr timestamp_begin current_year_begin
attr Rep.EM.Bezug.Jahr timestamp_end current_year_end
attr Rep.EM.Bezug.Jahr userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.Jahr verbose 2
defmod Rep.EM.Bezug.Monat DbRep LogSQL
attr Rep.EM.Bezug.Monat aggregation no
attr Rep.EM.Bezug.Monat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.Monat device Strom_Import
attr Rep.EM.Bezug.Monat event-on-update-reading state
attr Rep.EM.Bezug.Monat reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.Monat room GH->PV
attr Rep.EM.Bezug.Monat showproctime 1
attr Rep.EM.Bezug.Monat timeout 180
attr Rep.EM.Bezug.Monat timestamp_begin current_month_begin
attr Rep.EM.Bezug.Monat timestamp_end current_month_end
attr Rep.EM.Bezug.Monat userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.Monat verbose 2
defmod Rep.EM.Bezug.Vorjahr DbRep LogSQL
attr Rep.EM.Bezug.Vorjahr aggregation no
attr Rep.EM.Bezug.Vorjahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.Vorjahr device Strom_Import
attr Rep.EM.Bezug.Vorjahr event-on-update-reading state
attr Rep.EM.Bezug.Vorjahr reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.Vorjahr readingNameMap PowerMeter_Energy_Net_import__kWh_CounterCurrentLastYear
attr Rep.EM.Bezug.Vorjahr room GH->PV
attr Rep.EM.Bezug.Vorjahr showproctime 1
attr Rep.EM.Bezug.Vorjahr timeout 180
attr Rep.EM.Bezug.Vorjahr timestamp_begin previous_year_begin
attr Rep.EM.Bezug.Vorjahr timestamp_end previous_year_end
attr Rep.EM.Bezug.Vorjahr userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.Vorjahr verbose 2
defmod Rep.EM.Bezug.Vormonat DbRep LogSQL
attr Rep.EM.Bezug.Vormonat aggregation no
attr Rep.EM.Bezug.Vormonat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.Vormonat device Strom_Import
attr Rep.EM.Bezug.Vormonat event-on-update-reading state
attr Rep.EM.Bezug.Vormonat reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.Vormonat readingNameMap PowerMeter_Energy_Net_import__kWh_CounterCurrentLastMonth
attr Rep.EM.Bezug.Vormonat room GH->PV
attr Rep.EM.Bezug.Vormonat showproctime 1
attr Rep.EM.Bezug.Vormonat timeout 180
attr Rep.EM.Bezug.Vormonat timestamp_begin previous_month_begin
attr Rep.EM.Bezug.Vormonat timestamp_end previous_month_end
attr Rep.EM.Bezug.Vormonat userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.Vormonat verbose 2
defmod Rep.EM.Bezug.gestern DbRep LogSQL
attr Rep.EM.Bezug.gestern aggregation no
attr Rep.EM.Bezug.gestern devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.gestern device Strom_Import
attr Rep.EM.Bezug.gestern event-on-update-reading state
attr Rep.EM.Bezug.gestern reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.gestern readingNameMap PowerMeter_Energy_Net_import__kWh_CounterCurrentLastDay
attr Rep.EM.Bezug.gestern room GH->PV
attr Rep.EM.Bezug.gestern showproctime 1
attr Rep.EM.Bezug.gestern timeout 180
attr Rep.EM.Bezug.gestern timestamp_begin previous_day_begin
attr Rep.EM.Bezug.gestern timestamp_end previous_day_end
attr Rep.EM.Bezug.gestern userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.gestern verbose 2
defmod Rep.EM.Bezug.heute DbRep LogSQL
attr Rep.EM.Bezug.heute aggregation no
attr Rep.EM.Bezug.heute devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Bezug.heute device Strom_Import
attr Rep.EM.Bezug.heute event-on-update-reading state
attr Rep.EM.Bezug.heute reading PowerMeter_Energy_Net_import__kWh_CounterCurrent
attr Rep.EM.Bezug.heute room GH->PV
attr Rep.EM.Bezug.heute showproctime 1
attr Rep.EM.Bezug.heute timeout 180
attr Rep.EM.Bezug.heute timestamp_begin current_day_begin
attr Rep.EM.Bezug.heute timestamp_end current_day_end
attr Rep.EM.Bezug.heute userExitFn setDumEnergy .*:.*
attr Rep.EM.Bezug.heute verbose 2
defmod Rep.EM.Einspeisung.Jahr DbRep LogSQL
attr Rep.EM.Einspeisung.Jahr aggregation no
attr Rep.EM.Einspeisung.Jahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.Jahr device Strom_Export
attr Rep.EM.Einspeisung.Jahr event-on-update-reading state
attr Rep.EM.Einspeisung.Jahr reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.Jahr room GH->PV
attr Rep.EM.Einspeisung.Jahr showproctime 1
attr Rep.EM.Einspeisung.Jahr timeout 180
attr Rep.EM.Einspeisung.Jahr timestamp_begin current_year_begin
attr Rep.EM.Einspeisung.Jahr timestamp_end current_year_end
attr Rep.EM.Einspeisung.Jahr userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.Jahr verbose 2
defmod Rep.EM.Einspeisung.Monat DbRep LogSQL
attr Rep.EM.Einspeisung.Monat aggregation no
attr Rep.EM.Einspeisung.Monat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.Monat device Strom_Export
attr Rep.EM.Einspeisung.Monat event-on-update-reading state
attr Rep.EM.Einspeisung.Monat reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.Monat room GH->PV
attr Rep.EM.Einspeisung.Monat showproctime 1
attr Rep.EM.Einspeisung.Monat timeout 180
attr Rep.EM.Einspeisung.Monat timestamp_begin current_month_begin
attr Rep.EM.Einspeisung.Monat timestamp_end current_month_end
attr Rep.EM.Einspeisung.Monat userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.Monat verbose 2
defmod Rep.EM.Einspeisung.Vorjahr DbRep LogSQL
attr Rep.EM.Einspeisung.Vorjahr aggregation no
attr Rep.EM.Einspeisung.Vorjahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.Vorjahr device Strom_Export
attr Rep.EM.Einspeisung.Vorjahr event-on-update-reading state
attr Rep.EM.Einspeisung.Vorjahr reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.Vorjahr readingNameMap PowerMeter_Energy_Net_export__kWh_CounterCurrentLastYear
attr Rep.EM.Einspeisung.Vorjahr room GH->PV
attr Rep.EM.Einspeisung.Vorjahr showproctime 1
attr Rep.EM.Einspeisung.Vorjahr timeout 180
attr Rep.EM.Einspeisung.Vorjahr timestamp_begin previous_year_begin
attr Rep.EM.Einspeisung.Vorjahr timestamp_end previous_year_end
attr Rep.EM.Einspeisung.Vorjahr userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.Vorjahr verbose 2
defmod Rep.EM.Einspeisung.Vormonat DbRep LogSQL
attr Rep.EM.Einspeisung.Vormonat aggregation no
attr Rep.EM.Einspeisung.Vormonat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.Vormonat device Strom_Export
attr Rep.EM.Einspeisung.Vormonat event-on-update-reading state
attr Rep.EM.Einspeisung.Vormonat reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.Vormonat readingNameMap PowerMeter_Energy_Net_export__kWh_CounterCurrentLastMonth
attr Rep.EM.Einspeisung.Vormonat room GH->PV
attr Rep.EM.Einspeisung.Vormonat showproctime 1
attr Rep.EM.Einspeisung.Vormonat timeout 180
attr Rep.EM.Einspeisung.Vormonat timestamp_begin previous_month_begin
attr Rep.EM.Einspeisung.Vormonat timestamp_end previous_month_end
attr Rep.EM.Einspeisung.Vormonat userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.Vormonat verbose 2
defmod Rep.EM.Einspeisung.gestern DbRep LogSQL
attr Rep.EM.Einspeisung.gestern aggregation no
attr Rep.EM.Einspeisung.gestern devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.gestern device Strom_Export
attr Rep.EM.Einspeisung.gestern event-on-update-reading state
attr Rep.EM.Einspeisung.gestern reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.gestern readingNameMap PowerMeter_Energy_Net_export__kWh_CounterCurrentLastDay
attr Rep.EM.Einspeisung.gestern room GH->PV
attr Rep.EM.Einspeisung.gestern showproctime 1
attr Rep.EM.Einspeisung.gestern timeout 180
attr Rep.EM.Einspeisung.gestern timestamp_begin previous_day_begin
attr Rep.EM.Einspeisung.gestern timestamp_end previous_day_end
attr Rep.EM.Einspeisung.gestern userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.gestern verbose 2
defmod Rep.EM.Einspeisung.heute DbRep LogSQL
attr Rep.EM.Einspeisung.heute aggregation no
attr Rep.EM.Einspeisung.heute devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.EM.Einspeisung.heute device Strom_Export
attr Rep.EM.Einspeisung.heute event-on-update-reading state
attr Rep.EM.Einspeisung.heute reading PowerMeter_Energy_Net_export__kWh_CounterCurrent
attr Rep.EM.Einspeisung.heute room GH->PV
attr Rep.EM.Einspeisung.heute showproctime 1
attr Rep.EM.Einspeisung.heute timeout 180
attr Rep.EM.Einspeisung.heute timestamp_begin current_day_begin
attr Rep.EM.Einspeisung.heute timestamp_end current_day_end
attr Rep.EM.Einspeisung.heute userExitFn setDumEnergy .*:.*
attr Rep.EM.Einspeisung.heute verbose 2
defmod Rep.WR.Erzeugung.Jahr DbRep LogSQL
attr Rep.WR.Erzeugung.Jahr aggregation no
attr Rep.WR.Erzeugung.Jahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.Jahr device WR
attr Rep.WR.Erzeugung.Jahr diffAccept 2000
attr Rep.WR.Erzeugung.Jahr event-on-update-reading state
attr Rep.WR.Erzeugung.Jahr reading Inverter_Cumulation_TOTAL_ENERGY_Value
attr Rep.WR.Erzeugung.Jahr room GH->PV
attr Rep.WR.Erzeugung.Jahr showproctime 1
attr Rep.WR.Erzeugung.Jahr timeout 180
attr Rep.WR.Erzeugung.Jahr timestamp_begin current_year_begin
attr Rep.WR.Erzeugung.Jahr timestamp_end current_year_end
attr Rep.WR.Erzeugung.Jahr userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.Jahr verbose 2
defmod Rep.WR.Erzeugung.Monat DbRep LogSQL
attr Rep.WR.Erzeugung.Monat aggregation no
attr Rep.WR.Erzeugung.Monat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.Monat device WR
attr Rep.WR.Erzeugung.Monat diffAccept 2000
attr Rep.WR.Erzeugung.Monat event-on-update-reading state
attr Rep.WR.Erzeugung.Monat reading Inverter_Cumulation_TOTAL_ENERGY_Value
attr Rep.WR.Erzeugung.Monat room GH->PV
attr Rep.WR.Erzeugung.Monat showproctime 1
attr Rep.WR.Erzeugung.Monat timeout 180
attr Rep.WR.Erzeugung.Monat timestamp_begin current_month_begin
attr Rep.WR.Erzeugung.Monat timestamp_end current_month_end
attr Rep.WR.Erzeugung.Monat userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.Monat verbose 2
defmod Rep.WR.Erzeugung.Vorjahr DbRep LogSQL
attr Rep.WR.Erzeugung.Vorjahr aggregation no
attr Rep.WR.Erzeugung.Vorjahr devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.Vorjahr device WR
attr Rep.WR.Erzeugung.Vorjahr diffAccept 2000
attr Rep.WR.Erzeugung.Vorjahr event-on-update-reading state
attr Rep.WR.Erzeugung.Vorjahr reading Inverter_Cumulation_TOTAL_ENERGY_Value
attr Rep.WR.Erzeugung.Vorjahr readingNameMap Inverter_Cumulation_TOTAL_ENERGY_ValueLastYear
attr Rep.WR.Erzeugung.Vorjahr room GH->PV
attr Rep.WR.Erzeugung.Vorjahr showproctime 1
attr Rep.WR.Erzeugung.Vorjahr timeout 180
attr Rep.WR.Erzeugung.Vorjahr timestamp_begin previous_year_begin
attr Rep.WR.Erzeugung.Vorjahr timestamp_end previous_year_end
attr Rep.WR.Erzeugung.Vorjahr userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.Vorjahr verbose 2
defmod Rep.WR.Erzeugung.Vormonat DbRep LogSQL
attr Rep.WR.Erzeugung.Vormonat aggregation no
attr Rep.WR.Erzeugung.Vormonat devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.Vormonat device WR
attr Rep.WR.Erzeugung.Vormonat diffAccept 2000
attr Rep.WR.Erzeugung.Vormonat event-on-update-reading state
attr Rep.WR.Erzeugung.Vormonat reading Inverter_Cumulation_TOTAL_ENERGY_Value
attr Rep.WR.Erzeugung.Vormonat readingNameMap Inverter_Cumulation_TOTAL_ENERGY_ValueLastMonth
attr Rep.WR.Erzeugung.Vormonat room GH->PV
attr Rep.WR.Erzeugung.Vormonat showproctime 1
attr Rep.WR.Erzeugung.Vormonat timeout 180
attr Rep.WR.Erzeugung.Vormonat timestamp_begin previous_month_begin
attr Rep.WR.Erzeugung.Vormonat timestamp_end previous_month_end
attr Rep.WR.Erzeugung.Vormonat userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.Vormonat verbose 2
defmod Rep.WR.Erzeugung.gestern DbRep LogSQL
attr Rep.WR.Erzeugung.gestern aggregation no
attr Rep.WR.Erzeugung.gestern devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.gestern device WR
attr Rep.WR.Erzeugung.gestern diffAccept 2000
attr Rep.WR.Erzeugung.gestern event-on-update-reading state
attr Rep.WR.Erzeugung.gestern reading Inverter_Cumulation_DAY_ENERGY_Value
attr Rep.WR.Erzeugung.gestern readingNameMap Inverter_Cumulation_DAY_ENERGY_ValueLastDay
attr Rep.WR.Erzeugung.gestern room GH->PV
attr Rep.WR.Erzeugung.gestern showproctime 1
attr Rep.WR.Erzeugung.gestern timeout 180
attr Rep.WR.Erzeugung.gestern timestamp_begin previous_day_begin
attr Rep.WR.Erzeugung.gestern timestamp_end previous_day_end
attr Rep.WR.Erzeugung.gestern userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.gestern verbose 2
defmod Rep.WR.Erzeugung.heute DbRep LogSQL
attr Rep.WR.Erzeugung.heute aggregation no
attr Rep.WR.Erzeugung.heute devStateIcon connected:10px-kreis-gelb .*disconnect:10px-kreis-rot .*done:10px-kreis-gruen
attr Rep.WR.Erzeugung.heute device WR
attr Rep.WR.Erzeugung.heute diffAccept 2000
attr Rep.WR.Erzeugung.heute event-on-update-reading state
attr Rep.WR.Erzeugung.heute reading Inverter_Cumulation_DAY_ENERGY_Value
attr Rep.WR.Erzeugung.heute room GH->PV
attr Rep.WR.Erzeugung.heute showproctime 1
attr Rep.WR.Erzeugung.heute timeout 180
attr Rep.WR.Erzeugung.heute timestamp_begin current_day_begin
attr Rep.WR.Erzeugung.heute timestamp_end current_day_end
attr Rep.WR.Erzeugung.heute userExitFn setDumEnergy .*:.*
attr Rep.WR.Erzeugung.heute verbose 2
ElectricityCalculator Devices zum Berechnen der Leistungen aus den Energiemengen:
defmod Strom_Export ElectricityCalculator PowerMeter:Energy_Net_export__kWh.*
attr Strom_Export BasicPricePerAnnum 0
attr Strom_Export Currency €
attr Strom_Export DecimalPlace 3
attr Strom_Export ElectricityCounterOffset 1000.305
attr Strom_Export ElectricityKwhPerCounts 1
attr Strom_Export ElectricityPricePerKWh 0.2
attr Strom_Export MonthOfAnnualReading 7
attr Strom_Export MonthlyPayment 0
attr Strom_Export ReadingDestination CalculatorDevice
attr Strom_Export SiPrefixPower W
attr Strom_Export room EG->Stiegenhaus,GH->PV,System->Strom
defmod Strom_Import ElectricityCalculator PowerMeter:Energy_Net_import__kWh.*
attr Strom_Import BasicPricePerAnnum 0
attr Strom_Import Currency €
attr Strom_Import DecimalPlace 3
attr Strom_Import ElectricityCounterOffset 0
attr Strom_Import ElectricityKwhPerCounts 1
attr Strom_Import ElectricityPricePerKWh 0.2
attr Strom_Import MonthOfAnnualReading 7
attr Strom_Import MonthlyPayment 0
attr Strom_Import ReadingDestination CalculatorDevice
attr Strom_Import SiPrefixPower W
attr Strom_Import room EG->Stiegenhaus,GH->PV,System->Strom
Dummy für die Darstellung:
(Hier sind auch die Preise für den Strom Im- und Export als Attribut hinterlegt)
defmod Dum.Energy dummy
attr Dum.Energy userattr Einkaufspreis Verkaufspreis
attr Dum.Energy DbLogValueFn { if ($READING =~ /TotalConsumption/ && $VALUE > 10000){\
$IGNORE=1;;\
}\
}
attr Dum.Energy Einkaufspreis 0.175
attr Dum.Energy Verkaufspreis 0.05
attr Dum.Energy alias Energiebilanz
attr Dum.Energy event-min-interval GridFeedIn:60,GridConsumption:60
attr Dum.Energy event-on-change-reading PV,GridFeedIn,SelfConsumptionQuote,YieldDay,SavingDay
attr Dum.Energy event-on-update-reading TotalConsumption,AutarkyQuoteDay,AutarkyQuoteLastDay,SelfConsumptionQuoteDay,AutarkyQuoteMonth,SelfConsumptionQuoteMonth,GridConsumption
attr Dum.Energy group Energiebilanz
attr Dum.Energy icon measure_power_meter
attr Dum.Energy room GH->PV
attr Dum.Energy stateFormat {\
my $pv = ReadingsVal("$name","PV", "")." W";;\
my $pvd = ReadingsVal("$name","PVDay", "")." kWh";;\
my $pvm = ReadingsVal("$name","PVMonth", "")." kWh";;\
my $pvy = ReadingsVal("$name","PVYear", "")." kWh";;\
my $pvld = ReadingsVal("$name","PVLastDay", "")." kWh";;\
my $pvlm = ReadingsVal("$name","PVLastMonth", "")." kWh";;\
my $pvly = ReadingsVal("$name","PVLastYear", "")." kWh";;\
my $gfi = ReadingsVal("$name","GridFeedIn", "")." W";;\
my $gfid = ReadingsVal("$name","GridFeedInDay", "")." kWh";;\
my $gfim = ReadingsVal("$name","GridFeedInMonth", "")." kWh";;\
my $gfiy = ReadingsVal("$name","GridFeedInYear", "")." kWh";;\
my $gfild = ReadingsVal("$name","GridFeedInLastDay", "")." kWh";;\
my $gfilm = ReadingsVal("$name","GridFeedInLastMonth", "")." kWh";;\
my $gfily = ReadingsVal("$name","GridFeedInLastYear", "")." kWh";;\
my $sc = ReadingsVal("$name","SelfConsumption", "")." W";;\
my $scd = ReadingsVal("$name","SelfConsumptionDay", "")." kWh";;\
my $scm = ReadingsVal("$name","SelfConsumptionMonth", "")." kWh";;\
my $scy = ReadingsVal("$name","SelfConsumptionYear", "")." kWh";;\
my $scld = ReadingsVal("$name","SelfConsumptionLastDay", "")." kWh";;\
my $sclm = ReadingsVal("$name","SelfConsumptionLastMonth", "")." kWh";;\
my $scly = ReadingsVal("$name","SelfConsumptionLastYear", "")." kWh";;\
my $eb = ReadingsVal("$name","GridConsumption", "")." W";;\
my $ebd = ReadingsVal("$name","GridConsumptionDay", "")." kWh";;\
my $ebm = ReadingsVal("$name","GridConsumptionMonth", "")." kWh";;\
my $eby = ReadingsVal("$name","GridConsumptionYear", "")." kWh";;\
my $ebld = ReadingsVal("$name","GridConsumptionLastDay", "")." kWh";;\
my $eblm = ReadingsVal("$name","GridConsumptionLastMonth", "")." kWh";;\
my $ebly = ReadingsVal("$name","GridConsumptionLastYear", "")." kWh";;\
my $et = sprintf('%.0f',ReadingsVal("$name","TotalConsumption", ""))." W";;\
my $etd = ReadingsVal("$name","TotalConsumptionDay", "")." kWh";;\
my $etm = ReadingsVal("$name","TotalConsumptionMonth", "")." kWh";;\
my $ety = ReadingsVal("$name","TotalConsumptionYear", "")." kWh";;\
my $etld = ReadingsVal("$name","TotalConsumptionLastDay", "")." kWh";;\
my $etlm = ReadingsVal("$name","TotalConsumptionLastMonth", "")." kWh";;\
my $etly = ReadingsVal("$name","TotalConsumptionLastYear", "")." kWh";;\
my $aq = ReadingsVal("$name","AutarkyQuote", "")." %";;\
my $aqd = ReadingsVal("$name","AutarkyQuoteDay", "")." %";;\
my $aqm = ReadingsVal("$name","AutarkyQuoteMonth", "")." %";;\
my $aqy = ReadingsVal("$name","AutarkyQuoteYear", "")." %";;\
my $aqld = ReadingsVal("$name","AutarkyQuoteLastDay", "")." %";;\
my $aqlm = ReadingsVal("$name","AutarkyQuoteLastMonth", "")." %";;\
my $aqly = ReadingsVal("$name","AutarkyQuoteLastYear", "")." %";;\
my $sq = ReadingsVal("$name","SelfConsumptionQuote", "")." %";;\
my $sqd = ReadingsVal("$name","SelfConsumptionQuoteDay", "")." %";;\
my $sqm = ReadingsVal("$name","SelfConsumptionQuoteMonth", "")." %";;\
my $sqy = ReadingsVal("$name","SelfConsumptionQuoteYear", "")." %";;\
my $sqld = ReadingsVal("$name","SelfConsumptionQuoteLastDay", "")." %";;\
my $sqlm = ReadingsVal("$name","SelfConsumptionQuoteLastMonth", "")." %";;\
my $sqly = ReadingsVal("$name","SelfConsumptionQuoteLastYear", "")." %";;\
my $md = ReadingsTimestamp("$name", "TotalConsumption", "");;\
my $cd = ReadingsTimestamp("$name", "AutarkyQuoteDay", "");;\
my $cm = ReadingsTimestamp("$name", "AutarkyQuoteMonth", "");;\
my $cy = ReadingsTimestamp("$name", "AutarkyQuoteYear", "");;\
my $cld = ReadingsTimestamp("$name", "AutarkyQuoteLastDay", "");;\
my $clm = ReadingsTimestamp("$name", "AutarkyQuoteLastMonth", "");;\
my $cly = ReadingsTimestamp("$name", "AutarkyQuoteLastYear", "");;\
my $yieldd = ReadingsVal("$name","YieldDay", "")." €";;\
my $yieldm = ReadingsVal("$name","YieldMonth", "")." €";;\
my $yieldy = ReadingsVal("$name","YieldYear", "")." €";;\
my $savingd = ReadingsVal("$name","SavingDay", "")." €";;\
my $savingm = ReadingsVal("$name","SavingMonth", "")." €";;\
my $savingy = ReadingsVal("$name","SavingYear", "")." €";;\
my $yieldld = ReadingsVal("$name","YieldLastDay", "")." €";;\
my $yieldlm = ReadingsVal("$name","YieldLastMonth", "")." €";;\
my $yieldly = ReadingsVal("$name","YieldLastYear", "")." €";;\
my $savingld = ReadingsVal("$name","SavingLastDay", "")." €";;\
my $savinglm = ReadingsVal("$name","SavingLastMonth", "")." €";;\
my $savingly = ReadingsVal("$name","SavingLastYear", "")." €";;\
"<html><table border=2 bordercolor='lightgrey' cellspacing=0>\
<tr><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'> </td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>aktueller Wert</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Heute</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>gestern</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>dieser Monat</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Vormonat</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>dieses Jahr</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Vorjahr</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>PV-Erzeugung</td><td style='padding-right:5px;;padding-left:5px'>".$pv."</td><td style='padding-right:5px;;padding-left:5px'>".$pvd."</td><td style='padding-right:5px;;padding-left:5px'>".$pvld."</td><td style='padding-right:5px;;padding-left:5px'>".$pvm."</td><td style='padding-right:5px;;padding-left:5px'>".$pvlm."</td><td style='padding-right:5px;;padding-left:5px'>".$pvy."</td><td style='padding-right:5px;;padding-left:5px'>".$pvly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Einspeisung</td><td style='padding-right:5px;;padding-left:5px'>".$gfi."</td><td style='padding-right:5px;;padding-left:5px'>".$gfid."</td><td style='padding-right:5px;;padding-left:5px'>".$gfild."</td><td style='padding-right:5px;;padding-left:5px'>".$gfim."</td><td style='padding-right:5px;;padding-left:5px'>".$gfilm."</td><td style='padding-right:5px;;padding-left:5px'>".$gfiy."</td><td style='padding-right:5px;;padding-left:5px'>".$gfily."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Eigenverbrauch</td><td style='padding-right:5px;;padding-left:5px'>".$sc."</td><td style='padding-right:5px;;padding-left:5px'>".$scd."</td><td style='padding-right:5px;;padding-left:5px'>".$scld."</td><td style='padding-right:5px;;padding-left:5px'>".$scm."</td><<td style='padding-right:5px;;padding-left:5px'>".$sclm."</td><td style='padding-right:5px;;padding-left:5px'>".$scy."</td><td style='padding-right:5px;;padding-left:5px'>".$scly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Bezug</td><td style='padding-right:5px;;padding-left:5px'>".$eb."</td><td style='padding-right:5px;;padding-left:5px'>".$ebd."</td><td style='padding-right:5px;;padding-left:5px'>".$ebld."</td><td style='padding-right:5px;;padding-left:5px'>".$ebm."</td><td style='padding-right:5px;;padding-left:5px'>".$eblm."</td><td style='padding-right:5px;;padding-left:5px'>".$eby."</td><td style='padding-right:5px;;padding-left:5px'>".$ebly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Energieverbrauch</td><td style='padding-right:5px;;padding-left:5px'>".$et."</td><td style='padding-right:5px;;padding-left:5px'>".$etd."</td><td style='padding-right:5px;;padding-left:5px'>".$etld."</td><td style='padding-right:5px;;padding-left:5px'>".$etm."</td><td style='padding-right:5px;;padding-left:5px'>".$etlm."</td><td style='padding-right:5px;;padding-left:5px'>".$ety."</td><td style='padding-right:5px;;padding-left:5px'>".$etly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Autarkiequote</td><td style='padding-right:5px;;padding-left:5px'>".$aq."</td><td style='padding-right:5px;;padding-left:5px'>".$aqd."</td><td style='padding-right:5px;;padding-left:5px'>".$aqld."</td><td style='padding-right:5px;;padding-left:5px'>".$aqm."</td><td style='padding-right:5px;;padding-left:5px'>".$aqlm."</td><td style='padding-right:5px;;padding-left:5px'>".$aqy."</td><td style='padding-right:5px;;padding-left:5px'>".$aqly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Eigenverbrauchsquote</td><td style='padding-right:5px;;padding-left:5px'>".$sq."</td><td style='padding-right:5px;;padding-left:5px'>".$sqd."</td><td style='padding-right:5px;;padding-left:5px'>".$sqld."</td><td style='padding-right:5px;;padding-left:5px'>".$sqm."</td><td style='padding-right:5px;;padding-left:5px'>".$sqlm."</td><td style='padding-right:5px;;padding-left:5px'>".$sqy."</td><td style='padding-right:5px;;padding-left:5px'>".$sqly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Verkauf</td><td style='padding-right:5px;;padding-left:5px'> -- </td><td style='padding-right:5px;;padding-left:5px'>".$yieldd."</td><td style='padding-right:5px;;padding-left:5px'>".$yieldld."</td><td style='padding-right:5px;;padding-left:5px'>".$yieldm."</td><td style='padding-right:5px;;padding-left:5px'>".$yieldlm."</td><td style='padding-right:5px;;padding-left:5px'>".$yieldy."</td><td style='padding-right:5px;;padding-left:5px'>".$yieldly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Einsparung</td><td style='padding-right:5px;;padding-left:5px'> -- </td><td style='padding-right:5px;;padding-left:5px'>".$savingd."</td><td style='padding-right:5px;;padding-left:5px'>".$savingld."</td><td style='padding-right:5px;;padding-left:5px'>".$savingm."</td><td style='padding-right:5px;;padding-left:5px'>".$savinglm."</td><td style='padding-right:5px;;padding-left:5px'>".$savingy."</td><td style='padding-right:5px;;padding-left:5px'>".$savingly."</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Berechnung am</td><td style='padding-right:5px;;padding-left:5px'>".$md."</td><td style='padding-right:5px;;padding-left:5px'>".$cd."</td><td style='padding-right:5px;;padding-left:5px'>".$cld."</td><td style='padding-right:5px;;padding-left:5px'>".$cm."</td><td style='padding-right:5px;;padding-left:5px'>".$clm."</td><td style='padding-right:5px;;padding-left:5px'>".$cy."</td><td style='padding-right:5px;;padding-left:5px'>".$cly."</td></tr>\
</table></html>"\
}
setstate Dum.Energy <html><table border=2 bordercolor='lightgrey' cellspacing=0>\
<tr><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'> </td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>aktueller Wert</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Heute</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>gestern</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>dieser Monat</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Vormonat</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>dieses Jahr</td><td style='padding-right:5px;;padding-left:5px;;font-weight:bold'>Vorjahr</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>PV-Erzeugung</td><td style='padding-right:5px;;padding-left:5px'>90 W</td><td style='padding-right:5px;;padding-left:5px'>7.8 kWh</td><td style='padding-right:5px;;padding-left:5px'>6.2 kWh</td><td style='padding-right:5px;;padding-left:5px'>17.7 kWh</td><td style='padding-right:5px;;padding-left:5px'>626.2 kWh</td><td style='padding-right:5px;;padding-left:5px'>665.2 kWh</td><td style='padding-right:5px;;padding-left:5px'>0 kWh</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Einspeisung</td><td style='padding-right:5px;;padding-left:5px'>0 W</td><td style='padding-right:5px;;padding-left:5px'>1.5 kWh</td><td style='padding-right:5px;;padding-left:5px'>0.7 kWh</td><td style='padding-right:5px;;padding-left:5px'>2.9 kWh</td><td style='padding-right:5px;;padding-left:5px'>348.7 kWh</td><td style='padding-right:5px;;padding-left:5px'>350.0 kWh</td><td style='padding-right:5px;;padding-left:5px'>0 kWh</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Eigenverbrauch</td><td style='padding-right:5px;;padding-left:5px'>90 W</td><td style='padding-right:5px;;padding-left:5px'>6.3 kWh</td><td style='padding-right:5px;;padding-left:5px'>5.5 kWh</td><td style='padding-right:5px;;padding-left:5px'>14.8 kWh</td><<td style='padding-right:5px;;padding-left:5px'>277.5 kWh</td><td style='padding-right:5px;;padding-left:5px'>315.2 kWh</td><td style='padding-right:5px;;padding-left:5px'> kWh</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Bezug</td><td style='padding-right:5px;;padding-left:5px'>480 W</td><td style='padding-right:5px;;padding-left:5px'>18.6 kWh</td><td style='padding-right:5px;;padding-left:5px'>17.7 kWh</td><td style='padding-right:5px;;padding-left:5px'>50.1 kWh</td><td style='padding-right:5px;;padding-left:5px'>311.5 kWh</td><td style='padding-right:5px;;padding-left:5px'>339.4 kWh</td><td style='padding-right:5px;;padding-left:5px'>0 kWh</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Energieverbrauch</td><td style='padding-right:5px;;padding-left:5px'>570 W</td><td style='padding-right:5px;;padding-left:5px'>24.9 kWh</td><td style='padding-right:5px;;padding-left:5px'>23.2 kWh</td><td style='padding-right:5px;;padding-left:5px'>64.9 kWh</td><td style='padding-right:5px;;padding-left:5px'>589.0 kWh</td><td style='padding-right:5px;;padding-left:5px'>654.6 kWh</td><td style='padding-right:5px;;padding-left:5px'> kWh</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Autarkiequote</td><td style='padding-right:5px;;padding-left:5px'>16 %</td><td style='padding-right:5px;;padding-left:5px'>25 %</td><td style='padding-right:5px;;padding-left:5px'>24 %</td><td style='padding-right:5px;;padding-left:5px'>23 %</td><td style='padding-right:5px;;padding-left:5px'>47 %</td><td style='padding-right:5px;;padding-left:5px'>48 %</td><td style='padding-right:5px;;padding-left:5px'> %</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Eigenverbrauchsquote</td><td style='padding-right:5px;;padding-left:5px'>100 %</td><td style='padding-right:5px;;padding-left:5px'>81 %</td><td style='padding-right:5px;;padding-left:5px'>89 %</td><td style='padding-right:5px;;padding-left:5px'>84 %</td><td style='padding-right:5px;;padding-left:5px'>44 %</td><td style='padding-right:5px;;padding-left:5px'>47 %</td><td style='padding-right:5px;;padding-left:5px'> %</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Verkauf</td><td style='padding-right:5px;;padding-left:5px'> -- </td><td style='padding-right:5px;;padding-left:5px'>0.08 €</td><td style='padding-right:5px;;padding-left:5px'>0.03 €</td><td style='padding-right:5px;;padding-left:5px'>0.14 €</td><td style='padding-right:5px;;padding-left:5px'>17.43 €</td><td style='padding-right:5px;;padding-left:5px'>17.50 €</td><td style='padding-right:5px;;padding-left:5px'>0.00 €</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Einsparung</td><td style='padding-right:5px;;padding-left:5px'> -- </td><td style='padding-right:5px;;padding-left:5px'>1.10 €</td><td style='padding-right:5px;;padding-left:5px'>0.96 €</td><td style='padding-right:5px;;padding-left:5px'>2.59 €</td><td style='padding-right:5px;;padding-left:5px'>48.56 €</td><td style='padding-right:5px;;padding-left:5px'>55.16 €</td><td style='padding-right:5px;;padding-left:5px'>0.00 €</td></tr>\
<tr><td style='padding-right:5px;;padding-left:5px;;text-align:left;;font-weight:bold'>Berechnung am</td><td style='padding-right:5px;;padding-left:5px'>2022-04-03 18:24:56</td><td style='padding-right:5px;;padding-left:5px'>2022-04-03 18:20:09</td><td style='padding-right:5px;;padding-left:5px'>2022-04-03 00:10:01</td><td style='padding-right:5px;;padding-left:5px'>2022-04-03 17:55:09</td><td style='padding-right:5px;;padding-left:5px'>2022-04-01 00:13:08</td><td style='padding-right:5px;;padding-left:5px'>2022-04-02 20:15:09</td><td style='padding-right:5px;;padding-left:5px'></td></tr>\
</table></html>
ATs zum Berechnen der Quoten:
defmod recalc_Dum.Energy.Quoten.Jahr at *20:15:00 {fhem ("set Rep.WR.Erzeugung.Jahr diffValue") }
attr recalc_Dum.Energy.Quoten.Jahr disable 0
attr recalc_Dum.Energy.Quoten.Jahr room GH->PV
defmod recalc_Dum.Energy.Quoten.Monat at +*00:35:00 {fhem ("set Rep.WR.Erzeugung.Monat diffValue") }
attr recalc_Dum.Energy.Quoten.Monat disable 0
attr recalc_Dum.Energy.Quoten.Monat room GH->PV
defmod recalc_Dum.Energy.Quoten.Vorjahr at *00:15:00 {if($month == 1 && $mday == 1){fhem ("set Rep.WR.Erzeugung.Vorjahr diffValue")}}
attr recalc_Dum.Energy.Quoten.Vorjahr disable 0
attr recalc_Dum.Energy.Quoten.Vorjahr room GH->PV
defmod recalc_Dum.Energy.Quoten.Vormonat at *00:13:00 {if ($mday==1){fhem ("set Rep.WR.Erzeugung.Vormonat diffValue")}}
attr recalc_Dum.Energy.Quoten.Vormonat disable 0
attr recalc_Dum.Energy.Quoten.Vormonat room GH->PV
defmod recalc_Dum.Energy.Quoten.gestern at *00:10:00 {fhem ("set Rep.WR.Erzeugung.gestern diffValue") }
attr recalc_Dum.Energy.Quoten.gestern disable 0
attr recalc_Dum.Energy.Quoten.gestern room GH->PV
defmod recalc_Dum.Energy.Quoten.heute at +*00:10:00 {fhem ("set Rep.WR.Erzeugung.heute diffValue") }
attr recalc_Dum.Energy.Quoten.heute disable 0
attr recalc_Dum.Energy.Quoten.heute room GH->PV
Und hier noch die Notifys:
defmod N.CalcNetEnergy notify PowerMeter:Power_Sum__W.* {calcNetEnergy("PowerMeter")}
attr N.CalcNetEnergy room GH->PV
defmod N.GridConsumption.Dum.Energy notify Strom_Import:PowerMeter_Energy_Net_import__kWh_PowerCurrent:.* { fhem "setreading Dum.Energy GridConsumption ".sprintf("%.0f",$EVTPART1)}
attr N.GridConsumption.Dum.Energy room GH->PV
defmod N.GridFeedIn.Dum.Energy notify Strom_Export:PowerMeter_Energy_Net_export__kWh_PowerCurrent:.* { fhem "setreading Dum.Energy GridFeedIn ".sprintf("%.0f",$EVTPART1)}
attr N.GridFeedIn.Dum.Energy room GH->PV
defmod N.PV.TotalConsumption.Dum.Energy notify PowerMeter:(Energy_Net_export__kWh|Energy_Net_import__kWh).* {\
# Energieverbrauch\
if(ReadingsAge("WR","Inverter_Cumulation_PAC_Value",0) < 130){\
fhem "setreading Dum.Energy PV ".sprintf("%.0f",(ReadingsVal("WR","Inverter_Cumulation_PAC_Value",0)));;\
}else{\
fhem("setreading Dum.Energy PV 0");;\
}\
my $tc = sprintf("%.0f",ReadingsVal("Dum.Energy","PV",0)+ReadingsVal("Dum.Energy","GridConsumption",0)-ReadingsVal("Dum.Energy","GridFeedIn",0));;\
if($tc >= 0) {\
fhem ("setreading Dum.Energy TotalConsumption ".sprintf("%.0f",$tc));;\
}\
# Eigenverbrauch\
if(ReadingsAge("WR","Inverter_Cumulation_PAC_Value",0) < 130){\
my $sc = sprintf("%.0f",ReadingsVal("WR","Inverter_Cumulation_PAC_Value",0)-ReadingsVal("Dum.Energy","GridFeedIn",0));;\
if($sc >= 0) {\
fhem ("setreading Dum.Energy SelfConsumption ".sprintf("%.0f",$sc));;\
}\
}else{\
fhem ("setreading Dum.Energy SelfConsumption 0");;\
}\
# Autarkiegrad\
my $valA = (ReadingsVal("WR", "Inverter_Cumulation_PAC_Value",0))-ReadingsVal("Strom_Export", "PowerMeter_Energy_Net_export__kWh_PowerCurrent",0);;\
my $calcVal = 0;;\
if($valA + ReadingsVal("Strom_Import", "PowerMeter_Energy_Net_import__kWh_PowerCurrent",0) != 0){\
$calcVal = $valA / ($valA + ReadingsVal("Strom_Import", "PowerMeter_Energy_Net_import__kWh_PowerCurrent",0))*100;;\
}\
if(ReadingsAge("WR","Inverter_Cumulation_PAC_Value",0) > 65){\
$calcVal = 0;;\
}\
fhem ("setreading Dum.Energy AutarkyQuote ".($calcVal?sprintf("%.0f",$calcVal):"0"));;\
# Eigenverbrauchsquote\
my $totalpac = 0;;\
if(ReadingsAge("WR","Inverter_Cumulation_PAC_Value",0) < 65){\
$totalpac = ReadingsVal("WR", "Inverter_Cumulation_PAC_Value",0)\
}\
if($totalpac > 0) {\
my $valSelf = $totalpac - ReadingsVal("Strom_Export", "PowerMeter_Energy_Net_export__kWh_PowerCurrent",0);;\
my $calSelf = $valSelf / $totalpac * 100;;\
fhem ("setreading Dum.Energy SelfConsumptionQuote ".sprintf("%.0f",$calSelf));;\
} else {\
fhem ("setreading Dum.Energy SelfConsumptionQuote -");;\
}\
\
}
attr N.PV.TotalConsumption.Dum.Energy room GH->PV