How to calculate averagesince without NULL values

I added this for reasons like these.

You can just loop through and do your own calculation, filtering the null as you go.

I’m not familiar with jsscripting but to illustrate, this how it would be done in jruby:

states = waermepumpe_cop.all_states_since(24.hours.ago)
                        .reject { |history| history.state.is_a?(UnDefType) }
                        .map(&:state)
zero = QuantityType.new(0, waermepumpe_cop.unit)
average = states.sum(zero) / states.size
logger.info average