diff --git a/homeassistant/components/bloomsky/sensor.py b/homeassistant/components/bloomsky/sensor.py index 77978e6324d..6cefcdb3346 100644 --- a/homeassistant/components/bloomsky/sensor.py +++ b/homeassistant/components/bloomsky/sensor.py @@ -11,12 +11,10 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( AREA_SQUARE_METERS, CONF_MONITORED_CONDITIONS, - ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, - PRESSURE_INHG, - PRESSURE_MBAR, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfElectricPotential, + UnitOfPressure, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv @@ -37,25 +35,28 @@ SENSOR_TYPES = [ # Sensor units - these do not currently align with the API documentation SENSOR_UNITS_IMPERIAL = { - "Temperature": TEMP_FAHRENHEIT, + "Temperature": UnitOfTemperature.FAHRENHEIT, "Humidity": PERCENTAGE, - "Pressure": PRESSURE_INHG, + "Pressure": UnitOfPressure.INHG, "Luminance": f"cd/{AREA_SQUARE_METERS}", - "Voltage": ELECTRIC_POTENTIAL_MILLIVOLT, + "Voltage": UnitOfElectricPotential.MILLIVOLT, } # Metric units SENSOR_UNITS_METRIC = { - "Temperature": TEMP_CELSIUS, + "Temperature": UnitOfTemperature.CELSIUS, "Humidity": PERCENTAGE, - "Pressure": PRESSURE_MBAR, + "Pressure": UnitOfPressure.MBAR, "Luminance": f"cd/{AREA_SQUARE_METERS}", - "Voltage": ELECTRIC_POTENTIAL_MILLIVOLT, + "Voltage": UnitOfElectricPotential.MILLIVOLT, } # Device class SENSOR_DEVICE_CLASS = { "Temperature": SensorDeviceClass.TEMPERATURE, + "Humidity": SensorDeviceClass.HUMIDITY, + "Pressure": SensorDeviceClass.PRESSURE, + "Voltage": SensorDeviceClass.VOLTAGE, } # Which sensors to format numerically @@ -108,7 +109,7 @@ class BloomSkySensor(SensorEntity): ) @property - def device_class(self): + def device_class(self) -> SensorDeviceClass | None: """Return the class of this device, from component DEVICE_CLASSES.""" return SENSOR_DEVICE_CLASS.get(self._sensor_name)