OH3 rules calculation Engergy

I thought the following was working but the the assignment below is not working. What is wrong?

Number:Energy               ElectraAbsoluutPerJaar           "Absoluut per jaar [%.3f kWh]" 

The value shown when I hoover is 238.173 kWh
I want to set the value to 0 but the following is not processed but also doesn’t generate a error.

 ElectraAbsoluutPerJaar.postUpdate (0 | kWh)

If you change names of items how is this managed in the default rrd4j database. Are items removed or left in the database? And what if you then create a item with the same name after for instance a day later? I assume my problems has somehow to do with this because I created a new item what had as default value NULL and with the same code I could set it to zero.

No. All the database knows is that data has stopped coming from the old
Item. Some new Item might have appeared but of course it cannot know that’s supposed to be a replacement.

It just appends new data to the old dataset.

You’ve given us no idea why it should show that, or anything else. Is this Item perhaps linked to some device, or being updated by a rule?

Maybe I’m doing something wrong in the sequence.
If I’m correct the default rrdj4 is restoring all items after restarting OH3.2.0.M4.
How is the full sequence?
If have in all rules files a system started rule like the one below to initiate the values after creation

 if ( ElectraAbsoluutPerDag.state == NULL) { ElectraAbsoluutPerDag.postUpdate (0 | kWh)}

So the question is.

  1. When is the system started rule processed?
  2. When is that value stored in rrd4j?
  3. When is the last value of ElectraAbsoluutPerDag restored from rrd4j?

All that it can, some exotic Item types are not stored by rrd4j.

There is a small catch with Quantity types, numbers-with-units. The units are not stored, so rrd4j has to reconstruct the unit by guesswork. It looks at the default unit for each Item. Some types - temperature - have system default types as a fallback. Some types - energy - do not. So the only place rrd4j can find a default is by looking at Item metadata ‘pattern’.

That’s the equivalent of the [%.3f kWh] part in your Item definition. I think that should still work with file-defined Items.

All this normally happens before any rules are run.
If you think you have a problem, find out.

if ( ElectraAbsoluutPerDag.state == NULL) { 
   logInfo("test", "My Item is null")
   ElectraAbsoluutPerDag.postUpdate (0 | kWh)

All files? If they all do the same thing you are setting up a horse-race.

I tested this and the above statement is true after a restart of OH 3.
What is the reason behind this.
Can it be changed that always restoreOnStartup is 100% processed before any rules are processed?

I did the same test in another small rules file and that value was restored before the system started rule was processed. So it is partial working what makes it unpredictable.

If it were easily possible to ensure that, it would have been done years ago.

Is your Item ever restored at all?

None of this has anything to do with not being able to postUpdate(). Is that working now?

Nothing to do!