core icon indicating copy to clipboard operation
core copied to clipboard

device class "humidity" does not accept absolute humidity unit g/m3

Open schoppfe opened this issue 4 months ago • 0 comments

The problem

I get a warning for the definition of unit_of_measurement: ‘g/m³’ for a device of class humidity. Since humidity can be measured not only relatively but also absolutely, I would like to see ‘g/m³’ added to the valid units for humidity.

What version of Home Assistant Core has the issue?

core-2024.10.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

Entity sensor.absolute_luftfeuchtigkeit (<class 'homeassistant.components.template.sensor.SensorTemplate'>) is using native unit of measurement 'g/m³' which is not a valid unit for the device class ('humidity') it is using; expected one of ['%']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22

Example YAML snippet

- name: "abs. humidity"
    unique_id: weather_forecast_home_abs_humidity
    unit_of_measurement: "g/m³"
    state_class: measurement
    device_class: humidity
    state: >
      {% set temp = state_attr('weather.forecast_home', 'temperature') %}
      {% set rel_hum = state_attr('weather.forecast_home', 'humidity') %}
      {% set abs_humidity = (6.112 * e ** (17.67 * temp / (temp + 243.5)) * rel_hum * 2.1674) / (273.15 + temp) %}
      {{ abs_humidity | round(2) }}

Anything in the logs that might be useful for us?

No response

Additional information

No response

schoppfe avatar Oct 05 '24 05:10 schoppfe