From 9b8a77600192287f35a6a4772eba0c90c449708f Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 12 Jul 2021 22:45:29 +0200 Subject: [PATCH] Set device_class on temperature sensors A-E (#49524) Co-authored-by: Franck Nijhof --- homeassistant/components/apcupsd/sensor.py | 134 +++---- homeassistant/components/aqualogic/sensor.py | 36 +- homeassistant/components/arwn/sensor.py | 19 +- homeassistant/components/bloomsky/sensor.py | 11 + homeassistant/components/buienradar/sensor.py | 340 ++++++++++++------ homeassistant/components/ebusd/const.py | 219 ++++++++--- homeassistant/components/ebusd/sensor.py | 13 +- .../components/ecoal_boiler/sensor.py | 7 +- .../eddystone_temperature/sensor.py | 6 + .../components/eight_sleep/sensor.py | 20 +- .../components/environment_canada/sensor.py | 8 + homeassistant/components/envirophat/sensor.py | 38 +- 12 files changed, 593 insertions(+), 258 deletions(-) diff --git a/homeassistant/components/apcupsd/sensor.py b/homeassistant/components/apcupsd/sensor.py index 190a3f5f1d8..4748ae2476e 100644 --- a/homeassistant/components/apcupsd/sensor.py +++ b/homeassistant/components/apcupsd/sensor.py @@ -7,6 +7,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_RESOURCES, + DEVICE_CLASS_TEMPERATURE, ELECTRICAL_CURRENT_AMPERE, ELECTRICAL_VOLT_AMPERE, FREQUENCY_HERTZ, @@ -25,72 +26,72 @@ _LOGGER = logging.getLogger(__name__) SENSOR_PREFIX = "UPS " SENSOR_TYPES = { - "alarmdel": ["Alarm Delay", "", "mdi:alarm"], - "ambtemp": ["Ambient Temperature", "", "mdi:thermometer"], - "apc": ["Status Data", "", "mdi:information-outline"], - "apcmodel": ["Model", "", "mdi:information-outline"], - "badbatts": ["Bad Batteries", "", "mdi:information-outline"], - "battdate": ["Battery Replaced", "", "mdi:calendar-clock"], - "battstat": ["Battery Status", "", "mdi:information-outline"], - "battv": ["Battery Voltage", VOLT, "mdi:flash"], - "bcharge": ["Battery", PERCENTAGE, "mdi:battery"], - "cable": ["Cable Type", "", "mdi:ethernet-cable"], - "cumonbatt": ["Total Time on Battery", "", "mdi:timer-outline"], - "date": ["Status Date", "", "mdi:calendar-clock"], - "dipsw": ["Dip Switch Settings", "", "mdi:information-outline"], - "dlowbatt": ["Low Battery Signal", "", "mdi:clock-alert"], - "driver": ["Driver", "", "mdi:information-outline"], - "dshutd": ["Shutdown Delay", "", "mdi:timer-outline"], - "dwake": ["Wake Delay", "", "mdi:timer-outline"], - "endapc": ["Date and Time", "", "mdi:calendar-clock"], - "extbatts": ["External Batteries", "", "mdi:information-outline"], - "firmware": ["Firmware Version", "", "mdi:information-outline"], - "hitrans": ["Transfer High", VOLT, "mdi:flash"], - "hostname": ["Hostname", "", "mdi:information-outline"], - "humidity": ["Ambient Humidity", PERCENTAGE, "mdi:water-percent"], - "itemp": ["Internal Temperature", TEMP_CELSIUS, "mdi:thermometer"], - "lastxfer": ["Last Transfer", "", "mdi:transfer"], - "linefail": ["Input Voltage Status", "", "mdi:information-outline"], - "linefreq": ["Line Frequency", FREQUENCY_HERTZ, "mdi:information-outline"], - "linev": ["Input Voltage", VOLT, "mdi:flash"], - "loadpct": ["Load", PERCENTAGE, "mdi:gauge"], - "loadapnt": ["Load Apparent Power", PERCENTAGE, "mdi:gauge"], - "lotrans": ["Transfer Low", VOLT, "mdi:flash"], - "mandate": ["Manufacture Date", "", "mdi:calendar"], - "masterupd": ["Master Update", "", "mdi:information-outline"], - "maxlinev": ["Input Voltage High", VOLT, "mdi:flash"], - "maxtime": ["Battery Timeout", "", "mdi:timer-off-outline"], - "mbattchg": ["Battery Shutdown", PERCENTAGE, "mdi:battery-alert"], - "minlinev": ["Input Voltage Low", VOLT, "mdi:flash"], - "mintimel": ["Shutdown Time", "", "mdi:timer-outline"], - "model": ["Model", "", "mdi:information-outline"], - "nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash"], - "nominv": ["Nominal Input Voltage", VOLT, "mdi:flash"], - "nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash"], - "nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash"], - "nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash"], - "numxfers": ["Transfer Count", "", "mdi:counter"], - "outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash"], - "outputv": ["Output Voltage", VOLT, "mdi:flash"], - "reg1": ["Register 1 Fault", "", "mdi:information-outline"], - "reg2": ["Register 2 Fault", "", "mdi:information-outline"], - "reg3": ["Register 3 Fault", "", "mdi:information-outline"], - "retpct": ["Restore Requirement", PERCENTAGE, "mdi:battery-alert"], - "selftest": ["Last Self Test", "", "mdi:calendar-clock"], - "sense": ["Sensitivity", "", "mdi:information-outline"], - "serialno": ["Serial Number", "", "mdi:information-outline"], - "starttime": ["Startup Time", "", "mdi:calendar-clock"], - "statflag": ["Status Flag", "", "mdi:information-outline"], - "status": ["Status", "", "mdi:information-outline"], - "stesti": ["Self Test Interval", "", "mdi:information-outline"], - "timeleft": ["Time Left", "", "mdi:clock-alert"], - "tonbatt": ["Time on Battery", "", "mdi:timer-outline"], - "upsmode": ["Mode", "", "mdi:information-outline"], - "upsname": ["Name", "", "mdi:information-outline"], - "version": ["Daemon Info", "", "mdi:information-outline"], - "xoffbat": ["Transfer from Battery", "", "mdi:transfer"], - "xoffbatt": ["Transfer from Battery", "", "mdi:transfer"], - "xonbatt": ["Transfer to Battery", "", "mdi:transfer"], + "alarmdel": ["Alarm Delay", "", "mdi:alarm", None], + "ambtemp": ["Ambient Temperature", "", "mdi:thermometer", None], + "apc": ["Status Data", "", "mdi:information-outline", None], + "apcmodel": ["Model", "", "mdi:information-outline", None], + "badbatts": ["Bad Batteries", "", "mdi:information-outline", None], + "battdate": ["Battery Replaced", "", "mdi:calendar-clock", None], + "battstat": ["Battery Status", "", "mdi:information-outline", None], + "battv": ["Battery Voltage", VOLT, "mdi:flash", None], + "bcharge": ["Battery", PERCENTAGE, "mdi:battery", None], + "cable": ["Cable Type", "", "mdi:ethernet-cable", None], + "cumonbatt": ["Total Time on Battery", "", "mdi:timer-outline", None], + "date": ["Status Date", "", "mdi:calendar-clock", None], + "dipsw": ["Dip Switch Settings", "", "mdi:information-outline", None], + "dlowbatt": ["Low Battery Signal", "", "mdi:clock-alert", None], + "driver": ["Driver", "", "mdi:information-outline", None], + "dshutd": ["Shutdown Delay", "", "mdi:timer-outline", None], + "dwake": ["Wake Delay", "", "mdi:timer-outline", None], + "endapc": ["Date and Time", "", "mdi:calendar-clock", None], + "extbatts": ["External Batteries", "", "mdi:information-outline", None], + "firmware": ["Firmware Version", "", "mdi:information-outline", None], + "hitrans": ["Transfer High", VOLT, "mdi:flash", None], + "hostname": ["Hostname", "", "mdi:information-outline", None], + "humidity": ["Ambient Humidity", PERCENTAGE, "mdi:water-percent", None], + "itemp": ["Internal Temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE], + "lastxfer": ["Last Transfer", "", "mdi:transfer", None], + "linefail": ["Input Voltage Status", "", "mdi:information-outline", None], + "linefreq": ["Line Frequency", FREQUENCY_HERTZ, "mdi:information-outline", None], + "linev": ["Input Voltage", VOLT, "mdi:flash", None], + "loadpct": ["Load", PERCENTAGE, "mdi:gauge", None], + "loadapnt": ["Load Apparent Power", PERCENTAGE, "mdi:gauge", None], + "lotrans": ["Transfer Low", VOLT, "mdi:flash", None], + "mandate": ["Manufacture Date", "", "mdi:calendar", None], + "masterupd": ["Master Update", "", "mdi:information-outline", None], + "maxlinev": ["Input Voltage High", VOLT, "mdi:flash", None], + "maxtime": ["Battery Timeout", "", "mdi:timer-off-outline", None], + "mbattchg": ["Battery Shutdown", PERCENTAGE, "mdi:battery-alert", None], + "minlinev": ["Input Voltage Low", VOLT, "mdi:flash", None], + "mintimel": ["Shutdown Time", "", "mdi:timer-outline", None], + "model": ["Model", "", "mdi:information-outline", None], + "nombattv": ["Battery Nominal Voltage", VOLT, "mdi:flash", None], + "nominv": ["Nominal Input Voltage", VOLT, "mdi:flash", None], + "nomoutv": ["Nominal Output Voltage", VOLT, "mdi:flash", None], + "nompower": ["Nominal Output Power", POWER_WATT, "mdi:flash", None], + "nomapnt": ["Nominal Apparent Power", ELECTRICAL_VOLT_AMPERE, "mdi:flash", None], + "numxfers": ["Transfer Count", "", "mdi:counter", None], + "outcurnt": ["Output Current", ELECTRICAL_CURRENT_AMPERE, "mdi:flash", None], + "outputv": ["Output Voltage", VOLT, "mdi:flash", None], + "reg1": ["Register 1 Fault", "", "mdi:information-outline", None], + "reg2": ["Register 2 Fault", "", "mdi:information-outline", None], + "reg3": ["Register 3 Fault", "", "mdi:information-outline", None], + "retpct": ["Restore Requirement", PERCENTAGE, "mdi:battery-alert", None], + "selftest": ["Last Self Test", "", "mdi:calendar-clock", None], + "sense": ["Sensitivity", "", "mdi:information-outline", None], + "serialno": ["Serial Number", "", "mdi:information-outline", None], + "starttime": ["Startup Time", "", "mdi:calendar-clock", None], + "statflag": ["Status Flag", "", "mdi:information-outline", None], + "status": ["Status", "", "mdi:information-outline", None], + "stesti": ["Self Test Interval", "", "mdi:information-outline", None], + "timeleft": ["Time Left", "", "mdi:clock-alert", None], + "tonbatt": ["Time on Battery", "", "mdi:timer-outline", None], + "upsmode": ["Mode", "", "mdi:information-outline", None], + "upsname": ["Name", "", "mdi:information-outline", None], + "version": ["Daemon Info", "", "mdi:information-outline", None], + "xoffbat": ["Transfer from Battery", "", "mdi:transfer", None], + "xoffbatt": ["Transfer from Battery", "", "mdi:transfer", None], + "xonbatt": ["Transfer to Battery", "", "mdi:transfer", None], } SPECIFIC_UNITS = {"ITEMP": TEMP_CELSIUS} @@ -166,6 +167,7 @@ class APCUPSdSensor(SensorEntity): self._attr_icon = SENSOR_TYPES[self.type][2] if SENSOR_TYPES[sensor_type][1]: self._attr_unit_of_measurement = SENSOR_TYPES[sensor_type][1] + self._attr_device_class = SENSOR_TYPES[sensor_type][3] def update(self): """Get the latest status and use it to update our sensor state.""" diff --git a/homeassistant/components/aqualogic/sensor.py b/homeassistant/components/aqualogic/sensor.py index 315b039f778..1608f6173d8 100644 --- a/homeassistant/components/aqualogic/sensor.py +++ b/homeassistant/components/aqualogic/sensor.py @@ -5,6 +5,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_MONITORED_CONDITIONS, + DEVICE_CLASS_TEMPERATURE, PERCENTAGE, POWER_WATT, TEMP_CELSIUS, @@ -21,18 +22,28 @@ SALT_UNITS = ["g/L", "PPM"] WATT_UNITS = [POWER_WATT, POWER_WATT] NO_UNITS = [None, None] -# sensor_type [ description, unit, icon ] +# sensor_type [ description, unit, icon, device_class ] # sensor_type corresponds to property names in aqualogic.core.AquaLogic SENSOR_TYPES = { - "air_temp": ["Air Temperature", TEMP_UNITS, "mdi:thermometer"], - "pool_temp": ["Pool Temperature", TEMP_UNITS, "mdi:oil-temperature"], - "spa_temp": ["Spa Temperature", TEMP_UNITS, "mdi:oil-temperature"], - "pool_chlorinator": ["Pool Chlorinator", PERCENT_UNITS, "mdi:gauge"], - "spa_chlorinator": ["Spa Chlorinator", PERCENT_UNITS, "mdi:gauge"], - "salt_level": ["Salt Level", SALT_UNITS, "mdi:gauge"], - "pump_speed": ["Pump Speed", PERCENT_UNITS, "mdi:speedometer"], - "pump_power": ["Pump Power", WATT_UNITS, "mdi:gauge"], - "status": ["Status", NO_UNITS, "mdi:alert"], + "air_temp": ["Air Temperature", TEMP_UNITS, None, DEVICE_CLASS_TEMPERATURE], + "pool_temp": [ + "Pool Temperature", + TEMP_UNITS, + "mdi:oil-temperature", + DEVICE_CLASS_TEMPERATURE, + ], + "spa_temp": [ + "Spa Temperature", + TEMP_UNITS, + "mdi:oil-temperature", + DEVICE_CLASS_TEMPERATURE, + ], + "pool_chlorinator": ["Pool Chlorinator", PERCENT_UNITS, "mdi:gauge", None], + "spa_chlorinator": ["Spa Chlorinator", PERCENT_UNITS, "mdi:gauge", None], + "salt_level": ["Salt Level", SALT_UNITS, "mdi:gauge", None], + "pump_speed": ["Pump Speed", PERCENT_UNITS, "mdi:speedometer", None], + "pump_power": ["Pump Power", WATT_UNITS, "mdi:gauge", None], + "status": ["Status", NO_UNITS, "mdi:alert", None], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( @@ -89,6 +100,11 @@ class AquaLogicSensor(SensorEntity): """Return the polling state.""" return False + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return SENSOR_TYPES[self._type][3] + @property def icon(self): """Icon to use in the frontend, if any.""" diff --git a/homeassistant/components/arwn/sensor.py b/homeassistant/components/arwn/sensor.py index ba9166d1af5..83ff7da1b56 100644 --- a/homeassistant/components/arwn/sensor.py +++ b/homeassistant/components/arwn/sensor.py @@ -4,7 +4,12 @@ import logging from homeassistant.components import mqtt from homeassistant.components.sensor import SensorEntity -from homeassistant.const import DEGREE, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import ( + DEGREE, + DEVICE_CLASS_TEMPERATURE, + TEMP_CELSIUS, + TEMP_FAHRENHEIT, +) from homeassistant.core import callback from homeassistant.util import slugify @@ -30,7 +35,9 @@ def discover_sensors(topic, payload): unit = TEMP_FAHRENHEIT else: unit = TEMP_CELSIUS - return ArwnSensor(topic, name, "temp", unit) + return ArwnSensor( + topic, name, "temp", unit, device_class=DEVICE_CLASS_TEMPERATURE + ) if domain == "moisture": name = f"{parts[2]} Moisture" return ArwnSensor(topic, name, "moisture", unit, "mdi:water-percent") @@ -117,7 +124,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= class ArwnSensor(SensorEntity): """Representation of an ARWN sensor.""" - def __init__(self, topic, name, state_key, units, icon=None): + def __init__(self, topic, name, state_key, units, icon=None, device_class=None): """Initialize the sensor.""" self.hass = None self.entity_id = _slug(name) @@ -128,6 +135,7 @@ class ArwnSensor(SensorEntity): self.event = {} self._unit_of_measurement = units self._icon = icon + self._device_class = device_class def set_event(self, event): """Update the sensor with the most recent event.""" @@ -168,6 +176,11 @@ class ArwnSensor(SensorEntity): """Return the polling state.""" return False + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return self._device_class + @property def icon(self): """Return the icon of device based on its type.""" diff --git a/homeassistant/components/bloomsky/sensor.py b/homeassistant/components/bloomsky/sensor.py index 4dc52e1a85c..cf494c40916 100644 --- a/homeassistant/components/bloomsky/sensor.py +++ b/homeassistant/components/bloomsky/sensor.py @@ -5,6 +5,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( AREA_SQUARE_METERS, CONF_MONITORED_CONDITIONS, + DEVICE_CLASS_TEMPERATURE, PERCENTAGE, PRESSURE_INHG, PRESSURE_MBAR, @@ -43,6 +44,11 @@ SENSOR_UNITS_METRIC = { "Voltage": "mV", } +# Device class +SENSOR_DEVICE_CLASS = { + "Temperature": DEVICE_CLASS_TEMPERATURE, +} + # Which sensors to format numerically FORMAT_NUMBERS = ["Temperature", "Pressure", "Voltage"] @@ -103,6 +109,11 @@ class BloomSkySensor(SensorEntity): return SENSOR_UNITS_METRIC.get(self._sensor_name, None) return SENSOR_UNITS_IMPERIAL.get(self._sensor_name, None) + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return SENSOR_DEVICE_CLASS.get(self._sensor_name) + def update(self): """Request an update from the BloomSky API.""" self._bloomsky.refresh_devices() diff --git a/homeassistant/components/buienradar/sensor.py b/homeassistant/components/buienradar/sensor.py index e4a317cface..10507166288 100644 --- a/homeassistant/components/buienradar/sensor.py +++ b/homeassistant/components/buienradar/sensor.py @@ -29,6 +29,7 @@ from homeassistant.const import ( CONF_MONITORED_CONDITIONS, CONF_NAME, DEGREE, + DEVICE_CLASS_TEMPERATURE, IRRADIATION_WATTS_PER_SQUARE_METER, LENGTH_KILOMETERS, LENGTH_MILLIMETERS, @@ -60,132 +61,260 @@ SCHEDULE_NOK = 2 # Supported sensor types: # Key: ['label', unit, icon] SENSOR_TYPES = { - "stationname": ["Stationname", None, None], + "stationname": ["Stationname", None, None, None], # new in json api (>1.0.0): - "barometerfc": ["Barometer value", None, "mdi:gauge"], + "barometerfc": ["Barometer value", None, "mdi:gauge", None], # new in json api (>1.0.0): - "barometerfcname": ["Barometer", None, "mdi:gauge"], + "barometerfcname": ["Barometer", None, "mdi:gauge", None], # new in json api (>1.0.0): - "barometerfcnamenl": ["Barometer", None, "mdi:gauge"], - "condition": ["Condition", None, None], - "conditioncode": ["Condition code", None, None], - "conditiondetailed": ["Detailed condition", None, None], - "conditionexact": ["Full condition", None, None], - "symbol": ["Symbol", None, None], + "barometerfcnamenl": ["Barometer", None, "mdi:gauge", None], + "condition": ["Condition", None, None, None], + "conditioncode": ["Condition code", None, None, None], + "conditiondetailed": ["Detailed condition", None, None, None], + "conditionexact": ["Full condition", None, None, None], + "symbol": ["Symbol", None, None, None], # new in json api (>1.0.0): - "feeltemperature": ["Feel temperature", TEMP_CELSIUS, "mdi:thermometer"], - "humidity": ["Humidity", PERCENTAGE, "mdi:water-percent"], - "temperature": ["Temperature", TEMP_CELSIUS, "mdi:thermometer"], - "groundtemperature": ["Ground temperature", TEMP_CELSIUS, "mdi:thermometer"], - "windspeed": ["Wind speed", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "windforce": ["Wind force", "Bft", "mdi:weather-windy"], - "winddirection": ["Wind direction", None, "mdi:compass-outline"], - "windazimuth": ["Wind direction azimuth", DEGREE, "mdi:compass-outline"], - "pressure": ["Pressure", PRESSURE_HPA, "mdi:gauge"], - "visibility": ["Visibility", LENGTH_KILOMETERS, None], - "windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], + "feeltemperature": [ + "Feel temperature", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "humidity": ["Humidity", PERCENTAGE, "mdi:water-percent", None], + "temperature": [ + "Temperature", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "groundtemperature": [ + "Ground temperature", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "windspeed": ["Wind speed", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy", None], + "windforce": ["Wind force", "Bft", "mdi:weather-windy", None], + "winddirection": ["Wind direction", None, "mdi:compass-outline", None], + "windazimuth": ["Wind direction azimuth", DEGREE, "mdi:compass-outline", None], + "pressure": ["Pressure", PRESSURE_HPA, "mdi:gauge", None], + "visibility": ["Visibility", LENGTH_KILOMETERS, None, None], + "windgust": ["Wind gust", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy", None], "precipitation": [ "Precipitation", PRECIPITATION_MILLIMETERS_PER_HOUR, "mdi:weather-pouring", + None, + ], + "irradiance": [ + "Irradiance", + IRRADIATION_WATTS_PER_SQUARE_METER, + "mdi:sunglasses", + None, ], - "irradiance": ["Irradiance", IRRADIATION_WATTS_PER_SQUARE_METER, "mdi:sunglasses"], "precipitation_forecast_average": [ "Precipitation forecast average", PRECIPITATION_MILLIMETERS_PER_HOUR, "mdi:weather-pouring", + None, ], "precipitation_forecast_total": [ "Precipitation forecast total", LENGTH_MILLIMETERS, "mdi:weather-pouring", + None, ], # new in json api (>1.0.0): - "rainlast24hour": ["Rain last 24h", LENGTH_MILLIMETERS, "mdi:weather-pouring"], + "rainlast24hour": [ + "Rain last 24h", + LENGTH_MILLIMETERS, + "mdi:weather-pouring", + None, + ], # new in json api (>1.0.0): - "rainlasthour": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "temperature_1d": ["Temperature 1d", TEMP_CELSIUS, "mdi:thermometer"], - "temperature_2d": ["Temperature 2d", TEMP_CELSIUS, "mdi:thermometer"], - "temperature_3d": ["Temperature 3d", TEMP_CELSIUS, "mdi:thermometer"], - "temperature_4d": ["Temperature 4d", TEMP_CELSIUS, "mdi:thermometer"], - "temperature_5d": ["Temperature 5d", TEMP_CELSIUS, "mdi:thermometer"], - "mintemp_1d": ["Minimum temperature 1d", TEMP_CELSIUS, "mdi:thermometer"], - "mintemp_2d": ["Minimum temperature 2d", TEMP_CELSIUS, "mdi:thermometer"], - "mintemp_3d": ["Minimum temperature 3d", TEMP_CELSIUS, "mdi:thermometer"], - "mintemp_4d": ["Minimum temperature 4d", TEMP_CELSIUS, "mdi:thermometer"], - "mintemp_5d": ["Minimum temperature 5d", TEMP_CELSIUS, "mdi:thermometer"], - "rain_1d": ["Rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "rain_2d": ["Rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "rain_3d": ["Rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "rain_4d": ["Rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "rain_5d": ["Rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], + "rainlasthour": ["Rain last hour", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "temperature_1d": [ + "Temperature 1d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "temperature_2d": [ + "Temperature 2d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "temperature_3d": [ + "Temperature 3d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "temperature_4d": [ + "Temperature 4d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "temperature_5d": [ + "Temperature 5d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "mintemp_1d": [ + "Minimum temperature 1d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "mintemp_2d": [ + "Minimum temperature 2d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "mintemp_3d": [ + "Minimum temperature 3d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "mintemp_4d": [ + "Minimum temperature 4d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "mintemp_5d": [ + "Minimum temperature 5d", + TEMP_CELSIUS, + None, + DEVICE_CLASS_TEMPERATURE, + ], + "rain_1d": ["Rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "rain_2d": ["Rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "rain_3d": ["Rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "rain_4d": ["Rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "rain_5d": ["Rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], # new in json api (>1.0.0): - "minrain_1d": ["Minimum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "minrain_2d": ["Minimum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "minrain_3d": ["Minimum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "minrain_4d": ["Minimum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "minrain_5d": ["Minimum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], + "minrain_1d": ["Minimum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "minrain_2d": ["Minimum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "minrain_3d": ["Minimum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "minrain_4d": ["Minimum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "minrain_5d": ["Minimum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], # new in json api (>1.0.0): - "maxrain_1d": ["Maximum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "maxrain_2d": ["Maximum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "maxrain_3d": ["Maximum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "maxrain_4d": ["Maximum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "maxrain_5d": ["Maximum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring"], - "rainchance_1d": ["Rainchance 1d", PERCENTAGE, "mdi:weather-pouring"], - "rainchance_2d": ["Rainchance 2d", PERCENTAGE, "mdi:weather-pouring"], - "rainchance_3d": ["Rainchance 3d", PERCENTAGE, "mdi:weather-pouring"], - "rainchance_4d": ["Rainchance 4d", PERCENTAGE, "mdi:weather-pouring"], - "rainchance_5d": ["Rainchance 5d", PERCENTAGE, "mdi:weather-pouring"], - "sunchance_1d": ["Sunchance 1d", PERCENTAGE, "mdi:weather-partly-cloudy"], - "sunchance_2d": ["Sunchance 2d", PERCENTAGE, "mdi:weather-partly-cloudy"], - "sunchance_3d": ["Sunchance 3d", PERCENTAGE, "mdi:weather-partly-cloudy"], - "sunchance_4d": ["Sunchance 4d", PERCENTAGE, "mdi:weather-partly-cloudy"], - "sunchance_5d": ["Sunchance 5d", PERCENTAGE, "mdi:weather-partly-cloudy"], - "windforce_1d": ["Wind force 1d", "Bft", "mdi:weather-windy"], - "windforce_2d": ["Wind force 2d", "Bft", "mdi:weather-windy"], - "windforce_3d": ["Wind force 3d", "Bft", "mdi:weather-windy"], - "windforce_4d": ["Wind force 4d", "Bft", "mdi:weather-windy"], - "windforce_5d": ["Wind force 5d", "Bft", "mdi:weather-windy"], - "windspeed_1d": ["Wind speed 1d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "windspeed_2d": ["Wind speed 2d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "windspeed_3d": ["Wind speed 3d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "windspeed_4d": ["Wind speed 4d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "windspeed_5d": ["Wind speed 5d", SPEED_KILOMETERS_PER_HOUR, "mdi:weather-windy"], - "winddirection_1d": ["Wind direction 1d", None, "mdi:compass-outline"], - "winddirection_2d": ["Wind direction 2d", None, "mdi:compass-outline"], - "winddirection_3d": ["Wind direction 3d", None, "mdi:compass-outline"], - "winddirection_4d": ["Wind direction 4d", None, "mdi:compass-outline"], - "winddirection_5d": ["Wind direction 5d", None, "mdi:compass-outline"], - "windazimuth_1d": ["Wind direction azimuth 1d", DEGREE, "mdi:compass-outline"], - "windazimuth_2d": ["Wind direction azimuth 2d", DEGREE, "mdi:compass-outline"], - "windazimuth_3d": ["Wind direction azimuth 3d", DEGREE, "mdi:compass-outline"], - "windazimuth_4d": ["Wind direction azimuth 4d", DEGREE, "mdi:compass-outline"], - "windazimuth_5d": ["Wind direction azimuth 5d", DEGREE, "mdi:compass-outline"], - "condition_1d": ["Condition 1d", None, None], - "condition_2d": ["Condition 2d", None, None], - "condition_3d": ["Condition 3d", None, None], - "condition_4d": ["Condition 4d", None, None], - "condition_5d": ["Condition 5d", None, None], - "conditioncode_1d": ["Condition code 1d", None, None], - "conditioncode_2d": ["Condition code 2d", None, None], - "conditioncode_3d": ["Condition code 3d", None, None], - "conditioncode_4d": ["Condition code 4d", None, None], - "conditioncode_5d": ["Condition code 5d", None, None], - "conditiondetailed_1d": ["Detailed condition 1d", None, None], - "conditiondetailed_2d": ["Detailed condition 2d", None, None], - "conditiondetailed_3d": ["Detailed condition 3d", None, None], - "conditiondetailed_4d": ["Detailed condition 4d", None, None], - "conditiondetailed_5d": ["Detailed condition 5d", None, None], - "conditionexact_1d": ["Full condition 1d", None, None], - "conditionexact_2d": ["Full condition 2d", None, None], - "conditionexact_3d": ["Full condition 3d", None, None], - "conditionexact_4d": ["Full condition 4d", None, None], - "conditionexact_5d": ["Full condition 5d", None, None], - "symbol_1d": ["Symbol 1d", None, None], - "symbol_2d": ["Symbol 2d", None, None], - "symbol_3d": ["Symbol 3d", None, None], - "symbol_4d": ["Symbol 4d", None, None], - "symbol_5d": ["Symbol 5d", None, None], + "maxrain_1d": ["Maximum rain 1d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "maxrain_2d": ["Maximum rain 2d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "maxrain_3d": ["Maximum rain 3d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "maxrain_4d": ["Maximum rain 4d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "maxrain_5d": ["Maximum rain 5d", LENGTH_MILLIMETERS, "mdi:weather-pouring", None], + "rainchance_1d": ["Rainchance 1d", PERCENTAGE, "mdi:weather-pouring", None], + "rainchance_2d": ["Rainchance 2d", PERCENTAGE, "mdi:weather-pouring", None], + "rainchance_3d": ["Rainchance 3d", PERCENTAGE, "mdi:weather-pouring", None], + "rainchance_4d": ["Rainchance 4d", PERCENTAGE, "mdi:weather-pouring", None], + "rainchance_5d": ["Rainchance 5d", PERCENTAGE, "mdi:weather-pouring", None], + "sunchance_1d": ["Sunchance 1d", PERCENTAGE, "mdi:weather-partly-cloudy", None], + "sunchance_2d": ["Sunchance 2d", PERCENTAGE, "mdi:weather-partly-cloudy", None], + "sunchance_3d": ["Sunchance 3d", PERCENTAGE, "mdi:weather-partly-cloudy", None], + "sunchance_4d": ["Sunchance 4d", PERCENTAGE, "mdi:weather-partly-cloudy", None], + "sunchance_5d": ["Sunchance 5d", PERCENTAGE, "mdi:weather-partly-cloudy", None], + "windforce_1d": ["Wind force 1d", "Bft", "mdi:weather-windy", None], + "windforce_2d": ["Wind force 2d", "Bft", "mdi:weather-windy", None], + "windforce_3d": ["Wind force 3d", "Bft", "mdi:weather-windy", None], + "windforce_4d": ["Wind force 4d", "Bft", "mdi:weather-windy", None], + "windforce_5d": ["Wind force 5d", "Bft", "mdi:weather-windy", None], + "windspeed_1d": [ + "Wind speed 1d", + SPEED_KILOMETERS_PER_HOUR, + "mdi:weather-windy", + None, + ], + "windspeed_2d": [ + "Wind speed 2d", + SPEED_KILOMETERS_PER_HOUR, + "mdi:weather-windy", + None, + ], + "windspeed_3d": [ + "Wind speed 3d", + SPEED_KILOMETERS_PER_HOUR, + "mdi:weather-windy", + None, + ], + "windspeed_4d": [ + "Wind speed 4d", + SPEED_KILOMETERS_PER_HOUR, + "mdi:weather-windy", + None, + ], + "windspeed_5d": [ + "Wind speed 5d", + SPEED_KILOMETERS_PER_HOUR, + "mdi:weather-windy", + None, + ], + "winddirection_1d": ["Wind direction 1d", None, "mdi:compass-outline", None], + "winddirection_2d": ["Wind direction 2d", None, "mdi:compass-outline", None], + "winddirection_3d": ["Wind direction 3d", None, "mdi:compass-outline", None], + "winddirection_4d": ["Wind direction 4d", None, "mdi:compass-outline", None], + "winddirection_5d": ["Wind direction 5d", None, "mdi:compass-outline", None], + "windazimuth_1d": [ + "Wind direction azimuth 1d", + DEGREE, + "mdi:compass-outline", + None, + ], + "windazimuth_2d": [ + "Wind direction azimuth 2d", + DEGREE, + "mdi:compass-outline", + None, + ], + "windazimuth_3d": [ + "Wind direction azimuth 3d", + DEGREE, + "mdi:compass-outline", + None, + ], + "windazimuth_4d": [ + "Wind direction azimuth 4d", + DEGREE, + "mdi:compass-outline", + None, + ], + "windazimuth_5d": [ + "Wind direction azimuth 5d", + DEGREE, + "mdi:compass-outline", + None, + ], + "condition_1d": ["Condition 1d", None, None, None], + "condition_2d": ["Condition 2d", None, None, None], + "condition_3d": ["Condition 3d", None, None, None], + "condition_4d": ["Condition 4d", None, None, None], + "condition_5d": ["Condition 5d", None, None, None], + "conditioncode_1d": ["Condition code 1d", None, None, None], + "conditioncode_2d": ["Condition code 2d", None, None, None], + "conditioncode_3d": ["Condition code 3d", None, None, None], + "conditioncode_4d": ["Condition code 4d", None, None, None], + "conditioncode_5d": ["Condition code 5d", None, None, None], + "conditiondetailed_1d": ["Detailed condition 1d", None, None, None], + "conditiondetailed_2d": ["Detailed condition 2d", None, None, None], + "conditiondetailed_3d": ["Detailed condition 3d", None, None, None], + "conditiondetailed_4d": ["Detailed condition 4d", None, None, None], + "conditiondetailed_5d": ["Detailed condition 5d", None, None, None], + "conditionexact_1d": ["Full condition 1d", None, None, None], + "conditionexact_2d": ["Full condition 2d", None, None, None], + "conditionexact_3d": ["Full condition 3d", None, None, None], + "conditionexact_4d": ["Full condition 4d", None, None, None], + "conditionexact_5d": ["Full condition 5d", None, None, None], + "symbol_1d": ["Symbol 1d", None, None, None], + "symbol_2d": ["Symbol 2d", None, None, None], + "symbol_3d": ["Symbol 3d", None, None, None], + "symbol_4d": ["Symbol 4d", None, None, None], + "symbol_5d": ["Symbol 5d", None, None, None], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( @@ -471,6 +600,11 @@ class BrSensor(SensorEntity): """Return the unit of measurement of this entity, if any.""" return self._unit_of_measurement + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return SENSOR_TYPES[self.type][3] + @property def icon(self): """Return possible sensor specific icon.""" diff --git a/homeassistant/components/ebusd/const.py b/homeassistant/components/ebusd/const.py index c4ff789202d..7052a9950fd 100644 --- a/homeassistant/components/ebusd/const.py +++ b/homeassistant/components/ebusd/const.py @@ -1,5 +1,6 @@ """Constants for ebus component.""" from homeassistant.const import ( + DEVICE_CLASS_TEMPERATURE, ENERGY_KILO_WATT_HOUR, PERCENTAGE, PRESSURE_BAR, @@ -17,127 +18,243 @@ SENSOR_TYPES = { "ActualFlowTemperatureDesired": [ "Hc1ActualFlowTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, ], "MaxFlowTemperatureDesired": [ "Hc1MaxFlowTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, ], "MinFlowTemperatureDesired": [ "Hc1MinFlowTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, ], - "PumpStatus": ["Hc1PumpStatus", None, "mdi:toggle-switch", 2], + "PumpStatus": ["Hc1PumpStatus", None, "mdi:toggle-switch", 2, None], "HCSummerTemperatureLimit": [ "Hc1SummerTempLimit", TEMP_CELSIUS, "mdi:weather-sunny", 0, + DEVICE_CLASS_TEMPERATURE, + ], + "HolidayTemperature": [ + "HolidayTemp", + TEMP_CELSIUS, + None, + 0, + DEVICE_CLASS_TEMPERATURE, + ], + "HWTemperatureDesired": [ + "HwcTempDesired", + TEMP_CELSIUS, + None, + 0, + DEVICE_CLASS_TEMPERATURE, + ], + "HWActualTemperature": [ + "HwcStorageTemp", + TEMP_CELSIUS, + None, + 0, + DEVICE_CLASS_TEMPERATURE, + ], + "HWTimerMonday": ["hwcTimer.Monday", None, "mdi:timer-outline", 1, None], + "HWTimerTuesday": ["hwcTimer.Tuesday", None, "mdi:timer-outline", 1, None], + "HWTimerWednesday": ["hwcTimer.Wednesday", None, "mdi:timer-outline", 1, None], + "HWTimerThursday": ["hwcTimer.Thursday", None, "mdi:timer-outline", 1, None], + "HWTimerFriday": ["hwcTimer.Friday", None, "mdi:timer-outline", 1, None], + "HWTimerSaturday": ["hwcTimer.Saturday", None, "mdi:timer-outline", 1, None], + "HWTimerSunday": ["hwcTimer.Sunday", None, "mdi:timer-outline", 1, None], + "HWOperativeMode": ["HwcOpMode", None, "mdi:math-compass", 3, None], + "WaterPressure": ["WaterPressure", PRESSURE_BAR, "mdi:water-pump", 0, None], + "Zone1RoomZoneMapping": ["z1RoomZoneMapping", None, "mdi:label", 0, None], + "Zone1NightTemperature": [ + "z1NightTemp", + TEMP_CELSIUS, + "mdi:weather-night", + 0, + DEVICE_CLASS_TEMPERATURE, + ], + "Zone1DayTemperature": [ + "z1DayTemp", + TEMP_CELSIUS, + "mdi:weather-sunny", + 0, + DEVICE_CLASS_TEMPERATURE, ], - "HolidayTemperature": ["HolidayTemp", TEMP_CELSIUS, "mdi:thermometer", 0], - "HWTemperatureDesired": ["HwcTempDesired", TEMP_CELSIUS, "mdi:thermometer", 0], - "HWActualTemperature": ["HwcStorageTemp", TEMP_CELSIUS, "mdi:thermometer", 0], - "HWTimerMonday": ["hwcTimer.Monday", None, "mdi:timer-outline", 1], - "HWTimerTuesday": ["hwcTimer.Tuesday", None, "mdi:timer-outline", 1], - "HWTimerWednesday": ["hwcTimer.Wednesday", None, "mdi:timer-outline", 1], - "HWTimerThursday": ["hwcTimer.Thursday", None, "mdi:timer-outline", 1], - "HWTimerFriday": ["hwcTimer.Friday", None, "mdi:timer-outline", 1], - "HWTimerSaturday": ["hwcTimer.Saturday", None, "mdi:timer-outline", 1], - "HWTimerSunday": ["hwcTimer.Sunday", None, "mdi:timer-outline", 1], - "HWOperativeMode": ["HwcOpMode", None, "mdi:math-compass", 3], - "WaterPressure": ["WaterPressure", PRESSURE_BAR, "mdi:water-pump", 0], - "Zone1RoomZoneMapping": ["z1RoomZoneMapping", None, "mdi:label", 0], - "Zone1NightTemperature": ["z1NightTemp", TEMP_CELSIUS, "mdi:weather-night", 0], - "Zone1DayTemperature": ["z1DayTemp", TEMP_CELSIUS, "mdi:weather-sunny", 0], "Zone1HolidayTemperature": [ "z1HolidayTemp", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, + ], + "Zone1RoomTemperature": [ + "z1RoomTemp", + TEMP_CELSIUS, + None, + 0, + DEVICE_CLASS_TEMPERATURE, ], - "Zone1RoomTemperature": ["z1RoomTemp", TEMP_CELSIUS, "mdi:thermometer", 0], "Zone1ActualRoomTemperatureDesired": [ "z1ActualRoomTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, + ], + "Zone1TimerMonday": ["z1Timer.Monday", None, "mdi:timer-outline", 1, None], + "Zone1TimerTuesday": ["z1Timer.Tuesday", None, "mdi:timer-outline", 1, None], + "Zone1TimerWednesday": [ + "z1Timer.Wednesday", + None, + "mdi:timer-outline", + 1, + None, + ], + "Zone1TimerThursday": ["z1Timer.Thursday", None, "mdi:timer-outline", 1, None], + "Zone1TimerFriday": ["z1Timer.Friday", None, "mdi:timer-outline", 1, None], + "Zone1TimerSaturday": ["z1Timer.Saturday", None, "mdi:timer-outline", 1, None], + "Zone1TimerSunday": ["z1Timer.Sunday", None, "mdi:timer-outline", 1, None], + "Zone1OperativeMode": ["z1OpMode", None, "mdi:math-compass", 3, None], + "ContinuosHeating": [ + "ContinuosHeating", + TEMP_CELSIUS, + "mdi:weather-snowy", + 0, + DEVICE_CLASS_TEMPERATURE, ], - "Zone1TimerMonday": ["z1Timer.Monday", None, "mdi:timer-outline", 1], - "Zone1TimerTuesday": ["z1Timer.Tuesday", None, "mdi:timer-outline", 1], - "Zone1TimerWednesday": ["z1Timer.Wednesday", None, "mdi:timer-outline", 1], - "Zone1TimerThursday": ["z1Timer.Thursday", None, "mdi:timer-outline", 1], - "Zone1TimerFriday": ["z1Timer.Friday", None, "mdi:timer-outline", 1], - "Zone1TimerSaturday": ["z1Timer.Saturday", None, "mdi:timer-outline", 1], - "Zone1TimerSunday": ["z1Timer.Sunday", None, "mdi:timer-outline", 1], - "Zone1OperativeMode": ["z1OpMode", None, "mdi:math-compass", 3], - "ContinuosHeating": ["ContinuosHeating", TEMP_CELSIUS, "mdi:weather-snowy", 0], "PowerEnergyConsumptionLastMonth": [ "PrEnergySumHcLastMonth", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0, + None, ], "PowerEnergyConsumptionThisMonth": [ "PrEnergySumHcThisMonth", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0, + None, ], }, "ehp": { - "HWTemperature": ["HwcTemp", TEMP_CELSIUS, "mdi:thermometer", 4], - "OutsideTemp": ["OutsideTemp", TEMP_CELSIUS, "mdi:thermometer", 4], + "HWTemperature": ["HwcTemp", TEMP_CELSIUS, None, 4, DEVICE_CLASS_TEMPERATURE], + "OutsideTemp": ["OutsideTemp", TEMP_CELSIUS, None, 4, DEVICE_CLASS_TEMPERATURE], }, "bai": { - "HotWaterTemperature": ["HwcTemp", TEMP_CELSIUS, "mdi:thermometer", 4], - "StorageTemperature": ["StorageTemp", TEMP_CELSIUS, "mdi:thermometer", 4], + "HotWaterTemperature": [ + "HwcTemp", + TEMP_CELSIUS, + None, + 4, + DEVICE_CLASS_TEMPERATURE, + ], + "StorageTemperature": [ + "StorageTemp", + TEMP_CELSIUS, + None, + 4, + DEVICE_CLASS_TEMPERATURE, + ], "DesiredStorageTemperature": [ "StorageTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, ], "OutdoorsTemperature": [ "OutdoorstempSensor", TEMP_CELSIUS, - "mdi:thermometer", + None, 4, + DEVICE_CLASS_TEMPERATURE, ], - "WaterPreasure": ["WaterPressure", PRESSURE_BAR, "mdi:pipe", 4], - "AverageIgnitionTime": ["averageIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0], - "MaximumIgnitionTime": ["maxIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0], - "MinimumIgnitionTime": ["minIgnitiontime", TIME_SECONDS, "mdi:av-timer", 0], - "ReturnTemperature": ["ReturnTemp", TEMP_CELSIUS, "mdi:thermometer", 4], - "CentralHeatingPump": ["WP", None, "mdi:toggle-switch", 2], - "HeatingSwitch": ["HeatingSwitch", None, "mdi:toggle-switch", 2], + "WaterPreasure": ["WaterPressure", PRESSURE_BAR, "mdi:pipe", 4, None], + "AverageIgnitionTime": [ + "averageIgnitiontime", + TIME_SECONDS, + "mdi:av-timer", + 0, + None, + ], + "MaximumIgnitionTime": [ + "maxIgnitiontime", + TIME_SECONDS, + "mdi:av-timer", + 0, + None, + ], + "MinimumIgnitionTime": [ + "minIgnitiontime", + TIME_SECONDS, + "mdi:av-timer", + 0, + None, + ], + "ReturnTemperature": [ + "ReturnTemp", + TEMP_CELSIUS, + None, + 4, + DEVICE_CLASS_TEMPERATURE, + ], + "CentralHeatingPump": ["WP", None, "mdi:toggle-switch", 2, None], + "HeatingSwitch": ["HeatingSwitch", None, "mdi:toggle-switch", 2, None], "DesiredFlowTemperature": [ "FlowTempDesired", TEMP_CELSIUS, - "mdi:thermometer", + None, 0, + DEVICE_CLASS_TEMPERATURE, ], - "FlowTemperature": ["FlowTemp", TEMP_CELSIUS, "mdi:thermometer", 4], - "Flame": ["Flame", None, "mdi:toggle-switch", 2], + "FlowTemperature": [ + "FlowTemp", + TEMP_CELSIUS, + None, + 4, + DEVICE_CLASS_TEMPERATURE, + None, + ], + "Flame": ["Flame", None, "mdi:toggle-switch", 2, None], "PowerEnergyConsumptionHeatingCircuit": [ "PrEnergySumHc1", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0, + None, ], "PowerEnergyConsumptionHotWaterCircuit": [ "PrEnergySumHwc1", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0, + None, + ], + "RoomThermostat": ["DCRoomthermostat", None, "mdi:toggle-switch", 2, None], + "HeatingPartLoad": [ + "PartloadHcKW", + ENERGY_KILO_WATT_HOUR, + "mdi:flash", + 0, + None, + ], + "StateNumber": ["StateNumber", None, "mdi:fire", 3, None], + "ModulationPercentage": [ + "ModulationTempDesired", + PERCENTAGE, + "mdi:percent", + 0, + None, ], - "RoomThermostat": ["DCRoomthermostat", None, "mdi:toggle-switch", 2], - "HeatingPartLoad": ["PartloadHcKW", ENERGY_KILO_WATT_HOUR, "mdi:flash", 0], - "StateNumber": ["StateNumber", None, "mdi:fire", 3], - "ModulationPercentage": ["ModulationTempDesired", PERCENTAGE, "mdi:percent", 0], }, } diff --git a/homeassistant/components/ebusd/sensor.py b/homeassistant/components/ebusd/sensor.py index 00f6a6b2b3e..abd9620130d 100644 --- a/homeassistant/components/ebusd/sensor.py +++ b/homeassistant/components/ebusd/sensor.py @@ -41,7 +41,13 @@ class EbusdSensor(SensorEntity): """Initialize the sensor.""" self._state = None self._client_name = name - self._name, self._unit_of_measurement, self._icon, self._type = sensor + ( + self._name, + self._unit_of_measurement, + self._icon, + self._type, + self._device_class, + ) = sensor self.data = data @property @@ -77,6 +83,11 @@ class EbusdSensor(SensorEntity): return schedule return None + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return self._device_class + @property def icon(self): """Icon to use in the frontend, if any.""" diff --git a/homeassistant/components/ecoal_boiler/sensor.py b/homeassistant/components/ecoal_boiler/sensor.py index e1c9308b5a9..9a2fbdd9b87 100644 --- a/homeassistant/components/ecoal_boiler/sensor.py +++ b/homeassistant/components/ecoal_boiler/sensor.py @@ -1,6 +1,6 @@ """Allows reading temperatures from ecoal/esterownik.pl controller.""" from homeassistant.components.sensor import SensorEntity -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS from . import AVAILABLE_SENSORS, DATA_ECOAL_BOILER @@ -37,6 +37,11 @@ class EcoalTempSensor(SensorEntity): """Return the state of the sensor.""" return self._state + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return DEVICE_CLASS_TEMPERATURE + @property def unit_of_measurement(self): """Return the unit of measurement.""" diff --git a/homeassistant/components/eddystone_temperature/sensor.py b/homeassistant/components/eddystone_temperature/sensor.py index 28711821f50..9adb7665753 100644 --- a/homeassistant/components/eddystone_temperature/sensor.py +++ b/homeassistant/components/eddystone_temperature/sensor.py @@ -13,6 +13,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_NAME, + DEVICE_CLASS_TEMPERATURE, EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, STATE_UNKNOWN, @@ -117,6 +118,11 @@ class EddystoneTemp(SensorEntity): """Return the state of the device.""" return self.temperature + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return DEVICE_CLASS_TEMPERATURE + @property def unit_of_measurement(self): """Return the unit the value is expressed in.""" diff --git a/homeassistant/components/eight_sleep/sensor.py b/homeassistant/components/eight_sleep/sensor.py index ae0854ec244..01413ceaec0 100644 --- a/homeassistant/components/eight_sleep/sensor.py +++ b/homeassistant/components/eight_sleep/sensor.py @@ -2,7 +2,12 @@ import logging from homeassistant.components.sensor import SensorEntity -from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT +from homeassistant.const import ( + DEVICE_CLASS_TEMPERATURE, + PERCENTAGE, + TEMP_CELSIUS, + TEMP_FAHRENHEIT, +) from . import ( CONF_SENSORS, @@ -172,10 +177,11 @@ class EightUserSensor(EightSleepUserEntity, SensorEntity): return None @property - def icon(self): - """Icon to use in the frontend, if any.""" + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" if "bed_temp" in self._sensor: - return "mdi:thermometer" + return DEVICE_CLASS_TEMPERATURE + return None async def async_update(self): """Retrieve latest state.""" @@ -334,6 +340,6 @@ class EightRoomSensor(EightSleepUserEntity, SensorEntity): return TEMP_FAHRENHEIT @property - def icon(self): - """Icon to use in the frontend, if any.""" - return "mdi:thermometer" + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return DEVICE_CLASS_TEMPERATURE diff --git a/homeassistant/components/environment_canada/sensor.py b/homeassistant/components/environment_canada/sensor.py index 0f0fb04fd00..232bc558da1 100644 --- a/homeassistant/components/environment_canada/sensor.py +++ b/homeassistant/components/environment_canada/sensor.py @@ -12,6 +12,7 @@ from homeassistant.const import ( ATTR_LOCATION, CONF_LATITUDE, CONF_LONGITUDE, + DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS, ) import homeassistant.helpers.config_validation as cv @@ -77,6 +78,7 @@ class ECSensor(SensorEntity): self._state = None self._attr = None self._unit = None + self._device_class = None @property def unique_id(self) -> str: @@ -103,6 +105,11 @@ class ECSensor(SensorEntity): """Return the units of measurement.""" return self._unit + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return self._device_class + def update(self): """Update current conditions.""" self.ec_data.update() @@ -135,6 +142,7 @@ class ECSensor(SensorEntity): "humidex", ]: self._unit = TEMP_CELSIUS + self._device_class = DEVICE_CLASS_TEMPERATURE else: self._unit = sensor_data.get("unit") diff --git a/homeassistant/components/envirophat/sensor.py b/homeassistant/components/envirophat/sensor.py index 137d6aee853..4e10b5e65d1 100644 --- a/homeassistant/components/envirophat/sensor.py +++ b/homeassistant/components/envirophat/sensor.py @@ -9,6 +9,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.const import ( CONF_DISPLAY_OPTIONS, CONF_NAME, + DEVICE_CLASS_TEMPERATURE, PRESSURE_HPA, TEMP_CELSIUS, VOLT, @@ -24,22 +25,22 @@ CONF_USE_LEDS = "use_leds" MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=60) SENSOR_TYPES = { - "light": ["light", " ", "mdi:weather-sunny"], - "light_red": ["light_red", " ", "mdi:invert-colors"], - "light_green": ["light_green", " ", "mdi:invert-colors"], - "light_blue": ["light_blue", " ", "mdi:invert-colors"], - "accelerometer_x": ["accelerometer_x", "G", "mdi:earth"], - "accelerometer_y": ["accelerometer_y", "G", "mdi:earth"], - "accelerometer_z": ["accelerometer_z", "G", "mdi:earth"], - "magnetometer_x": ["magnetometer_x", " ", "mdi:magnet"], - "magnetometer_y": ["magnetometer_y", " ", "mdi:magnet"], - "magnetometer_z": ["magnetometer_z", " ", "mdi:magnet"], - "temperature": ["temperature", TEMP_CELSIUS, "mdi:thermometer"], - "pressure": ["pressure", PRESSURE_HPA, "mdi:gauge"], - "voltage_0": ["voltage_0", VOLT, "mdi:flash"], - "voltage_1": ["voltage_1", VOLT, "mdi:flash"], - "voltage_2": ["voltage_2", VOLT, "mdi:flash"], - "voltage_3": ["voltage_3", VOLT, "mdi:flash"], + "light": ["light", " ", "mdi:weather-sunny", None], + "light_red": ["light_red", " ", "mdi:invert-colors", None], + "light_green": ["light_green", " ", "mdi:invert-colors", None], + "light_blue": ["light_blue", " ", "mdi:invert-colors", None], + "accelerometer_x": ["accelerometer_x", "G", "mdi:earth", None], + "accelerometer_y": ["accelerometer_y", "G", "mdi:earth", None], + "accelerometer_z": ["accelerometer_z", "G", "mdi:earth", None], + "magnetometer_x": ["magnetometer_x", " ", "mdi:magnet", None], + "magnetometer_y": ["magnetometer_y", " ", "mdi:magnet", None], + "magnetometer_z": ["magnetometer_z", " ", "mdi:magnet", None], + "temperature": ["temperature", TEMP_CELSIUS, None, DEVICE_CLASS_TEMPERATURE], + "pressure": ["pressure", PRESSURE_HPA, "mdi:gauge", None], + "voltage_0": ["voltage_0", VOLT, "mdi:flash", None], + "voltage_1": ["voltage_1", VOLT, "mdi:flash", None], + "voltage_2": ["voltage_2", VOLT, "mdi:flash", None], + "voltage_3": ["voltage_3", VOLT, "mdi:flash", None], } PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( @@ -91,6 +92,11 @@ class EnvirophatSensor(SensorEntity): """Return the state of the sensor.""" return self._state + @property + def device_class(self): + """Return the class of this device, from component DEVICE_CLASSES.""" + return SENSOR_TYPES[self.type][3] + @property def icon(self): """Icon to use in the frontend, if any."""