mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Add device classes to bloomsky (#84054)
This commit is contained in:
parent
b0b3b36392
commit
dcea8a6ced
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user