ESPHome device_class support not actually aligned to Home Assistant's?

The ESPHome docs Sensor Component — ESPHome say:

  • device_class (Optional, string): The device class for the sensor. See Sensor - Home Assistant for a list of available options. Set to "" to remove the default device class of a sensor.

This makes it sound like the ESPHome device_class list is unified with HA’s. Navigating to that URL: https://www.home-assistant.io/integrations/sensor/#device-class it shows several valid device_class values that don’t actually work in ESPHome.

device_class Home Assistant Supported in ESPHome
None TRUE TRUE
aqi TRUE FALSE
battery TRUE TRUE
carbon_dioxide TRUE TRUE
carbon_monoxide TRUE TRUE
current TRUE TRUE
energy TRUE TRUE
gas TRUE TRUE
humidity TRUE TRUE
illuminance TRUE TRUE
monetary TRUE TRUE
nitrogen_dioxide TRUE FALSE
nitrogen_monoxide TRUE FALSE
nitrous_oxide TRUE FALSE
ozone TRUE FALSE
pm1 TRUE FALSE
pm10 TRUE FALSE
pm25 TRUE FALSE
power_factor TRUE TRUE
power TRUE TRUE
pressure TRUE TRUE
signal_strength TRUE TRUE
sulphur_dioxide TRUE FALSE
temperature TRUE TRUE
timestamp TRUE FALSE
volatile_organic_compounds TRUE FALSE
voltage TRUE TRUE

I discovered this when I tried to use aqi and pm25 values in the ESPHome editor:


Or try to run a validation on the yaml with one of those device_classes defined.

This shouldn’t be the case, right?

1 Like

Seems these device classes were added with HA 2021.9. Thanks for sorting out the list, I’ve submitted a PR to incorporate them into ESPHome as well :slight_smile:

1 Like

Awesome! Thanks @oxan!