Fix fan setpoints for flexit_bacnet (#133388)

This commit is contained in:
Jonas Fors Lellky 2024-12-17 11:36:45 +01:00 committed by GitHub
parent 084ef20695
commit ce0117b2b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 80 additions and 68 deletions

View File

@ -29,6 +29,8 @@ class FlexitNumberEntityDescription(NumberEntityDescription):
"""Describes a Flexit number entity.""" """Describes a Flexit number entity."""
native_value_fn: Callable[[FlexitBACnet], float] native_value_fn: Callable[[FlexitBACnet], float]
native_max_value_fn: Callable[[FlexitBACnet], int]
native_min_value_fn: Callable[[FlexitBACnet], int]
set_native_value_fn: Callable[[FlexitBACnet], Callable[[int], Awaitable[None]]] set_native_value_fn: Callable[[FlexitBACnet], Callable[[int], Awaitable[None]]]
@ -37,121 +39,121 @@ NUMBERS: tuple[FlexitNumberEntityDescription, ...] = (
key="away_extract_fan_setpoint", key="away_extract_fan_setpoint",
translation_key="away_extract_fan_setpoint", translation_key="away_extract_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_extract_air_away, native_value_fn=lambda device: device.fan_setpoint_extract_air_away,
set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_away, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_away,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda device: int(device.fan_setpoint_extract_air_home),
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="away_supply_fan_setpoint", key="away_supply_fan_setpoint",
translation_key="away_supply_fan_setpoint", translation_key="away_supply_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_supply_air_away, native_value_fn=lambda device: device.fan_setpoint_supply_air_away,
set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_away, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_away,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda device: int(device.fan_setpoint_supply_air_home),
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="cooker_hood_extract_fan_setpoint", key="cooker_hood_extract_fan_setpoint",
translation_key="cooker_hood_extract_fan_setpoint", translation_key="cooker_hood_extract_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_extract_air_cooker, native_value_fn=lambda device: device.fan_setpoint_extract_air_cooker,
set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_cooker, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_cooker,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="cooker_hood_supply_fan_setpoint", key="cooker_hood_supply_fan_setpoint",
translation_key="cooker_hood_supply_fan_setpoint", translation_key="cooker_hood_supply_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_supply_air_cooker, native_value_fn=lambda device: device.fan_setpoint_supply_air_cooker,
set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_cooker, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_cooker,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="fireplace_extract_fan_setpoint", key="fireplace_extract_fan_setpoint",
translation_key="fireplace_extract_fan_setpoint", translation_key="fireplace_extract_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_extract_air_fire, native_value_fn=lambda device: device.fan_setpoint_extract_air_fire,
set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_fire, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_fire,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="fireplace_supply_fan_setpoint", key="fireplace_supply_fan_setpoint",
translation_key="fireplace_supply_fan_setpoint", translation_key="fireplace_supply_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_supply_air_fire, native_value_fn=lambda device: device.fan_setpoint_supply_air_fire,
set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_fire, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_fire,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda _: 30,
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="high_extract_fan_setpoint", key="high_extract_fan_setpoint",
translation_key="high_extract_fan_setpoint", translation_key="high_extract_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_extract_air_high, native_value_fn=lambda device: device.fan_setpoint_extract_air_high,
set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_high, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_high,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda device: int(device.fan_setpoint_extract_air_home),
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="high_supply_fan_setpoint", key="high_supply_fan_setpoint",
translation_key="high_supply_fan_setpoint", translation_key="high_supply_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_supply_air_high, native_value_fn=lambda device: device.fan_setpoint_supply_air_high,
set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_high, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_high,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda device: int(device.fan_setpoint_supply_air_home),
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="home_extract_fan_setpoint", key="home_extract_fan_setpoint",
translation_key="home_extract_fan_setpoint", translation_key="home_extract_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_extract_air_home, native_value_fn=lambda device: device.fan_setpoint_extract_air_home,
set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_home, set_native_value_fn=lambda device: device.set_fan_setpoint_extract_air_home,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda device: int(device.fan_setpoint_extract_air_away),
), ),
FlexitNumberEntityDescription( FlexitNumberEntityDescription(
key="home_supply_fan_setpoint", key="home_supply_fan_setpoint",
translation_key="home_supply_fan_setpoint", translation_key="home_supply_fan_setpoint",
device_class=NumberDeviceClass.POWER_FACTOR, device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=0,
native_max_value=100,
native_step=1, native_step=1,
mode=NumberMode.SLIDER, mode=NumberMode.SLIDER,
native_value_fn=lambda device: device.fan_setpoint_supply_air_home, native_value_fn=lambda device: device.fan_setpoint_supply_air_home,
set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_home, set_native_value_fn=lambda device: device.set_fan_setpoint_supply_air_home,
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
native_max_value_fn=lambda _: 100,
native_min_value_fn=lambda device: int(device.fan_setpoint_supply_air_away),
), ),
) )
@ -192,6 +194,16 @@ class FlexitNumber(FlexitEntity, NumberEntity):
"""Return the state of the number.""" """Return the state of the number."""
return self.entity_description.native_value_fn(self.coordinator.device) return self.entity_description.native_value_fn(self.coordinator.device)
@property
def native_max_value(self) -> float:
"""Return the native max value of the number."""
return self.entity_description.native_max_value_fn(self.coordinator.device)
@property
def native_min_value(self) -> float:
"""Return the native min value of the number."""
return self.entity_description.native_min_value_fn(self.coordinator.device)
async def async_set_native_value(self, value: float) -> None: async def async_set_native_value(self, value: float) -> None:
"""Update the current value.""" """Update the current value."""
set_native_value_fn = self.entity_description.set_native_value_fn( set_native_value_fn = self.entity_description.set_native_value_fn(

View File

@ -69,16 +69,16 @@ def mock_flexit_bacnet() -> Generator[AsyncMock]:
flexit_bacnet.electric_heater = True flexit_bacnet.electric_heater = True
# Mock fan setpoints # Mock fan setpoints
flexit_bacnet.fan_setpoint_extract_air_fire = 10 flexit_bacnet.fan_setpoint_extract_air_fire = 56
flexit_bacnet.fan_setpoint_supply_air_fire = 20 flexit_bacnet.fan_setpoint_supply_air_fire = 77
flexit_bacnet.fan_setpoint_extract_air_away = 30 flexit_bacnet.fan_setpoint_extract_air_away = 40
flexit_bacnet.fan_setpoint_supply_air_away = 40 flexit_bacnet.fan_setpoint_supply_air_away = 42
flexit_bacnet.fan_setpoint_extract_air_home = 50 flexit_bacnet.fan_setpoint_extract_air_home = 70
flexit_bacnet.fan_setpoint_supply_air_home = 60 flexit_bacnet.fan_setpoint_supply_air_home = 74
flexit_bacnet.fan_setpoint_extract_air_high = 70 flexit_bacnet.fan_setpoint_extract_air_high = 100
flexit_bacnet.fan_setpoint_supply_air_high = 80 flexit_bacnet.fan_setpoint_supply_air_high = 100
flexit_bacnet.fan_setpoint_extract_air_cooker = 90 flexit_bacnet.fan_setpoint_extract_air_cooker = 50
flexit_bacnet.fan_setpoint_supply_air_cooker = 100 flexit_bacnet.fan_setpoint_supply_air_cooker = 70
yield flexit_bacnet yield flexit_bacnet

View File

@ -5,8 +5,8 @@
}), }),
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 70,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -42,8 +42,8 @@
'attributes': ReadOnlyDict({ 'attributes': ReadOnlyDict({
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Away extract fan setpoint', 'friendly_name': 'Device Name Away extract fan setpoint',
'max': 100, 'max': 70,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -53,7 +53,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '30', 'state': '40',
}) })
# --- # ---
# name: test_numbers[number.device_name_away_supply_fan_setpoint-entry] # name: test_numbers[number.device_name_away_supply_fan_setpoint-entry]
@ -62,8 +62,8 @@
}), }),
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 74,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -99,8 +99,8 @@
'attributes': ReadOnlyDict({ 'attributes': ReadOnlyDict({
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Away supply fan setpoint', 'friendly_name': 'Device Name Away supply fan setpoint',
'max': 100, 'max': 74,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -110,7 +110,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '40', 'state': '42',
}) })
# --- # ---
# name: test_numbers[number.device_name_cooker_hood_extract_fan_setpoint-entry] # name: test_numbers[number.device_name_cooker_hood_extract_fan_setpoint-entry]
@ -120,7 +120,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -157,7 +157,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Cooker hood extract fan setpoint', 'friendly_name': 'Device Name Cooker hood extract fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -167,7 +167,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '90', 'state': '50',
}) })
# --- # ---
# name: test_numbers[number.device_name_cooker_hood_supply_fan_setpoint-entry] # name: test_numbers[number.device_name_cooker_hood_supply_fan_setpoint-entry]
@ -177,7 +177,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -214,7 +214,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Cooker hood supply fan setpoint', 'friendly_name': 'Device Name Cooker hood supply fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -224,7 +224,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '100', 'state': '70',
}) })
# --- # ---
# name: test_numbers[number.device_name_fireplace_extract_fan_setpoint-entry] # name: test_numbers[number.device_name_fireplace_extract_fan_setpoint-entry]
@ -234,7 +234,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -271,7 +271,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Fireplace extract fan setpoint', 'friendly_name': 'Device Name Fireplace extract fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -281,7 +281,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '10', 'state': '56',
}) })
# --- # ---
# name: test_numbers[number.device_name_fireplace_supply_fan_setpoint-entry] # name: test_numbers[number.device_name_fireplace_supply_fan_setpoint-entry]
@ -291,7 +291,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -328,7 +328,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Fireplace supply fan setpoint', 'friendly_name': 'Device Name Fireplace supply fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 30,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -338,7 +338,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '20', 'state': '77',
}) })
# --- # ---
# name: test_numbers[number.device_name_high_extract_fan_setpoint-entry] # name: test_numbers[number.device_name_high_extract_fan_setpoint-entry]
@ -348,7 +348,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 70,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -385,7 +385,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name High extract fan setpoint', 'friendly_name': 'Device Name High extract fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 70,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -395,7 +395,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '70', 'state': '100',
}) })
# --- # ---
# name: test_numbers[number.device_name_high_supply_fan_setpoint-entry] # name: test_numbers[number.device_name_high_supply_fan_setpoint-entry]
@ -405,7 +405,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 74,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -442,7 +442,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name High supply fan setpoint', 'friendly_name': 'Device Name High supply fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 74,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -452,7 +452,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '80', 'state': '100',
}) })
# --- # ---
# name: test_numbers[number.device_name_home_extract_fan_setpoint-entry] # name: test_numbers[number.device_name_home_extract_fan_setpoint-entry]
@ -462,7 +462,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 40,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -499,7 +499,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Home extract fan setpoint', 'friendly_name': 'Device Name Home extract fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 40,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -509,7 +509,7 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '50', 'state': '70',
}) })
# --- # ---
# name: test_numbers[number.device_name_home_supply_fan_setpoint-entry] # name: test_numbers[number.device_name_home_supply_fan_setpoint-entry]
@ -519,7 +519,7 @@
'area_id': None, 'area_id': None,
'capabilities': dict({ 'capabilities': dict({
'max': 100, 'max': 100,
'min': 0, 'min': 42,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
}), }),
@ -556,7 +556,7 @@
'device_class': 'power_factor', 'device_class': 'power_factor',
'friendly_name': 'Device Name Home supply fan setpoint', 'friendly_name': 'Device Name Home supply fan setpoint',
'max': 100, 'max': 100,
'min': 0, 'min': 42,
'mode': <NumberMode.SLIDER: 'slider'>, 'mode': <NumberMode.SLIDER: 'slider'>,
'step': 1, 'step': 1,
'unit_of_measurement': '%', 'unit_of_measurement': '%',
@ -566,6 +566,6 @@
'last_changed': <ANY>, 'last_changed': <ANY>,
'last_reported': <ANY>, 'last_reported': <ANY>,
'last_updated': <ANY>, 'last_updated': <ANY>,
'state': '60', 'state': '74',
}) })
# --- # ---

