From 7e6392f062a015c344a634a703c3e1224766d1dc Mon Sep 17 00:00:00 2001 From: Jonas Fors Lellky Date: Fri, 20 Dec 2024 10:11:50 +0100 Subject: [PATCH] Define setpoints as constants in flexit_bacnet (#133580) * Define setpoints as consts * Use a regular comment instead of docstring * Un-indent comment --- .../components/flexit_bacnet/number.py | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/flexit_bacnet/number.py b/homeassistant/components/flexit_bacnet/number.py index 029ce896445..6e405e8e8ac 100644 --- a/homeassistant/components/flexit_bacnet/number.py +++ b/homeassistant/components/flexit_bacnet/number.py @@ -23,6 +23,9 @@ from . import FlexitCoordinator from .const import DOMAIN from .entity import FlexitEntity +_MAX_FAN_SETPOINT = 100 +_MIN_FAN_SETPOINT = 30 + @dataclass(kw_only=True, frozen=True) class FlexitNumberEntityDescription(NumberEntityDescription): @@ -34,6 +37,24 @@ class FlexitNumberEntityDescription(NumberEntityDescription): set_native_value_fn: Callable[[FlexitBACnet], Callable[[int], Awaitable[None]]] +# Setpoints for Away, Home and High are dependent of each other. Fireplace and Cooker Hood +# have setpoints between 0 (MIN_FAN_SETPOINT) and 100 (MAX_FAN_SETPOINT). +# See the table below for all the setpoints. +# +# | Mode | Setpoint | Min | Max | +# |:------------|----------|:----------------------|:----------------------| +# | HOME | Supply | AWAY Supply setpoint | 100 | +# | HOME | Extract | AWAY Extract setpoint | 100 | +# | AWAY | Supply | 30 | HOME Supply setpoint | +# | AWAY | Extract | 30 | HOME Extract setpoint | +# | HIGH | Supply | HOME Supply setpoint | 100 | +# | HIGH | Extract | HOME Extract setpoint | 100 | +# | COOKER_HOOD | Supply | 30 | 100 | +# | COOKER_HOOD | Extract | 30 | 100 | +# | FIREPLACE | Supply | 30 | 100 | +# | FIREPLACE | Extract | 30 | 100 | + + NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( FlexitNumberEntityDescription( key="away_extract_fan_setpoint", @@ -45,7 +66,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_away, native_unit_of_measurement=PERCENTAGE, native_max_value_fn=lambda device: int(device.fan_setpoint_extract_air_home), - native_min_value_fn=lambda _: 30, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="away_supply_fan_setpoint", @@ -57,7 +78,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_away, native_unit_of_measurement=PERCENTAGE, native_max_value_fn=lambda device: int(device.fan_setpoint_supply_air_home), - native_min_value_fn=lambda _: 30, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="cooker_hood_extract_fan_setpoint", @@ -68,8 +89,8 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_extract_air_cooker, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_cooker, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, - native_min_value_fn=lambda _: 30, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="cooker_hood_supply_fan_setpoint", @@ -80,8 +101,8 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_supply_air_cooker, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_cooker, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, - native_min_value_fn=lambda _: 30, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="fireplace_extract_fan_setpoint", @@ -92,8 +113,8 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_extract_air_fire, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_fire, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, - native_min_value_fn=lambda _: 30, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="fireplace_supply_fan_setpoint", @@ -104,8 +125,8 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_supply_air_fire, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_fire, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, - native_min_value_fn=lambda _: 30, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, + native_min_value_fn=lambda _: _MIN_FAN_SETPOINT, ), FlexitNumberEntityDescription( key="high_extract_fan_setpoint", @@ -116,7 +137,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_extract_air_high, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_high, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, native_min_value_fn=lambda device: int(device.fan_setpoint_extract_air_home), ), FlexitNumberEntityDescription( @@ -128,7 +149,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_supply_air_high, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_high, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, native_min_value_fn=lambda device: int(device.fan_setpoint_supply_air_home), ), FlexitNumberEntityDescription( @@ -140,7 +161,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_extract_air_home, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_home, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, native_min_value_fn=lambda device: int(device.fan_setpoint_extract_air_away), ), FlexitNumberEntityDescription( @@ -152,7 +173,7 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = ( native_value_fn=lambda device: device.fan_setpoint_supply_air_home, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_home, native_unit_of_measurement=PERCENTAGE, - native_max_value_fn=lambda _: 100, + native_max_value_fn=lambda _: _MAX_FAN_SETPOINT, native_min_value_fn=lambda device: int(device.fan_setpoint_supply_air_away), ), )