Set device_class on temperature sensors L-Q (#52919)
This commit is contained in:
parent
0a3aab935a
commit
d1f3c20079
8 changed files with 143 additions and 64 deletions
|
@ -31,14 +31,20 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||
sensors = []
|
||||
for sensor_type in luftdaten.sensor_conditions:
|
||||
try:
|
||||
name, icon, unit = SENSORS[sensor_type]
|
||||
name, icon, unit, device_class = SENSORS[sensor_type]
|
||||
except KeyError:
|
||||
_LOGGER.debug("Unknown sensor value type: %s", sensor_type)
|
||||
continue
|
||||
|
||||
sensors.append(
|
||||
LuftdatenSensor(
|
||||
luftdaten, sensor_type, name, icon, unit, entry.data[CONF_SHOW_ON_MAP]
|
||||
luftdaten,
|
||||
sensor_type,
|
||||
name,
|
||||
icon,
|
||||
unit,
|
||||
device_class,
|
||||
entry.data[CONF_SHOW_ON_MAP],
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -48,7 +54,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
|
|||
class LuftdatenSensor(SensorEntity):
|
||||
"""Implementation of a Luftdaten sensor."""
|
||||
|
||||
def __init__(self, luftdaten, sensor_type, name, icon, unit, show):
|
||||
def __init__(self, luftdaten, sensor_type, name, icon, unit, device_class, show):
|
||||
"""Initialize the Luftdaten sensor."""
|
||||
self._async_unsub_dispatcher_connect = None
|
||||
self.luftdaten = luftdaten
|
||||
|
@ -59,6 +65,7 @@ class LuftdatenSensor(SensorEntity):
|
|||
self._unit_of_measurement = unit
|
||||
self._show_on_map = show
|
||||
self._attrs = {}
|
||||
self._attr_device_class = device_class
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue