def _setup_platform(self, platform_type, platform_config,
                        discovery_info=None):
        platform = prepare_setup_platform(
            self.hass, self.config, self.domain, platform_type)

        if platform is None:
            return

        # Config > Platform > Component
        scan_interval = platform_config.get(
            CONF_SCAN_INTERVAL,
            getattr(platform, 'SCAN_INTERVAL', self.scan_interval))
        entity_namespace = platform_config.get(CONF_ENTITY_NAMESPACE)

        try:
            platform.setup_platform(
                self.hass, platform_config,
                EntityPlatform(self, scan_interval,
                               entity_namespace).add_entities,
                discovery_info)

            self.hass.config.components.append(
                '{}.{}'.format(self.domain, platform_type))
        except Exception:  # pylint: disable=broad-except
            self.logger.exception(
                'Error while setting up platform %s', platform_type)
Setup a platform for this component.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/helpers/entity_component.py/EntityComponent._setup_platform