(self, user_input: ConfigType | None = None)
return self.async_show_form(
            step_id='include_exclude',
            data_schema=vol.Schema({
                vol.Required(CONF_INCLUDE_EXCLUDE_MODE, default=include_exclude_mode): vol.In(INCLUDE_EXCLUDE_MODES),
                vol.Optional(CONF_ENTITIES, default=sorted(set(entities))): cv.multi_select(all_supported_entities)
            })
        )
Choose entities to include or exclude from the domain.
Choose entities to include or exclude from the domain.
Choose entities to include or exclude from the domain .
async def async_step_include_exclude(self, user_input: ConfigType | None = None) -> data_entry_flow.FlowResult:
        """Choose entities to include or exclude from the domain."""
        if user_input is not None:
            entity_filter = _EMPTY_ENTITY_FILTER.copy()
            entities = user_input[CONF_ENTITIES]

            if user_input[CONF_INCLUDE_EXCLUDE_MODE] == MODE_INCLUDE:
                entity_filter[CONF_INCLUDE_ENTITIES] = entities

                # Include all of the domain if there are no entities
                # explicitly included as the user selected the domain
                domains_with_entities_selected = _domains_set_from_entities(entities)
                entity_filter[CONF_INCLUDE_DOMAINS] = [
                    domain
                    for domain in self._options[CONF_DOMAINS]
                    if domain not in domains_with_entities_selected
                ]
            else:
                entity_filter[CONF_INCLUDE_DOMAINS] = self._options[CONF_DOMAINS]
                entity_filter[CONF_EXCLUDE_ENTITIES] = entities

            self._options[const.CONF_FILTER] = entity_filter

            return await self.async_step_cloud_settings()

        entity_filter = self._options.get(const.CONF_FILTER, {})
        all_supported_entities = _async_get_matching_entities(self.hass, domains=self._options[CONF_DOMAINS])
        entities = entity_filter.get(CONF_INCLUDE_ENTITIES, [])
        include_exclude_mode = MODE_INCLUDE

        if not entities:
            include_exclude_mode = MODE_EXCLUDE
            entities = entity_filter.get(CONF_EXCLUDE_ENTITIES, [])

        entities = [
            entity_id
            for entity_id in entities
            if entity_id in all_supported_entities
        ]

        return self.async_show_form(
            step_id='include_exclude',
            data_schema=vol.Schema({
                vol.Required(CONF_INCLUDE_EXCLUDE_MODE, default=include_exclude_mode): vol.In(INCLUDE_EXCLUDE_MODES),
                vol.Optional(CONF_ENTITIES, default=sorted(set(entities))): cv.multi_select(all_supported_entities)
            })
        )
async def async_step_include_exclude ( self , user_input : ConfigType | None = None ) -> data_entry_flow . FlowResult : if user_input is not None : entity_filter = _EMPTY_ENTITY_FILTER . copy ( ) entities = user_input [ CONF_ENTITIES ] if user_input [ CONF_INCLUDE_EXCLUDE_MODE ] == MODE_INCLUDE : entity_filter [ CONF_INCLUDE_ENTITIES ] = entities # Include all of the domain if there are no entities # explicitly included as the user selected the domain domains_with_entities_selected = _domains_set_from_entities ( entities ) entity_filter [ CONF_INCLUDE_DOMAINS ] = [ domain for domain in self . _options [ CONF_DOMAINS ] if domain not in domains_with_entities_selected ] else : entity_filter [ CONF_INCLUDE_DOMAINS ] = self . _options [ CONF_DOMAINS ] entity_filter [ CONF_EXCLUDE_ENTITIES ] = entities self . _options [ const . CONF_FILTER ] = entity_filter return await self . async_step_cloud_settings ( ) entity_filter = self . _options . get ( const . CONF_FILTER , { } ) all_supported_entities = _async_get_matching_entities ( self . hass , domains = self . _options [ CONF_DOMAINS ] ) entities = entity_filter . get ( CONF_INCLUDE_ENTITIES , [ ] ) include_exclude_mode = MODE_INCLUDE if not entities : include_exclude_mode = MODE_EXCLUDE entities = entity_filter . get ( CONF_EXCLUDE_ENTITIES , [ ] ) entities = [ entity_id for entity_id in entities if entity_id in all_supported_entities ] return self . async_show_form ( step_id = 'include_exclude' , data_schema = vol . Schema ( { vol . Required ( CONF_INCLUDE_EXCLUDE_MODE , default = include_exclude_mode ) : vol . In ( INCLUDE_EXCLUDE_MODES ) , vol . Optional ( CONF_ENTITIES , default = sorted ( set ( entities ) ) ) : cv . multi_select ( all_supported_entities ) } ) )