Use new helper properties in plaato options flow (#129782)

This commit is contained in:
epenet 2024-11-04 09:39:56 +01:00 committed by GitHub
parent 11ab992dbb
commit b48e2127b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -176,23 +176,19 @@ class PlaatoConfigFlow(ConfigFlow, domain=DOMAIN):
@staticmethod @staticmethod
@callback @callback
def async_get_options_flow(config_entry: ConfigEntry) -> PlaatoOptionsFlowHandler: def async_get_options_flow(
config_entry: ConfigEntry,
) -> PlaatoOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return PlaatoOptionsFlowHandler(config_entry) return PlaatoOptionsFlowHandler()
class PlaatoOptionsFlowHandler(OptionsFlow): class PlaatoOptionsFlowHandler(OptionsFlow):
"""Handle Plaato options.""" """Handle Plaato options."""
def __init__(self, config_entry: ConfigEntry) -> None:
"""Initialize domain options flow."""
super().__init__()
self._config_entry = config_entry
async def async_step_init(self, user_input: None = None) -> ConfigFlowResult: async def async_step_init(self, user_input: None = None) -> ConfigFlowResult:
"""Manage the options.""" """Manage the options."""
use_webhook = self._config_entry.data.get(CONF_USE_WEBHOOK, False) use_webhook = self.config_entry.data.get(CONF_USE_WEBHOOK, False)
if use_webhook: if use_webhook:
return await self.async_step_webhook() return await self.async_step_webhook()
@ -211,7 +207,7 @@ class PlaatoOptionsFlowHandler(OptionsFlow):
{ {
vol.Optional( vol.Optional(
CONF_SCAN_INTERVAL, CONF_SCAN_INTERVAL,
default=self._config_entry.options.get( default=self.config_entry.options.get(
CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL
), ),
): cv.positive_int ): cv.positive_int
@ -226,7 +222,7 @@ class PlaatoOptionsFlowHandler(OptionsFlow):
if user_input is not None: if user_input is not None:
return self.async_create_entry(title="", data=user_input) return self.async_create_entry(title="", data=user_input)
webhook_id = self._config_entry.data.get(CONF_WEBHOOK_ID, None) webhook_id = self.config_entry.data.get(CONF_WEBHOOK_ID, None)
webhook_url = ( webhook_url = (
"" ""
if webhook_id is None if webhook_id is None