ESPHome "device classe" and "unit of measurement" issue (pm1, pm25, pm10, tvoc)

Hello HA Community,

I have a air quality sensor with different sensors that are defined this way is the Yaml ESPHome: (I can share the complete code if that helps)

  sensors:
  - name: "${friendly_name} PM1"
    id: daikinpm1
    unit_of_measurement: "μg/m³"
    accuracy_decimals: 0
    device_class: pm1
  - name: "${friendly_name} PM2.5"
    id: daikinpm25
    unit_of_measurement: "μg/m³"
    accuracy_decimals: 0
    device_class: pm25
  - name: "${friendly_name} PM10"
    id: daikinpm10
    unit_of_measurement: "μg/m³"
    accuracy_decimals: 0
    device_class: pm10
- platform: sgp30
  i2c_id: sgp30_bus
  eco2:
    name: "${friendly_name} eCO2"
    accuracy_decimals: 1
  tvoc:
    name: "${friendly_name} TVOC"
    id: daikintvocppb
    filters:
      - lambda: return x * 2.3;        #ppd -> μg/m³
      - exponential_moving_average:
          alpha: 0.1
          send_every: 10
          send_first_at: 1
    unit_of_measurement: "μg/m³"
    device_class: volatile_organic_compounds  
    accuracy_decimals: 0

And Im getting the following warnings in the Home Assistant log:

2023-06-12 13:33:44.531 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.daikin_air_sensor_floor_1_pm1 (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'μg/m³' which is not a valid unit for the device class ('pm1') it is using; expected one of ['µg/m³']; 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+esphome%22
2023-06-12 13:33:44.546 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.daikin_air_sensor_floor_1_pm2_5 (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'μg/m³' which is not a valid unit for the device class ('pm25') it is using; expected one of ['µg/m³']; 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+esphome%22
2023-06-12 13:33:44.619 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.daikin_air_sensor_floor_1_tvoc (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'μg/m³' 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 create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+esphome%22
2023-06-12 13:33:44.639 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.daikin_air_sensor_floor_1_pm10 (<class 'homeassistant.components.esphome.sensor.EsphomeSensor'>) is using native unit of measurement 'μg/m³' which is not a valid unit for the device class ('pm10') it is using; expected one of ['µg/m³']; 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+esphome%22

What is wrong or missing?

The ESPHome version is 2023.2.4 and Home Assistant is 2023.4.6. If somebody is looking after the same this is how it looks like:

1 Like

Althought the ‘μg/m³’ that you used is visually exactly the same as the expected ‘µg/m³’, the µ-symbol is a different character. In your case it’s 0x3BC while expected is 0xB5: characters from different encoding spaces.

To solve this, copy this ‘µg/m³’ into your configuration and problem will be solved.

3 Likes

Alright! Didn’t thought that it was so simple.
I will try that and let you know.

How did you spot that!

I think with an Hex editor I guess :relaxed:. Don’t know any other way to do it… @ckxsmart any thoughts?

I would have assumed it was a bug in the code. The symbols look identical. At least when people use the wrong degrees symbol it is usually noticeable.

1 Like

Indeed! I would not look for that either…

but they are not the same!

As soon I’ve updated the Firmware got immediately this:

2023-06-12 19:45:10.578 WARNING (Recorder) [homeassistant.components.sensor.recorder] The unit of sensor.daikin_air_sensor_floor_1_tvoc is changing, got multiple {'µg/m³', 'μg/m³'}, generation of long term statistics will be suppressed unless the unit is stable and matches the unit of already compiled statistics (μg/m³). Go to https://my.home-assistant.io/redirect/developer_statistics to fix this

And after restart HA the warnings disappear. @ckxsmart your answer is tagged as the solution.
Thank you to both.

PS: I have still one issue since the ESP restarts every ~5000 seconds but will open a new topic for that one.