View File

@ -64,21 +64,21 @@ async def test_numbers_implementation(
assert len(mocked_method.mock_calls) == 1 assert len(mocked_method.mock_calls) == 1
assert hass.states.get(ENTITY_ID).state == "60" assert hass.states.get(ENTITY_ID).state == "60"
mock_flexit_bacnet.fan_setpoint_supply_air_fire = 10 mock_flexit_bacnet.fan_setpoint_supply_air_fire = 40
await hass.services.async_call( await hass.services.async_call(
NUMBER_DOMAIN, NUMBER_DOMAIN,
SERVICE_SET_VALUE, SERVICE_SET_VALUE,
{ {
ATTR_ENTITY_ID: ENTITY_ID, ATTR_ENTITY_ID: ENTITY_ID,
ATTR_VALUE: 10, ATTR_VALUE: 40,
}, },
blocking=True, blocking=True,
) )
mocked_method = getattr(mock_flexit_bacnet, "set_fan_setpoint_supply_air_fire") mocked_method = getattr(mock_flexit_bacnet, "set_fan_setpoint_supply_air_fire")
assert len(mocked_method.mock_calls) == 2 assert len(mocked_method.mock_calls) == 2
assert hass.states.get(ENTITY_ID).state == "10" assert hass.states.get(ENTITY_ID).state == "40"
# Error recovery, when setting the value # Error recovery, when setting the value
mock_flexit_bacnet.set_fan_setpoint_supply_air_fire.side_effect = DecodingError mock_flexit_bacnet.set_fan_setpoint_supply_air_fire.side_effect = DecodingError
@ -89,7 +89,7 @@ async def test_numbers_implementation(
SERVICE_SET_VALUE, SERVICE_SET_VALUE,
{ {
ATTR_ENTITY_ID: ENTITY_ID, ATTR_ENTITY_ID: ENTITY_ID,
ATTR_VALUE: 10, ATTR_VALUE: 40,
}, },
blocking=True, blocking=True,
) )