From e65d49184922305a22fd39cde1b3a3e8a989c46d Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sat, 27 Jun 2026 23:49:19 +0200 Subject: [PATCH] Migrate foobot to UnitOfDensity / UnitOfRatio enums (#175006) --- homeassistant/components/foobot/sensor.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/foobot/sensor.py b/homeassistant/components/foobot/sensor.py index 6b651984d233..a98ca998b5f4 100644 --- a/homeassistant/components/foobot/sensor.py +++ b/homeassistant/components/foobot/sensor.py @@ -16,12 +16,10 @@ from homeassistant.components.sensor import ( ) from homeassistant.const import ( ATTR_TEMPERATURE, - CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, - CONCENTRATION_PARTS_PER_BILLION, - CONCENTRATION_PARTS_PER_MILLION, CONF_TOKEN, CONF_USERNAME, - PERCENTAGE, + UnitOfDensity, + UnitOfRatio, UnitOfTemperature, ) from homeassistant.core import HomeAssistant @@ -44,7 +42,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="pm", name=ATTR_PM2_5, - native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, + native_unit_of_measurement=UnitOfDensity.MICROGRAMS_PER_CUBIC_METER, icon="mdi:cloud", ), SensorEntityDescription( @@ -56,25 +54,25 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="hum", name=ATTR_HUMIDITY, - native_unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=UnitOfRatio.PERCENTAGE, icon="mdi:water-percent", ), SensorEntityDescription( key="co2", name=ATTR_CARBON_DIOXIDE, - native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, + native_unit_of_measurement=UnitOfRatio.PARTS_PER_MILLION, icon="mdi:molecule-co2", ), SensorEntityDescription( key="voc", name=ATTR_VOLATILE_ORGANIC_COMPOUNDS, - native_unit_of_measurement=CONCENTRATION_PARTS_PER_BILLION, + native_unit_of_measurement=UnitOfRatio.PARTS_PER_BILLION, icon="mdi:cloud", ), SensorEntityDescription( key="allpollu", name=ATTR_FOOBOT_INDEX, - native_unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=UnitOfRatio.PERCENTAGE, icon="mdi:percent", ), )