Limych / ha-average

Average Sensor for Home Assistant
Other
362 stars 30 forks source link

Unit of measurement lost when "stacking" average sensors #143

Open StefanDorschu opened 2 years ago

StefanDorschu commented 2 years ago

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.

Limych commented 2 years ago

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.

StefanDorschu commented 2 years ago

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).

prj commented 2 years ago

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.

StefanDorschu commented 2 years ago

@ Limych Any ideas?

resain commented 1 month ago

This issue appears to has reappeared in the latest release (assuming it was ever fixed?) Any work around's? The unit of sensor.average_daily_temperature (None) cannot be converted to the unit of previously compiled statistics (°C)

Update: looks like this could have been an issue for some time and its only on updating to HA 2024.10 that the repair prompt was raised.