Initializing Items

Hello all.

Im having some problems with items and their initialization.
I have some items that show numerical values result of some calculation, if I first initialize them to 0 they work, otherwise it stays as null.

The following code never works unless i do before postUpdate(PowerConsMonthCheio,0)

aux=(PowerAccuCheio.state as DecimalType).intValue() + (PowerConsMonthCheio.state as DecimalType).intValue()
postUpdate(PowerConsMonthCheio,aux) 

To try to solve things I have put in a rule that runs at startup

if (PowerConsMonthCheio == null) postUpdate(PowerAccuCheio,0)

But PowerAccuCheio is not updated to 0

Can you help me?
Tnaks

Sorry, some copy past errors
In the above text I posted

if (PowerConsMonthCheio == null) postUpdate(PowerAccuCheio,0)

it showld be

if (PowerConsMonthCheio == null) postUpdate(PowerConsMonthCheio 
,0)

... sorry

Items in rules should never be null. They might be Uninitialized (OH1) or NULL (OH2), which is shorthand for UnDefType.NULL. They can also be Undefined (OH1) or UNDEF (OH2), which is shorthand for UnDefType.UNDEF.

@watou: Can you please explain the difference between NULL (OH2) and UNDEF (OH2)? When can/will an item have this “value”? (I presume we are talking about the value of the item and not the state, right?).

There’s current discussion of this subject here. I think items on startup are initially Uninitialized, but then bindings, persistence restoreOnStartup, rules or the REST API will start posting new states to them after that. I believe Undefined means “I know that the source of this value reports that the value is unknown.” But follow the referenced thread for the latest!

I guess I use those terms interchangeably to refer to the state of the item.