ha-average icon indicating copy to clipboard operation
ha-average copied to clipboard

Unit of measurement lost when "stacking" average sensors

Open StefanDorschu opened this issue 2 years ago • 5 comments

Describe the bug

I'm using this sensor to average my temperatures. E.g. i have several sensors in my living room which are averaged to a single value. This value (sensor) is used as an input to calculate (average again) the temperature of the first floor. When i do so, the sensor of the averaged temp in the first floor has no unit of measurement.

Configuration.yaml

- platform: average
  name: "Wohnzimmer - Temperatur"
  unique_id: "wohnzimmer_temperatur"
  precision: 0
  entities:
    - sensor.wohnzimmer_sensor_glastaster_flugeltur_temperatur
    - sensor.wohnzimmer_sensor_glastaster_linke_hebeschiebeanlage_temperatur
    - sensor.wohnzimmer_sensor_glastaster_eingangstur_temperatur

- platform: average
  name: "Allgemein.Wohnräume.Erdgeschoss - Temperatur"
  unique_id: "allgemein_wohnraume_erdgeschoss_temperatur"
  precision: 1
  entities:
    - sensor.flur_eingang_temperatur
    - sensor.flur_technik_temperatur
    - sensor.kuche_temperatur
    - sensor.waschkuche_temperatur
    - sensor.alte_kuche_temperatur
    - sensor.wohnzimmer_temperatur

Expected behavior

Keep the unit of measurement.

StefanDorschu avatar Jun 19 '22 10:06 StefanDorschu

I could not repeat your bug: everything works correctly with your config. Tested on the latest version of HA.

Screenshot2

Please check that your source sensors are working correctly. Perhaps, to identify the cause of the error, the enabled debugging mode is useful: https://github.com/Limych/ha-average#troubleshooting

If you find an error in my code, please post logs with this error here.

Limych avatar Jun 19 '22 14:06 Limych

Thanks for your quick reply. I activated the logs and see some "strange" behaviour.

Here and there i get the "error" that some value is not a temperature although the sensors are temperature sensors. Bildschirmfoto 2022-06-20 um 05 52 51 Bildschirmfoto 2022-06-20 um 05 56 21

Bildschirmfoto 2022-06-20 um 05 53 07 Bildschirmfoto 2022-06-20 um 05 55 57

Beside that i have no clue whats wrong (everything is updated to the newest versions).

StefanDorschu avatar Jun 20 '22 03:06 StefanDorschu

For me it gets lost even without any stacking.

I have a value coming from node-red with unit EUR/MWh, and then randomly the EUR/MWh unit is lost. Then to restore this, I have to erase the history for the whole entity, only then does the unit come back.

This happens after every restart of HA. Seems like if there is even one value where it receives "0" or "unavailable" then the unit is just deleted.

How about just adding a setting to the sensor where it is possible to specify the unit??? Every other sensor has this possibility but not this one.

Anyway, for now I am doing the average calculation in Node RED, so that I can specify the units.

prj avatar Jul 07 '22 10:07 prj

@ Limych Any ideas?

StefanDorschu avatar Jul 13 '22 15:07 StefanDorschu