Remove async_setup from locative (#93895)

* Remove async_setup from locative

* Micro-optimize async_setup_entry
This commit is contained in:
Erik Montnemery 2023-06-01 20:08:32 +02:00 committed by GitHub
parent 23ca26ae56
commit bb5430ff59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,6 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_entry_flow
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -61,12 +60,6 @@ WEBHOOK_SCHEMA = vol.All(
)
async def async_setup(hass: HomeAssistant, hass_config: ConfigType) -> bool:
"""Set up the Locative component."""
hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}}
return True
async def handle_webhook(hass, webhook_id, request):
"""Handle incoming webhook from Locative."""
try:
@ -117,6 +110,8 @@ async def handle_webhook(hass, webhook_id, request):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Configure based on config entry."""
if DOMAIN not in hass.data:
hass.data[DOMAIN] = {"devices": set(), "unsub_device_tracker": {}}
webhook.async_register(
hass, DOMAIN, "Locative", entry.data[CONF_WEBHOOK_ID], handle_webhook
)