[SOLVED] Cast error during iteration

Probably because either one or more of the members is not a NumberItem or one or more of the Item’s states are NULL or UNDEF which cannot be cast to DecimalType.

Why not use the stream functions? The work better in almost all cases. See Design Pattern: Working with Groups in Rules. In particular you want filter, map, and reduce.

val sum = group_house_totalenergy.members.filter[ n | n.state instanceof Number ].map[state as Number].reduce[ sum, n | sum = sum + n ]