Untitled

mail@pastecode.io avatar
unknown
python
20 days ago
957 B
2
Indexable
Never
async def async_step_reconfigure(
    self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
    entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
    if entry is None:
        return self.async_abort(reason="Nothing to reconfigure")

    errors: dict[str, str] = {}

    if user_input is None:
        user_input = {CONF_EMAIL: entry.data[CONF_EMAIL]}
    else:
        token = await self.async_get_token(user_input)
        return self.async_update_reload_and_abort(
            entry,
            unique_id=self.token_subject(token),
            title=user_input[CONF_EMAIL],
            data={
                CONF_EMAIL: user_input[CONF_EMAIL],
                CONF_TOKEN: token,
            },
        )

    return self.async_show_form(
        step_id="reconfigure",
        data_schema=self.add_suggested_values_to_schema(
            STEP_USER_DATA_SCHEMA, user_input
        ),
        errors=errors,
    )
Leave a Comment