Openhab Shelly 3EM calculate the Power consumption balanced "saldierend"

Hi!
I need a little help.
I would like to calculate the electricity consumption balanced from the values of the Shelly 3EM.
I would like the energy consumption as billed by the energy supplier.
I hope this is understandable?!
In German we say “saldierend”

I found the Solution

Can you post the code? I’m facing the same problem!

It is more than a code…and it is a little complicated…
Bute the answer is here:
https://community.openhab.org/t/blockly-or-script-how-to-get-sum-of-item-since-now-to-date/134217/27

First you need 10 Items:

You must change your persistence service to JDBC.
Then make a file for JDBC:
jdbc.persist:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
   	everyDay    : "0 0 0 * * ?"
   	default = everyChange
}
 
Items {

    Shelly3EMSHEM3_KumulierterVerbrauch : strategy = everyChange, everyMinute, everyDay, restoreOnStartup
    Minute_Einspeisung : strategy = everyChange, restoreOnStartup
    Minute_Verbrauch : strategy = everyChange, restoreOnStartup
    Minute_Ges_Einspeisung : strategy = everyChange, restoreOnStartup
    Minute_Ges_Verbrauch : strategy = everyChange, restoreOnStartup
    Minute_Tageseinspeisung : strategy = everyChange, restoreOnStartup
    Minute_Tagesverbrauch1 : strategy = everyChange, restoreOnStartup

    Stromkosten_Summe : strategy = everyChange, restoreOnStartup
    Stromkosten_Tag : strategy = everyChange, restoreOnStartup

    Einspeisung_Summe : strategy = everyChange, restoreOnStartup
    Einspeisung_Tag : strategy = everyChange, restoreOnStartup```
}

Make 1.Rule:

rule "Strom & Einspeisung"
when
Item Shelly3EMSHEM3_KumulierterGesamtverbrauch received update
then
Stromkosten_Tag.postUpdate(Minute_Tagesverbrauch1.state as DecimalType * 0.28)
Stromkosten_Summe.postUpdate(Minute_Ges_Verbrauch.state as DecimalType * 0.28)
Einspeisung_Tag.postUpdate(Minute_Tageseinspeisung.state as DecimalType * 0.044)
Einspeisung_Summe.postUpdate(Minute_Ges_Einspeisung.state as DecimalType * 0.044)
end

Make 2.Rule:

home.sitemap:

Frame label="Verbrauch & Einspeisung" {  
   	Text label="Übersicht" icon="energy" {
    Frame label="Verbrauch & Einspeisung" {         
    Text item=Minute_Ges_Verbrauch label="Gesamtverbrauch ab 01.08.2021 [%.3f KWH]" icon="boese" 
	Text item=Stromkosten_Summe icon="money_red"
	Text item=Minute_Tagesverbrauch1 label="Verbrauch heute [%.3f KWH]" icon="boese" 
	Text item=Stromkosten_Tag icon="money_red"
	Text item=Minute_Ges_Einspeisung label="Gesamteinspeisung ab 01.08.2021 [%.3f KWH]" icon="smiley" 
	Text item=Einspeisung_Summe icon="money"
	Text item=Minute_Tageseinspeisung label="Einspeisung heute [%.3f KWH]" icon="smiley" 
	Text item=Einspeisung_Tag icon="money"
}}

Then it look like this:

Thanks!