mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove deprecated hass.components
usage in config entry flow (#111880)
* Remove deprecated `hass.components` usage in config entry flow * Do local import * Also use local import for webhook
This commit is contained in:
parent
64dcc4606f
commit
995d93dd33
@ -220,21 +220,33 @@ class WebhookFlowHandler(config_entries.ConfigFlow):
|
|||||||
if user_input is None:
|
if user_input is None:
|
||||||
return self.async_show_form(step_id="user")
|
return self.async_show_form(step_id="user")
|
||||||
|
|
||||||
webhook_id = self.hass.components.webhook.async_generate_id()
|
# Local import to be sure cloud is loaded and setup
|
||||||
|
# pylint: disable-next=import-outside-toplevel
|
||||||
|
from homeassistant.components.cloud import (
|
||||||
|
async_active_subscription,
|
||||||
|
async_create_cloudhook,
|
||||||
|
async_is_connected,
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
# Local import to be sure webhook is loaded and setup
|
||||||
"cloud" in self.hass.config.components
|
# pylint: disable-next=import-outside-toplevel
|
||||||
and self.hass.components.cloud.async_active_subscription()
|
from homeassistant.components.webhook import (
|
||||||
|
async_generate_id,
|
||||||
|
async_generate_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
webhook_id = async_generate_id()
|
||||||
|
|
||||||
|
if "cloud" in self.hass.config.components and async_active_subscription(
|
||||||
|
self.hass
|
||||||
):
|
):
|
||||||
if not self.hass.components.cloud.async_is_connected():
|
if not async_is_connected(self.hass):
|
||||||
return self.async_abort(reason="cloud_not_connected")
|
return self.async_abort(reason="cloud_not_connected")
|
||||||
|
|
||||||
webhook_url = await self.hass.components.cloud.async_create_cloudhook(
|
webhook_url = await async_create_cloudhook(self.hass, webhook_id)
|
||||||
webhook_id
|
|
||||||
)
|
|
||||||
cloudhook = True
|
cloudhook = True
|
||||||
else:
|
else:
|
||||||
webhook_url = self.hass.components.webhook.async_generate_url(webhook_id)
|
webhook_url = async_generate_url(self.hass, webhook_id)
|
||||||
cloudhook = False
|
cloudhook = False
|
||||||
|
|
||||||
self._description_placeholder["webhook_url"] = webhook_url
|
self._description_placeholder["webhook_url"] = webhook_url
|
||||||
@ -267,4 +279,8 @@ async def webhook_async_remove_entry(
|
|||||||
if not entry.data.get("cloudhook") or "cloud" not in hass.config.components:
|
if not entry.data.get("cloudhook") or "cloud" not in hass.config.components:
|
||||||
return
|
return
|
||||||
|
|
||||||
await hass.components.cloud.async_delete_cloudhook(entry.data["webhook_id"])
|
# Local import to be sure cloud is loaded and setup
|
||||||
|
# pylint: disable-next=import-outside-toplevel
|
||||||
|
from homeassistant.components.cloud import async_delete_cloudhook
|
||||||
|
|
||||||
|
await async_delete_cloudhook(hass, entry.data["webhook_id"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user