diff --git a/homeassistant/components/vallox/sensor.py b/homeassistant/components/vallox/sensor.py index 48b44dd97fe..d3357e50ad2 100644 --- a/homeassistant/components/vallox/sensor.py +++ b/homeassistant/components/vallox/sensor.py @@ -13,6 +13,7 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, + FREQUENCY_HERTZ, PERCENTAGE, TEMP_CELSIUS, ) @@ -32,7 +33,7 @@ from .const import ( ) -class ValloxSensor(ValloxEntity, SensorEntity): +class ValloxSensorEntity(ValloxEntity, SensorEntity): """Representation of a Vallox sensor.""" entity_description: ValloxSensorEntityDescription @@ -58,10 +59,17 @@ class ValloxSensor(ValloxEntity, SensorEntity): if (metric_key := self.entity_description.metric_key) is 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.""" @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 # it is not in regular operation mode. -class ValloxFanSpeedSensor(ValloxSensor): +class ValloxFanSpeedSensor(ValloxSensorEntity): """Child class for fan speed reporting.""" @property @@ -87,7 +95,7 @@ class ValloxFanSpeedSensor(ValloxSensor): return super().native_value if fan_is_on else 0 -class ValloxFilterRemainingSensor(ValloxSensor): +class ValloxFilterRemainingSensor(ValloxSensorEntity): """Child class for filter remaining time reporting.""" @property @@ -104,7 +112,7 @@ class ValloxFilterRemainingSensor(ValloxSensor): ) -class ValloxCellStateSensor(ValloxSensor): +class ValloxCellStateSensor(ValloxSensorEntity): """Child class for cell state reporting.""" @property @@ -123,15 +131,16 @@ class ValloxSensorEntityDescription(SensorEntityDescription): """Describes Vallox sensor entity.""" 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( key="current_profile", name="Current profile", icon="mdi:gauge", - sensor_type=ValloxProfileSensor, + entity_type=ValloxProfileSensor, ), ValloxSensorEntityDescription( key="fan_speed", @@ -140,20 +149,40 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = ( icon="mdi:fan", state_class=SensorStateClass.MEASUREMENT, 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( key="remaining_time_for_filter", name="Remaining time for filter", device_class=SensorDeviceClass.TIMESTAMP, - sensor_type=ValloxFilterRemainingSensor, + entity_type=ValloxFilterRemainingSensor, ), ValloxSensorEntityDescription( key="cell_state", name="Cell state", icon="mdi:swap-horizontal-bold", metric_key="A_CYC_CELL_STATE", - sensor_type=ValloxCellStateSensor, + entity_type=ValloxCellStateSensor, ), ValloxSensorEntityDescription( key="extract_air", @@ -187,6 +216,23 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, 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( key="humidity", name="Humidity", @@ -202,6 +248,8 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = ( icon="mdi:gauge", state_class=SensorStateClass.MEASUREMENT, native_unit_of_measurement=PERCENTAGE, + entity_registry_enabled_default=False, + round_ndigits=0, ), ValloxSensorEntityDescription( key="co2", @@ -210,6 +258,7 @@ SENSORS: tuple[ValloxSensorEntityDescription, ...] = ( device_class=SensorDeviceClass.CO2, state_class=SensorStateClass.MEASUREMENT, 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( [ - description.sensor_type(name, coordinator, description) - for description in SENSORS + description.entity_type(name, coordinator, description) + for description in SENSOR_ENTITIES ] )