Sensor with invalid unit of measurement but it is defined in const.py

Hey everyone,

I’ve just been adding MQTT statistics to my configuration.yaml and while trying to get that functional stumbled onto device/class doco so I thought I’d configure it for my other MQTT sensors

Unfortunately its resulted in some errors showing up in the devices page but they seem like they might be a bug as the doco only contains this unit of measurement for this device class

* **pm1**: Concentration of particulate matter less than 1 micrometer in µg/m³
* **pm25**: Concentration of particulate matter less than 2.5 micrometers in µg/m³
* **pm10**: Concentration of particulate matter less than 10 micrometers in µg/m³

I have one of these for each of my particulate sensors that were previously working fine until I added the device_class for the relevant type

I got the units of measurement from github core/homeassistant/const.py at 3e6473d13094a548bc9cdee2fa68ac2a23551ee1 · home-assistant/core · GitHub

It is defined there
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: Final = "µg/m³"

This is my sensor config that is now erroring out

 #Climate sensor bedroom 4
    - name: "bedroom4.pm10"
      unique_id: "bedroom4_pm10"
      unit_of_measurement: "µg/m³"
      device_class: "pm10"
      state_topic: "home/air/sensor/bedroom4/PMSensor/pm10"
    - name: "bedroom4.pm2.5"
      unique_id: "bedroom4_pm2.5"
      unit_of_measurement: "µg/m³"
      device_class: "pm25"
      state_topic: "home/air/sensor/bedroom4/PMSensor/pm2.5"  
    - name: "bedroom4.pm1.0"
      unique_id: "bedroom4_pm1.0"
      unit_of_measurement: "µg/m³"
      device_class: "pm1"
      state_topic: "home/air/sensor/bedroom4/PMSensor/pm1.0"

I could fix this by removing the device_class again but is that the best solution?

I took a look and to be honest, I don’t see any problem with what you have based on this dev doc and this user doc. Maybe a bug??

The error seems to have gone away after a lucky reboot of HA so i guess we can ignore it, ty ill close the issue in a few days if nothing else comes of it