home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.11k stars 29.79k forks source link

Unit for the device class 'volatile_organic_compounds_parts' #102387

Closed kbabioch closed 7 months ago

kbabioch commented 10 months ago

The problem

I'm getting errors in my logs for sensor entities from my presence detector, which I cannot address with modifications to the configuration.

The configuration itself looks something like this:

knx:
  sensor:
    - name: "OG-Z1-PM1 VOC"
      state_address: "4/3/14"
      type: 2byte_float
      sync_state: expire 300
      device_class: volatile_organic_compounds_parts
      state_class: measurement

The sensor returns a (custom) 2 byte float value, which represents "parts per billion" in terms of VOC / air quality.

The value itself is read correctly and can be processed within Home Assistant. However there is no unit set. In the logs of Home Assistant I'm getting the following error logged (several times):

Entity sensor.og_z1_pm1_voc (<class 'homeassistant.components.knx.sensor.KNXSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('volatile_organic_compounds_parts') it is using; expected one of ['ppb', 'ppm']; 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+knx%22

According to the developer documentation of the Sensor Entity the device class should be VOLATILE_ORGANIC_COMPOUNDS_PARTS and the unit for this device class is either ppm or ppb.

However I'm not able to set this unit_of_measurement and/or native_unit_of_measurement for this entity, as this will result in errors when parsing the YAML file.

How I am I supposed to change the unit in order to get rid of the error log and have it displayed correctly in the interface?

What version of Home Assistant Core has the issue?

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

knx

Link to integration documentation on our website

https://www.home-assistant.io/integrations/knx/#sensor

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

home-assistant[bot] commented 10 months ago

Hey there @julius2342, @farmio, @marvin-w, mind taking a look at this issue as it has been labeled with an integration (knx) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `knx` 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 knx` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


knx documentation knx source (message by IssueLinks)

farmio commented 10 months ago

Hi 👋! Unfortunately setting a unit manually for Knx sensors is not supported. You can try to use customize or work around by omitting the device_class and use its value in a helper with correct unit and device_class.

kbabioch commented 10 months ago

Is this a technical limitation or something that might be improved later on? I'm currently trying to clean up my error logs, and this is one of the remaining issues ;-).

farmio commented 10 months ago

It's more of a historical / political limitation.

We didn't want to add (another) config value that does exactly the same as an already built in concept (customize). And I guess no one has revised that thought in the past ~4 years, even though things are a bit different now (eg. customize not being as prominent as it has been in the past).

issue-triage-workflows[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.