core icon indicating copy to clipboard operation
core copied to clipboard

Unit of measurements is not correct

Open cloudbr34k84 opened this issue 1 year ago • 9 comments

The problem

Unit of measurements is not correct Unit of measurements °C, °C, °C of input sensors sensor.izone_current_temperature_upstairs, sensor.ble_temperature_upstairs_lounge_ble_climate, sensor.upstairs_climate_display_temperature are not compatible using no device class of sensor group sensor.upstairs_lounge_average_temperature.

Unit of measurements L, L of input sensors sensor.beergarden_garden_tap_total_water_no_cycle_metered, sensor.frontyard_right_side_garden_tap_water_no_cycle_metered are not compatible using no device class of sensor group sensor.total_garden_taps_water_no_cycle_metered.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

What version of Home Assistant Core has the issue?

2024.2.0

What was the last working version of Home Assistant Core?

2024.1.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Groups

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

cloudbr34k84 avatar Feb 08 '24 09:02 cloudbr34k84

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (group) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of group can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign group Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


group documentation group source (message by IssueLinks)

home-assistant[bot] avatar Feb 08 '24 09:02 home-assistant[bot]

Occuring, when unit of measurement is defined in the parent sensors and no device_class is available (for example µSv/h for radiation). Unit of measurement is not carried over from parent sensors (all the same unit) to the helper anymore. When using the old "Combine the state of several sensors" helper, the error message does not appear and the unit of measurement is carried over from the parent sensors to the helper.

jorgwolski avatar Feb 08 '24 10:02 jorgwolski

Experiencing a similar problem with a different warning in the form of

WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.indoor_temperature (<class 'homeassistant.components.group.sensor.SensorGroup'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('temperature') it is using; expected one of ['°F', 'K', '°C'];

So in my case it appears the device_class was maintained but the units of measurement were lost.

~I found that removing and re-adding a group member caused the unit of measurement to be set again.~ Only helped until HA reboots.

mill1000 avatar Feb 08 '24 15:02 mill1000

Seeing the same error for my cover. I have a sensor how much they are open/closed in % but there is no device class for that.

StefanDorschu avatar Feb 08 '24 19:02 StefanDorschu

I did a hard reboot of HA and I think that fixed it, try that everyone

cloudbr34k84 avatar Feb 08 '24 19:02 cloudbr34k84

Nothing changed after rebooting.

StefanDorschu avatar Feb 08 '24 20:02 StefanDorschu

See @mill1000 and what he did

cloudbr34k84 avatar Feb 08 '24 20:02 cloudbr34k84

Negative. Reboot and group re-creation didn't change anything.

jorgwolski avatar Feb 08 '24 20:02 jorgwolski

Same issue here. I got four different warnings with variations on this, but I was able to fix two by adding a device class for some MQTT temperature sensors in my YAML. It did require a full reboot for them to "take" and the warning to disappear. Still working on the other two.

ultrathew avatar Feb 08 '24 21:02 ultrathew

Issue still present in core 2024.2.1

jorgwolski avatar Feb 09 '24 12:02 jorgwolski

Same issue here with grouping multiple solar panels, all delivering in 'W'

....not compatible using no device class of sensor group sensor.enphase_garage_power_total.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

I cannot set a device class on the group, the choice I have is 'sensor-group' but not more specific. First seen in 2024.2.0 and indeed still present in 2024.2.1

pvmil avatar Feb 09 '24 14:02 pvmil

same here: I have a helper sensor.zonenergietotaal; both have a unit_of_measurement: kW the helper gives a total so what is the problem? the helper self has no unit_of_measurement

Unit of measurements is not correct Unit of measurements kW, kW of input sensors sensor.solaredge_current_power_kw, sensor.envoy_121144087692_current_power_production are not compatible using no device class of sensor group sensor.zonenergietotaal

sensor.solaredge_current_power_kw: unit_of_measurement: kW friendly_name: solaredge_current_power_kW

sensor.envoy_121144087692_current_power_production: state_class: measurement unit_of_measurement: kW device_class: power icon: mdi:flash friendly_name: Envoy 121144087692 Current power production

pkleingu avatar Feb 09 '24 16:02 pkleingu

I'm having the same issue with multiple Enphase Envoy solar meters.

Unit of measurements W, W, W of input sensors sensor.envoy_202220107059_current_power_production, sensor.envoy_202317171048_current_power_production, sensor.envoy_202328056209_current_power_production are not compatible using no device class of sensor group sensor.solar_current_power_production.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

This is a regression in 2024.2.0 and unchanged in 2024.2.1 .

madbrain76 avatar Feb 09 '24 20:02 madbrain76

Same here. Unfortunately there's no such device class like valve...

Unit of measurements %, %, %, %, %, %, %, % of input sensors sensor.knx_heizung_status_stellventil_bad, sensor.knx_heizung_status_stellventil_buero, sensor.knx_heizung_status_stellventil_flur, sensor.knx_heizung_status_stellventil_kinderzimmer_hinten, sensor.knx_heizung_status_stellventil_kueche, sensor.knx_heizung_status_stellventil_wohnbereich, sensor.knx_heizung_status_stellventil_kinderzimmer_vorne, sensor.knx_heizung_status_stellventil_schlafzimmer are not compatible using no device class of sensor group sensor.stellventile_fussbodenheizung_1og.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

Alex-joomla avatar Feb 10 '24 07:02 Alex-joomla

Similar here for yahoo finance hacs integration:

Unit of measurements USD, GBP, USD, GBP, GBP, GBP of input sensors sensor.yahoofinance_, sensor.yahoofinance_c_l, Sensor.yahoofinance_a, sensor.yahoofinance_f_l, sensor.yahoofinance_h_, sensor.yahoofinance_i_l are not compatible using no device class of sensor group sensor.commodities.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

I have redacted the ticker symbol name for privacy

limitless-code avatar Feb 12 '24 11:02 limitless-code

Same with me updated to 2024.3:

Unit of measurements °C, °C, °C, °C, °C, °C, °C, °C of input sensors sensor.temp_e, sensor.temp_j, sensor.temp_s, sensor.temp_office, sensor.temp_n, sensor.temp_master, sensor.atc_d49b84_temperature, sensor.temp_media are not compatible using no device class of sensor group sensor.tempindoor.

Please correct the unit of measurements on the source entities or set a proper device class on the sensor group and reload the group sensor to fix this issue.

If we could add the unit of measurement to the group that would be handy.

mong00se007 avatar Feb 14 '24 02:02 mong00se007

Same issue here.

Since there wasn't an option to set the device class in the UI on the Group sensor, I attempted to set the device_class to power using yaml customize (Envoy current power production sensors like madbrain76). This does not seem to have done anything, unless perhaps I did it wrong.

Aurifier avatar Feb 14 '24 20:02 Aurifier

same here. all entities have unit "W" which is now lost and even if I try to add it via customize.yaml to the helper sensor it is not added

marc4s avatar Feb 16 '24 07:02 marc4s

Oh man I was going to try that next :(

Aurifier avatar Feb 16 '24 12:02 Aurifier

If the parent sensors have a unit of measurement but no device class, you can use the "Combine the state of several sensors" helper. That one keeps the unit of measurement of the parent sensors (if they are all identical) and causes no errors at moment.

jorgwolski avatar Feb 17 '24 11:02 jorgwolski

Saw https://github.com/home-assistant/core/pull/110181 in the recent release and I was hopeful, ~but it doesn’t seem to have done anything~

Actually my Home Assistant crashed during the update and I didn't notice; I still have not been able to take the update. Was hoping to help test this, but won't be able to until I migrate HA to a new box during the week of 2024-02-26.

@PoppyPop folks with other-than-Enphase sensors are having the same issue. Hopefully that helps them (me as well, thank you!), but there’s definitely a regression in the Group sensor that should be addressed too.

Aurifier avatar Feb 18 '24 17:02 Aurifier

Hello, to be honest, i first tried to correct the goup sensor, i potentially identified the source of the regression.

It seem's that it does not handle correcly sensor with missing device_class, but for the moment i don't have any clues for a good fix. (so fixing the source was easier and the fastest solution in my case).

i don't have time today to check, but wil make a second try tomorow.

PoppyPop avatar Feb 18 '24 20:02 PoppyPop

Not sure how to understand that: "Source" as in source of the problem or source code? If you were able to update the sensor with a device_class, could you pls tell us how you did that? I have not been able to find such a setting. Thx /F

friendlycrow avatar Feb 19 '24 11:02 friendlycrow

I don't added a device_class, i choose to make a pull request for an intégration that i use, because it was easier to fix.

@gjohansson-ST you added this commit, can you provide a bit more explanation the bug you would fix ? it seem's that if one sensor in the group has no device_class, it break the unit of measurement.

if the device_class is None, we don't need to control for converters of Units, because it will always return no Units.

Here is a minimal sample to reproduce the error :

template:
  - sensor:
      - name: "sensor without class"
        unit_of_measurement: "W"
        state: 53

sensor:
  - platform: group
    type: last
    entities:
      - sensor.sensor_without_class

PoppyPop avatar Feb 19 '24 16:02 PoppyPop

Actually the repair is a bit misleading I see now reading it again. Unless you manually configure a unit_of_measurement on your group sensor it will not populate a UoM unless you also have a device class set ( which you can only do in YAML, not from the UI ).

So it's behaving as it's supposed to but again, not being clear on the description of the repair issue.

Anyway we should probably allow to have a calculated UoM if all UoM's on the source entities are the same when not having any device class.

gjohansson-ST avatar Feb 21 '24 11:02 gjohansson-ST