async def _async_setup_platform(self, async_create_setup_task, tries=0):
    'Set up a platform via config file or config entry.\n\n        async_create_setup_task creates a coroutine that sets up platform.\n        '
    logger = self.logger
    hass = self.hass
    full_name = '{}.{}'.format(self.domain, self.platform_name)
    logger.info('Setting up %s', full_name)
    warn_task = hass.loop.call_later(SLOW_SETUP_WARNING, logger.warning, 'Setup of platform %s is taking over %s seconds.', self.platform_name, SLOW_SETUP_WARNING)
    try:
        task = async_create_setup_task()
        (await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT))
        if self._tasks:
            pending = [task for task in self._tasks if (not task.done())]
            self._tasks.clear()
            if pending:
                (await asyncio.wait(pending))
        hass.config.components.add(full_name)
        return True
    except PlatformNotReady:
        tries += 1
        wait_time = (min(tries, 6) * 30)
        logger.warning('Platform %s not ready yet. Retrying in %d seconds.', self.platform_name, wait_time)

        async def setup_again(now):
            'Run setup again.'
            self._async_cancel_retry_setup = None
            (await self._async_setup_platform(async_create_setup_task, tries))
        self._async_cancel_retry_setup = async_call_later(hass, wait_time, setup_again)
        return False
    except asyncio.TimeoutError:
        logger.error('Setup of platform %s is taking longer than %s seconds. Startup will proceed without waiting any longer.', self.platform_name, SLOW_SETUP_MAX_WAIT)
        return False
    except Exception:
        logger.exception('Error while setting up platform %s', self.platform_name)
        return False
    finally:
        warn_task.cancel()
Set up a platform via config file or config entry.

async_create_setup_task creates a coroutine that sets up platform.
async def _async_setup_platform(self, async_create_setup_task, tries=0):
    'Set up a platform via config file or config entry.\n\n        async_create_setup_task creates a coroutine that sets up platform.\n        '
    logger = self.logger
    hass = self.hass
    full_name = '{}.{}'.format(self.domain, self.platform_name)
    logger.info('Setting up %s', full_name)
    warn_task = hass.loop.call_later(SLOW_SETUP_WARNING, logger.warning, 'Setup of platform %s is taking over %s seconds.', self.platform_name, SLOW_SETUP_WARNING)
    try:
        task = async_create_setup_task()
        (await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT))
        if self._tasks:
            pending = [task for task in self._tasks if (not task.done())]
            self._tasks.clear()
            if pending:
                (await asyncio.wait(pending))
        hass.config.components.add(full_name)
        return True
    except PlatformNotReady:
        tries += 1
        wait_time = (min(tries, 6) * 30)
        logger.warning('Platform %s not ready yet. Retrying in %d seconds.', self.platform_name, wait_time)

        async def setup_again(now):
            'Run setup again.'
            self._async_cancel_retry_setup = None
            (await self._async_setup_platform(async_create_setup_task, tries))
        self._async_cancel_retry_setup = async_call_later(hass, wait_time, setup_again)
        return False
    except asyncio.TimeoutError:
        logger.error('Setup of platform %s is taking longer than %s seconds. Startup will proceed without waiting any longer.', self.platform_name, SLOW_SETUP_MAX_WAIT)
        return False
    except Exception:
        logger.exception('Error while setting up platform %s', self.platform_name)
        return False
    finally:
        warn_task.cancel()