Repository: home-assistant/core
File: homeassistant/components/switchbot/config_flow.py (Python)

Code before:
                ),
            ): int
        }
        if CONF_SENSOR_TYPE in self.config_entry.data and self.config_entry.data[
            CONF_SENSOR_TYPE
        ] in (
            SupportedModels.LOCK,
            SupportedModels.LOCK_PRO,
            SupportedModels.LOCK_ULTRA,
        ):
            options.update(
                {
                    vol.Optional(
                        CONF_LOCK_NIGHTLATCH,
                        default=self.config_entry.options.get(
                            CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH
                        ),
                    ): bool
                }
            )
        if (
            CONF_SENSOR_TYPE in self.config_entry.data
            and self.config_entry.data[CONF_SENSOR_TYPE] == SupportedModels.CURTAIN
        ):
            options.update(
                {
                    vol.Optional(
                        CONF_CURTAIN_SPEED,
                        default=self.config_entry.options.get(
                            CONF_CURTAIN_SPEED, DEFAULT_CURTAIN_SPEED
                        ),
                    ): selector.NumberSelector(
                        selector.NumberSelectorConfig(
                            min=CURTAIN_SPEED_MIN,
                            max=CURTAIN_SPEED_MAX,
                            step=1,
                            mode=selector.NumberSelectorMode.SLIDER,
                        )
                    )
                }
            )

        return self.async_show_form(step_id="init", data_schema=vol.Schema(options))


Review comment (suggestion):
Also update the `async_create_entry` call in the config flow (not in the options flow) to set the default curtain speed in the options.

Code after:
            CONF_SENSOR_TYPE
        ] in (
            SupportedModels.LOCK,
            SupportedModels.LOCK_PRO,
            SupportedModels.LOCK_ULTRA,
        ):
            options.update(
                {
                    vol.Optional(
                        CONF_LOCK_NIGHTLATCH,
                        default=self.config_entry.options.get(
                            CONF_LOCK_NIGHTLATCH, DEFAULT_LOCK_NIGHTLATCH
                        ),
                    ): bool
                }
            )
        if (
            CONF_SENSOR_TYPE in self.config_entry.data
            and self.config_entry.data[CONF_SENSOR_TYPE] == SupportedModels.CURTAIN
        ):
            options.update(
                {
                    vol.Optional(
                        CONF_CURTAIN_SPEED,
                        default=self.config_entry.options.get(
                            CONF_CURTAIN_SPEED, DEFAULT_CURTAIN_SPEED
                        ),
                    ): selector.NumberSelector(
                        selector.NumberSelectorConfig(
                            min=CURTAIN_SPEED_MIN,
                            max=CURTAIN_SPEED_MAX,
                            step=1,
                            mode=selector.NumberSelectorMode.SLIDER,
                        )
                    )
                }
            )

        return self.async_show_form(step_id="init", data_schema=vol.Schema(options))