aijayadams / hass-blueair

BlueAir sensor integration for HomeAssistant
34 stars 15 forks source link

VOC sensor using incorrect device_class - reported in HA logs #23

Open spikeygg opened 1 year ago

spikeygg commented 1 year ago

I have noticed in the Home Assistant system logs that my blueair VOC sensor shows up because the units are ppb instead of µg/m³. The log entries look like this:

Entity sensor.blueair_office_voc (<class 'custom_components.blueair.sensor.BlueairVOCSensor'>) is using native unit of measurement 'ppb' which is not a valid unit for the device class ('volatile_organic_compounds') it is using; expected one of ['µg/m³']; Please update your configuration if your entity is manually configured, otherwise report it to the custom integration author.

I have had this same warning on a few ESPHome devices that I created with a ccs811 sensor and I fixed those by assigning the device_class to volatile_organic_compound_parts (which allows for ppm or ppb units) instead of the default: volatile_organic_compound (which only has the µg/m³ units).

See the valid Home Assistant device_classes here: https://www.home-assistant.io/integrations/sensor/

SoccerCore11 commented 10 months ago

@spikeygg how/where did you make this change to stop getting the errors in the log?

spikeygg commented 10 months ago

@spikeygg how/where did you make this change to stop getting the errors in the log?

It was in the ESPHome YAML file. When you describe the hookup of the sensors to the ESP32/ESP8266 you can also set the device_class of the sensor entities. If you set the device_class of them properly, the error will go away. This is a problem in the definition of the sensors in the BlueAir component source code. If the device_class was set to volatile_organic_compound_parts it would make the error message go away because the units would be fixed.