mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add state class to nexia sensors (#64932)
This commit is contained in:
parent
09982afd2e
commit
a6b26dbec4
@ -3,7 +3,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from nexia.const import UNIT_CELSIUS
|
from nexia.const import UNIT_CELSIUS
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import (
|
||||||
|
SensorDeviceClass,
|
||||||
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -38,6 +42,7 @@ async def async_setup_entry(
|
|||||||
"System Status",
|
"System Status",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Air cleaner
|
# Air cleaner
|
||||||
@ -49,6 +54,7 @@ async def async_setup_entry(
|
|||||||
"Air Cleaner Mode",
|
"Air Cleaner Mode",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Compressor Speed
|
# Compressor Speed
|
||||||
@ -61,6 +67,7 @@ async def async_setup_entry(
|
|||||||
"Current Compressor Speed",
|
"Current Compressor Speed",
|
||||||
None,
|
None,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
percent_conv,
|
percent_conv,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -72,6 +79,7 @@ async def async_setup_entry(
|
|||||||
"Requested Compressor Speed",
|
"Requested Compressor Speed",
|
||||||
None,
|
None,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
percent_conv,
|
percent_conv,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -90,6 +98,7 @@ async def async_setup_entry(
|
|||||||
"Outdoor Temperature",
|
"Outdoor Temperature",
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
unit,
|
unit,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Relative Humidity
|
# Relative Humidity
|
||||||
@ -102,6 +111,7 @@ async def async_setup_entry(
|
|||||||
"Relative Humidity",
|
"Relative Humidity",
|
||||||
SensorDeviceClass.HUMIDITY,
|
SensorDeviceClass.HUMIDITY,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
percent_conv,
|
percent_conv,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -123,18 +133,14 @@ async def async_setup_entry(
|
|||||||
"Temperature",
|
"Temperature",
|
||||||
SensorDeviceClass.TEMPERATURE,
|
SensorDeviceClass.TEMPERATURE,
|
||||||
unit,
|
unit,
|
||||||
|
SensorStateClass.MEASUREMENT,
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Zone Status
|
# Zone Status
|
||||||
entities.append(
|
entities.append(
|
||||||
NexiaThermostatZoneSensor(
|
NexiaThermostatZoneSensor(
|
||||||
coordinator,
|
coordinator, zone, "get_status", "Zone Status", None, None, None
|
||||||
zone,
|
|
||||||
"get_status",
|
|
||||||
"Zone Status",
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
# Setpoint Status
|
# Setpoint Status
|
||||||
@ -146,6 +152,7 @@ async def async_setup_entry(
|
|||||||
"Zone Setpoint Status",
|
"Zone Setpoint Status",
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -163,6 +170,7 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||||||
sensor_name,
|
sensor_name,
|
||||||
sensor_class,
|
sensor_class,
|
||||||
sensor_unit,
|
sensor_unit,
|
||||||
|
state_class,
|
||||||
modifier=None,
|
modifier=None,
|
||||||
):
|
):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
@ -173,15 +181,10 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||||||
unique_id=f"{thermostat.thermostat_id}_{sensor_call}",
|
unique_id=f"{thermostat.thermostat_id}_{sensor_call}",
|
||||||
)
|
)
|
||||||
self._call = sensor_call
|
self._call = sensor_call
|
||||||
self._class = sensor_class
|
|
||||||
self._state = None
|
|
||||||
self._unit_of_measurement = sensor_unit
|
|
||||||
self._modifier = modifier
|
self._modifier = modifier
|
||||||
|
self._attr_device_class = sensor_class
|
||||||
@property
|
self._attr_native_unit_of_measurement = sensor_unit
|
||||||
def device_class(self):
|
self._attr_state_class = state_class
|
||||||
"""Return the device class of the sensor."""
|
|
||||||
return self._class
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
@ -193,11 +196,6 @@ class NexiaThermostatSensor(NexiaThermostatEntity, SensorEntity):
|
|||||||
val = round(val, 1)
|
val = round(val, 1)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit of measurement this sensor expresses itself in."""
|
|
||||||
return self._unit_of_measurement
|
|
||||||
|
|
||||||
|
|
||||||
class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
||||||
"""Nexia Zone Sensor Support."""
|
"""Nexia Zone Sensor Support."""
|
||||||
@ -210,6 +208,7 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||||||
sensor_name,
|
sensor_name,
|
||||||
sensor_class,
|
sensor_class,
|
||||||
sensor_unit,
|
sensor_unit,
|
||||||
|
state_class,
|
||||||
modifier=None,
|
modifier=None,
|
||||||
):
|
):
|
||||||
"""Create a zone sensor."""
|
"""Create a zone sensor."""
|
||||||
@ -221,15 +220,10 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||||||
unique_id=f"{zone.zone_id}_{sensor_call}",
|
unique_id=f"{zone.zone_id}_{sensor_call}",
|
||||||
)
|
)
|
||||||
self._call = sensor_call
|
self._call = sensor_call
|
||||||
self._class = sensor_class
|
|
||||||
self._state = None
|
|
||||||
self._unit_of_measurement = sensor_unit
|
|
||||||
self._modifier = modifier
|
self._modifier = modifier
|
||||||
|
self._attr_device_class = sensor_class
|
||||||
@property
|
self._attr_native_unit_of_measurement = sensor_unit
|
||||||
def device_class(self):
|
self._attr_state_class = state_class
|
||||||
"""Return the device class of the sensor."""
|
|
||||||
return self._class
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
@ -240,8 +234,3 @@ class NexiaThermostatZoneSensor(NexiaThermostatZoneEntity, SensorEntity):
|
|||||||
if isinstance(val, float):
|
if isinstance(val, float):
|
||||||
val = round(val, 1)
|
val = round(val, 1)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
@property
|
|
||||||
def native_unit_of_measurement(self):
|
|
||||||
"""Return the unit of measurement this sensor expresses itself in."""
|
|
||||||
return self._unit_of_measurement
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user