Set device_class on additional temperature sensors (#52960)
* Set device_class on additional temperature sensors * Apply suggestions from code review Co-authored-by: Tobias Sauerwein <cgtobi@users.noreply.github.com> * Set device class for greeneye_monitor sensor * Set device class for bme280 and bme680 sensor Co-authored-by: Tobias Sauerwein <cgtobi@users.noreply.github.com>
This commit is contained in:
parent
96f6e0e4a4
commit
e563dc0d7b
11 changed files with 74 additions and 25 deletions
|
@ -1,7 +1,12 @@
|
|||
"""Support for Waterfurnace."""
|
||||
|
||||
from homeassistant.components.sensor import ENTITY_ID_FORMAT, SensorEntity
|
||||
from homeassistant.const import PERCENTAGE, POWER_WATT, TEMP_FAHRENHEIT
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_FAHRENHEIT,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.util import slugify
|
||||
|
||||
|
@ -12,9 +17,15 @@ class WFSensorConfig:
|
|||
"""Water Furnace Sensor configuration."""
|
||||
|
||||
def __init__(
|
||||
self, friendly_name, field, icon="mdi:gauge", unit_of_measurement=None
|
||||
self,
|
||||
friendly_name,
|
||||
field,
|
||||
icon="mdi:gauge",
|
||||
unit_of_measurement=None,
|
||||
device_class=None,
|
||||
):
|
||||
"""Initialize configuration."""
|
||||
self.device_class = device_class
|
||||
self.friendly_name = friendly_name
|
||||
self.field = field
|
||||
self.icon = icon
|
||||
|
@ -25,13 +36,19 @@ SENSORS = [
|
|||
WFSensorConfig("Furnace Mode", "mode"),
|
||||
WFSensorConfig("Total Power", "totalunitpower", "mdi:flash", POWER_WATT),
|
||||
WFSensorConfig(
|
||||
"Active Setpoint", "tstatactivesetpoint", "mdi:thermometer", TEMP_FAHRENHEIT
|
||||
"Active Setpoint",
|
||||
"tstatactivesetpoint",
|
||||
None,
|
||||
TEMP_FAHRENHEIT,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
),
|
||||
WFSensorConfig("Leaving Air", "leavingairtemp", "mdi:thermometer", TEMP_FAHRENHEIT),
|
||||
WFSensorConfig("Room Temp", "tstatroomtemp", "mdi:thermometer", TEMP_FAHRENHEIT),
|
||||
WFSensorConfig(
|
||||
"Loop Temp", "enteringwatertemp", "mdi:thermometer", TEMP_FAHRENHEIT
|
||||
"Leaving Air", "leavingairtemp", None, TEMP_FAHRENHEIT, DEVICE_CLASS_TEMPERATURE
|
||||
),
|
||||
WFSensorConfig(
|
||||
"Room Temp", "tstatroomtemp", None, TEMP_FAHRENHEIT, DEVICE_CLASS_TEMPERATURE
|
||||
),
|
||||
WFSensorConfig("Loop Temp", "enteringwatertemp", None, TEMP_FAHRENHEIT),
|
||||
WFSensorConfig(
|
||||
"Humidity Set Point", "tstathumidsetpoint", "mdi:water-percent", PERCENTAGE
|
||||
),
|
||||
|
@ -71,6 +88,7 @@ class WaterFurnaceSensor(SensorEntity):
|
|||
self._state = None
|
||||
self._icon = config.icon
|
||||
self._unit_of_measurement = config.unit_of_measurement
|
||||
self._attr_device_class = config.device_class
|
||||
|
||||
# This ensures that the sensors are isolated per waterfurnace unit
|
||||
self.entity_id = ENTITY_ID_FORMAT.format(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue