Blockly or script - how to get sum of item since now to date

Here’s how to do it using JRuby. You can do this using GUI rule or define the triggers in a file based rule. If you are using openhab 3.2 you’ll need to add require 'openhab' at the top.

require 'openhab' # this line is not needed on openhab 3.3

start_date = Time.new(2022, 01, 01) # You could also use ZonedDateTime if you prefer
Gesverbr1.update Verbr.sum_since(start_date)
Gesamteinspeisung.update Einsp.sum_since(start_date)

This will use your default persistence service. If you have multiple persistence services installed and want to specify the one that isn’t the default or want to be sure regardless of what the default is, just add the service name at the end, e.g.

Verbr.sum_since(start_date, 'jdbc') 

I noticed your persistence setting is everyChange. You might want to use everyUpdate for the relevant items?

You can also force the item to write to persistence by calling Gesverbr1.persist

Example:

require 'openhab' # this line is not needed on openhab 3.3

start_date = Time.new(2022, 01, 01) # You could also use ZonedDateTime if you prefer
Gesverbr1.update Verbr.sum_since(start_date)
Gesamteinspeisung.update Einsp.sum_since(start_date)

Gesverbr1.persist
Gesamteinspeisung.persist