diff --git a/homeassistant/components/bond/fan.py b/homeassistant/components/bond/fan.py index 6f6a98036c7..cb247b37309 100644 --- a/homeassistant/components/bond/fan.py +++ b/homeassistant/components/bond/fan.py @@ -75,7 +75,7 @@ class BondFan(BondEntity, FanEntity): return None # map 1..max_speed Bond speed to 1..3 HA speed - max_speed = self._device.props.get("max_speed", 3) + max_speed = max(self._device.props.get("max_speed", 3), self._speed) ha_speed = math.ceil(self._speed * (len(self.speed_list) - 1) / max_speed) return self.speed_list[ha_speed] diff --git a/tests/components/bond/common.py b/tests/components/bond/common.py index 181fe3eaf07..bb3329b6a2d 100644 --- a/tests/components/bond/common.py +++ b/tests/components/bond/common.py @@ -49,9 +49,11 @@ async def setup_platform( hass: core.HomeAssistant, platform: str, discovered_device: Dict[str, Any], + *, bond_device_id: str = "bond-device-id", - props: Dict[str, Any] = None, bond_version: Dict[str, Any] = None, + props: Dict[str, Any] = None, + state: Dict[str, Any] = None, ): """Set up the specified Bond platform.""" mock_entry = MockConfigEntry( @@ -65,9 +67,11 @@ async def setup_platform( return_value=[bond_device_id] ), patch_bond_device( return_value=discovered_device - ), patch_bond_device_state(), patch_bond_device_properties( + ), patch_bond_device_properties( return_value=props - ), patch_bond_device_state(): + ), patch_bond_device_state( + return_value=state + ): assert await async_setup_component(hass, BOND_DOMAIN, {}) await hass.async_block_till_done() diff --git a/tests/components/bond/test_fan.py b/tests/components/bond/test_fan.py index 6a8a15fc4c0..91f0c21e77a 100644 --- a/tests/components/bond/test_fan.py +++ b/tests/components/bond/test_fan.py @@ -96,6 +96,20 @@ async def test_non_standard_speed_list(hass: core.HomeAssistant): ) +async def test_fan_speed_with_no_max_seed(hass: core.HomeAssistant): + """Tests that fans without max speed (increase/decrease controls) map speed to HA standard.""" + await setup_platform( + hass, + FAN_DOMAIN, + ceiling_fan("name-1"), + bond_device_id="test-device-id", + props={"no": "max_speed"}, + state={"power": 1, "speed": 14}, + ) + + assert hass.states.get("fan.name_1").attributes["speed"] == fan.SPEED_HIGH + + async def test_turn_on_fan_with_speed(hass: core.HomeAssistant): """Tests that turn on command delegates to set speed API.""" await setup_platform(