Load/unload gpslogger entities correctly between component and platform (#20448)

* Embed device_tracker in gpslogger

* Load/unload gpslogger entities correctly between component and platform

* Await the coroutine directly
This commit is contained in:
Rohan Kapoor authored and GitHub committed 2019-01-27 15:37:19 -08:00
1 parent 0c87fb421e
commit d179686edf
4 files changed
+74 -39

No files matched your search

@@ -15,8 +15,8 @@ from homeassistant.components.device_tracker.tile import ATTR_ALTITUDE
from homeassistant.const import HTTP_UNPROCESSABLE_ENTITY, \
HTTP_OK, ATTR_LATITUDE, ATTR_LONGITUDE, CONF_WEBHOOK_ID
from homeassistant.helpers import config_entry_flow
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER
_LOGGER = logging.getLogger(__name__)
@@ -57,9 +57,6 @@ WEBHOOK_SCHEMA = vol.Schema({
async def async_setup(hass, hass_config):
"""Set up the GPSLogger component."""
hass.async_create_task(
async_load_platform(hass, 'device_tracker', DOMAIN, {}, hass_config)
)
return True
@@ -103,12 +100,18 @@ async def async_setup_entry(hass, entry):
"""Configure based on config entry."""
hass.components.webhook.async_register(
DOMAIN, 'GPSLogger', entry.data[CONF_WEBHOOK_ID], handle_webhook)
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, DEVICE_TRACKER)
)
return True
async def async_unload_entry(hass, entry):
"""Unload a config entry."""
hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID])
await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER)
return True
config_entry_flow.register_webhook_flow(