mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Add new vallox temperature and fan sensors (#75783)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
51c3836ec2
commit
a4d4170279
@ -13,6 +13,7 @@ from homeassistant.components.sensor import (
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
FREQUENCY_HERTZ,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
@ -32,7 +33,7 @@ from .const import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValloxSensor(ValloxEntity, SensorEntity):
|
class ValloxSensorEntity(ValloxEntity, SensorEntity):
|
||||||
"""Representation of a Vallox sensor."""
|
"""Representation of a Vallox sensor."""
|
||||||
|
|
||||||
entity_description: ValloxSensorEntityDescription
|
entity_description: ValloxSensorEntityDescription
|
||||||
@ -58,10 +59,17 @@ class ValloxSensor(ValloxEntity, SensorEntity):
|
|||||||
if (metric_key := self.entity_description.metric_key) is None:
|
if (metric_key := self.entity_description.metric_key) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return self.coordinator.data.get_metric(metric_key)
|
value = self.coordinator.data.get_metric(metric_key)
|
||||||
|
|
||||||
|
if self.entity_description.round_ndigits is not None and isinstance(
|
||||||
|
value, float
|
||||||
|
):
|
||||||
|
value = round(value, self.entity_description.round_ndigits)
|
||||||
|
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class ValloxProfileSensor(ValloxSensor):
|
class ValloxProfileSensor(ValloxSensorEntity):
|
||||||
"""Child class for profile reporting."""
|
"""Child class for profile reporting."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -77,7 +85,7 @@ class ValloxProfileSensor(ValloxSensor):
|
|||||||
#
|
#
|
||||||
# Therefore, first query the overall state of the device, and report zero percent fan speed in case
|
# Therefore, first query the overall state of the device, and report zero percent fan speed in case
|
||||||
# it is not in regular operation mode.
|
# it is not in regular operation mode.
|
||||||
class ValloxFanSpeedSensor(ValloxSensor):
|
class ValloxFanSpeedSensor(ValloxSensorEntity):
|
||||||
"""Child class for fan speed reporting."""
|
"""Child class for fan speed reporting."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -87,7 +95,7 @@ class ValloxFanSpeedSensor(ValloxSensor):
|
|||||||
return super().native_value if fan_is_on else 0
|
return super().native_value if fan_is_on else 0
|
||||||
|
|
||||||
|
|
||||||
class ValloxFilterRemainingSensor(ValloxSensor):
|
class ValloxFilterRemainingSensor(ValloxSensorEntity):
|
||||||
"""Child class for filter remaining time reporting."""
|
"""Child class for filter remaining time reporting."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -104,7 +112,7 @@ class ValloxFilterRemainingSensor(ValloxSensor):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class ValloxCellStateSensor(ValloxSensor):
|
class ValloxCellStateSensor(ValloxSensorEntity):
|
||||||
"""Child class for cell state reporting."""
|
"""Child class for cell state reporting."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -123,15 +131,16 @@ class ValloxSensorEntityDescription(SensorEntityDescription):
|
|||||||
"""Describes Vallox sensor entity."""
|
"""Describes Vallox sensor entity."""
|
||||||
|
|
||||||
metric_key: str | None = None
|
metric_key: str | None = None
|
||||||
sensor_type: type[ValloxSensor] = ValloxSensor
|
entity_type: type[ValloxSensorEntity] = ValloxSensorEntity
|
||||||
|
round_ndigits: int | None = None
|
||||||
|
|
||||||
|
|
||||||
SENSORS: tuple[ValloxSensorEntityDescription, ...] = (
|
SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="current_profile",
|
key="current_profile",
|
||||||
name="Current profile",
|
name="Current profile",
|
||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
sensor_type=ValloxProfileSensor,
|
entity_type=ValloxProfileSensor,
|
||||||
),
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="fan_speed",
|
key="fan_speed",
|
||||||
@ -140,20 +149,40 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:fan",
|
icon="mdi:fan",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
sensor_type=ValloxFanSpeedSensor,
|
entity_type=ValloxFanSpeedSensor,
|
||||||
|
),
|
||||||
|
ValloxSensorEntityDescription(
|
||||||
|
key="extract_fan_speed",
|
||||||
|
name="Extract fan speed",
|
||||||
|
metric_key="A_CYC_EXTR_FAN_SPEED",
|
||||||
|
icon="mdi:fan",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
entity_type=ValloxFanSpeedSensor,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
|
ValloxSensorEntityDescription(
|
||||||
|
key="supply_fan_speed",
|
||||||
|
name="Supply fan speed",
|
||||||
|
metric_key="A_CYC_SUPP_FAN_SPEED",
|
||||||
|
icon="mdi:fan",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
|
entity_type=ValloxFanSpeedSensor,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="remaining_time_for_filter",
|
key="remaining_time_for_filter",
|
||||||
name="Remaining time for filter",
|
name="Remaining time for filter",
|
||||||
device_class=SensorDeviceClass.TIMESTAMP,
|
device_class=SensorDeviceClass.TIMESTAMP,
|
||||||
sensor_type=ValloxFilterRemainingSensor,
|
entity_type=ValloxFilterRemainingSensor,
|
||||||
),
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="cell_state",
|
key="cell_state",
|
||||||
name="Cell state",
|
name="Cell state",
|
||||||
icon="mdi:swap-horizontal-bold",
|
icon="mdi:swap-horizontal-bold",
|
||||||
metric_key="A_CYC_CELL_STATE",
|
metric_key="A_CYC_CELL_STATE",
|
||||||
sensor_type=ValloxCellStateSensor,
|
entity_type=ValloxCellStateSensor,
|
||||||
),
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="extract_air",
|
key="extract_air",
|
||||||
@ -187,6 +216,23 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = (
|
|||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
|
ValloxSensorEntityDescription(
|
||||||
|
key="supply_cell_air",
|
||||||
|
name="Supply cell air",
|
||||||
|
metric_key="A_CYC_TEMP_SUPPLY_CELL_AIR",
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
),
|
||||||
|
ValloxSensorEntityDescription(
|
||||||
|
key="optional_air",
|
||||||
|
name="Optional air",
|
||||||
|
metric_key="A_CYC_TEMP_OPTIONAL",
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="humidity",
|
key="humidity",
|
||||||
name="Humidity",
|
name="Humidity",
|
||||||
@ -202,6 +248,8 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = (
|
|||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
|
round_ndigits=0,
|
||||||
),
|
),
|
||||||
ValloxSensorEntityDescription(
|
ValloxSensorEntityDescription(
|
||||||
key="co2",
|
key="co2",
|
||||||
@ -210,6 +258,7 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.CO2,
|
device_class=SensorDeviceClass.CO2,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||||
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -223,7 +272,7 @@ async def async_setup_entry(
|
|||||||
|
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
description.sensor_type(name, coordinator, description)
|
description.entity_type(name, coordinator, description)
|
||||||
for description in SENSORS
|
for description in SENSOR_ENTITIES
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user