custom_components/nea_sg_weather/config_flow.py
async def async_step_user(self, user_input=None):
        """Handle a flow initialized by the user."""
        self._errors = {}

        if user_input is not None:
            if user_input[CONF_NAME] not in configured_instances(self.hass):
                if user_input[CONF_SENSOR] or user_input[CONF_WEATHER]:
                    if user_input[CONF_SENSOR]:
                        # Additional config flow if sensors need to be set up
                        self._data = user_input
                        self._data[CONF_SENSORS] = {
                            CONF_PREFIX: '',
                            CONF_REGION: bool(),
                            CONF_RAIN: bool(),
                            CONF_AREAS: list(),
                        }
                        return await self.async_step_sensor()
                    elif user_input[CONF_WEATHER]:
                        return self.async_create_entry(
                            title=user_input[CONF_NAME], data=user_input
                        )
                else:
                    self._errors[CONF_NAME] = "no_entities_selected"
            else:
                self._errors[CONF_NAME] = "already_configured"

        return self.async_show_form(
            step_id="user",
            data_schema=vol.Schema(
                {
                    vol.Optional(CONF_NAME, default=DEFAULT_NAME): str,
                    vol.Optional(CONF_WEATHER, default=True): cv.boolean,
                    vol.Optional(CONF_SENSOR, default=False): cv.boolean,
                    vol.Optional(
                        CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL
                    ): cv.positive_int,
                    vol.Optional(
                        CONF_TIMEOUT, default=DEFAULT_TIMEOUT
                    ): cv.positive_int,
                }
            ),
            errors=self._errors,
        )
Handle a flow initialized by the user.
Handle a flow initialized by the user.
Handle a flow initialized by the user .
async def async_step_user(self, user_input=None):
        self._errors = {}
        if user_input is not None:
            if user_input[CONF_NAME] not in configured_instances(self.hass):
                if user_input[CONF_SENSOR] or user_input[CONF_WEATHER]:
                    if user_input[CONF_SENSOR]:
                        self._data = user_input
                        self._data[CONF_SENSORS] = {
                            CONF_PREFIX: '',
                            CONF_REGION: bool(),
                            CONF_RAIN: bool(),
                            CONF_AREAS: list(),
                        }
                        return await self.async_step_sensor()
                    elif user_input[CONF_WEATHER]:
                        return self.async_create_entry(
                            title=user_input[CONF_NAME], data=user_input
                        )
                else:
                    self._errors[CONF_NAME] = "no_entities_selected"
            else:
                self._errors[CONF_NAME] = "already_configured"
        return self.async_show_form(
            step_id="user",
            data_schema=vol.Schema(
                {
                    vol.Optional(CONF_NAME, default=DEFAULT_NAME): str,
                    vol.Optional(CONF_WEATHER, default=True): cv.boolean,
                    vol.Optional(CONF_SENSOR, default=False): cv.boolean,
                    vol.Optional(
                        CONF_SCAN_INTERVAL, default=DEFAULT_SCAN_INTERVAL
                    ): cv.positive_int,
                    vol.Optional(
                        CONF_TIMEOUT, default=DEFAULT_TIMEOUT
                    ): cv.positive_int,
                }
            ),
            errors=self._errors,
        )
async def async_step_user ( self , user_input = None ) : self . _errors = { } if user_input is not None : if user_input [ CONF_NAME ] not in configured_instances ( self . hass ) : if user_input [ CONF_SENSOR ] or user_input [ CONF_WEATHER ] : if user_input [ CONF_SENSOR ] : self . _data = user_input self . _data [ CONF_SENSORS ] = { CONF_PREFIX : '' , CONF_REGION : bool ( ) , CONF_RAIN : bool ( ) , CONF_AREAS : list ( ) , } return await self . async_step_sensor ( ) elif user_input [ CONF_WEATHER ] : return self . async_create_entry ( title = user_input [ CONF_NAME ] , data = user_input ) else : self . _errors [ CONF_NAME ] = "no_entities_selected" else : self . _errors [ CONF_NAME ] = "already_configured" return self . async_show_form ( step_id = "user" , data_schema = vol . Schema ( { vol . Optional ( CONF_NAME , default = DEFAULT_NAME ) : str , vol . Optional ( CONF_WEATHER , default = True ) : cv . boolean , vol . Optional ( CONF_SENSOR , default = False ) : cv . boolean , vol . Optional ( CONF_SCAN_INTERVAL , default = DEFAULT_SCAN_INTERVAL ) : cv . positive_int , vol . Optional ( CONF_TIMEOUT , default = DEFAULT_TIMEOUT ) : cv . positive_int , } ) , errors = self . _errors , )
Handle a flow initialized by the user.
Handle a flow initialized by the user .
"""Handle a flow initialized by the user.""" # Additional config flow if sensors need to be set up
self
user_input