async def async_set_direction(self, direction: str) -> None: """Set fan rotation direction.""" bond_direction = ( Direction.REVERSE if direction == DIRECTION_REVERSE else Direction.FORWARD ) await self._hub.bond.action( self._device.device_id, Action.set_direction(bond_direction) )
async def test_set_fan_direction(hass: core.HomeAssistant): """Tests that set direction command delegates to API.""" await setup_platform( hass, FAN_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id" ) with patch_bond_action() as mock_set_direction, patch_bond_device_state(): await hass.services.async_call( FAN_DOMAIN, SERVICE_SET_DIRECTION, {ATTR_ENTITY_ID: "fan.name_1", ATTR_DIRECTION: DIRECTION_FORWARD}, blocking=True, ) await hass.async_block_till_done() mock_set_direction.assert_called_once_with( "test-device-id", Action.set_direction(Direction.FORWARD) )