Wrong group average with Number:Temperature

Hi Community.

I’ll start with Platform information:

  • Hardware: Raspberry Pi 3
  • OS: Openhabian on Raspbian 10
  • Java Runtime Environment: openJDK 11
  • openHAB version: 3.3.0 release

I’m having a strange issue with Averages for temperatues not being calculated correctly in some cases. My setup is as follows:

  • 2 Max! Thermostats, 2 Items for the SET_TEMPERATURE channels of both called thermostat1_SetTemperature and thermostat2_SetTemperature respectively; type is set to Number:Temperature
  • a group wohnzimmer_thermostate_wunschtemperatur containing both items with Member Base Type set to Number:Temperature and group function to AVG

Please see the following log-output when I change the SetTemperatures on the thermostats by sending a command with the target temperature to the group item:

// command gets sent to both items when sending the command to the group
2022-12-06 16:31:37.241 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'thermostat2_SetTemperature' received command 19.5 °C
2022-12-06 16:31:37.249 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'thermostat1_SetTemperature' received command 19.5 °C

// expected value of both SetTemperatures is 19.5 °C
2022-12-06 16:31:37.289 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'thermostat2_SetTemperature' predicted to become 19.5 °C
2022-12-06 16:31:37.316 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'thermostat1_SetTemperature' predicted to become 19.5 °C

// the change happens for the first of both Thermostats
2022-12-06 16:31:37.351 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'thermostat2_SetTemperature' changed from 19 °C to 19.5 °C

// group average gets correctly updated to (19 °C + 19.5°C) / 2 (rounded to one decimal place for some reason)
2022-12-06 16:31:37.355 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'wohnzimmer_thermostate_wunschtemperatur' changed from 19 °C to 19.3 °C through thermostat2_SetTemperature

// second change happens
2022-12-06 16:31:37.359 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'thermostat1_SetTemperature' changed from 19 °C to 19.5 °C

// HERE IS THE ISSUE
// both items have a value of 19.5 °C now - but the average is 20 °C for some reason
2022-12-06 16:31:37.407 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'wohnzimmer_thermostate_wunschtemperatur' changed from 19.3 °C to 20 °C through thermostat1_SetTemperature

// here I'm going back to 19 °C and the group average is correctly at 19 °C afterwards
2022-12-06 16:31:38.467 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'thermostat1_SetTemperature' changed from 19.5 °C to 19 °C
2022-12-06 16:31:38.476 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'wohnzimmer_thermostate_wunschtemperatur' changed from 20 °C to 19.3 °C through thermostat1_SetTemperature
2022-12-06 16:31:39.768 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'thermostat2_SetTemperature' changed from 19.5 °C to 19 °C
2022-12-06 16:31:39.776 [INFO ] [hab.event.GroupItemStateChangedEvent] - Item 'wohnzimmer_thermostate_wunschtemperatur' changed from 19.3 °C to 19 °C through thermostat2_SetTemperature

I read through a lot of stuff regarding dimensions and types and so on, but all values seem to be correct and the SetTemperature shown on the display of the Thermostats is also correct. I don’t know where to look next.

Thanks for any help or hints you may have.
Steffen

I would first double-check that your Group has only the members that you expect (I think API Explorer can tell you this).

If that is okay, it is possible the Group aggregation functions are not working correctly - there have been some minor changes in this area I believe and/or in Quantity (units) maths.

I’m suspecting a rounding issue

That doesn’t look correct to me either - wouldn’t we expect 19.25? The events.log should be reporting actual state, not formatted with places.

I wonder if the unexpected 20 is likewise 19.5 rounded up.

I suggest logging a Github issue against OH core, with your clear example.

FTR: Fixed in Fix AVG calculation in GroupFunction by J-N-K · Pull Request #3202 · openhab/openhab-core · GitHub

3 Likes

Thanks to both of you for the quick reply and for fixing the issue in the repo before I could even file an issue.