thanks for the answer I calculated it in that way:
val Number TotalPower = (inverter1ActivePower.state as DecimalType
+ inverter2PreBatDischarge.state as DecimalType
+ inverter1PowerDrawn.state as DecimalType
- inverter2PreBatCharge.state as DecimalType
- inverter1PowerGridFeedIn.state as DecimalType)
if ( TotalPower >= 0 ) {
TotalPowerConsumption.postUpdate(TotalPower)
}
But I will try your solution, too