Remove cloud dependency from mobile_app (#29373)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-12-03 15:43:48 -08:00
1 parent 98b6905738
commit e26eebfc19
4 files changed
+21 -29

No files matched your search

+12 -11
View File
@@ -6,11 +6,7 @@ from aiohttp.web import Request, Response
from nacl.secret import SecretBox
from homeassistant.auth.util import generate_secret
from homeassistant.components.cloud import (
CloudNotAvailable,
async_create_cloudhook,
async_remote_ui_url,
)
from homeassistant.components.http import HomeAssistantView
from homeassistant.components.http.data_validator import RequestDataValidator
from homeassistant.const import CONF_WEBHOOK_ID, HTTP_CREATED
@@ -41,8 +37,12 @@ class RegistrationsView(HomeAssistantView):
webhook_id = generate_secret()
if hass.components.cloud.async_active_subscription():
data[CONF_CLOUDHOOK_URL] = await async_create_cloudhook(hass, webhook_id)
cloud_loaded = "cloud" in hass.config.components
if cloud_loaded and hass.components.cloud.async_active_subscription():
data[
CONF_CLOUDHOOK_URL
] = await hass.components.cloud.async_create_cloudhook(webhook_id)
data[ATTR_DEVICE_ID] = str(uuid.uuid4()).replace("-", "")
@@ -59,10 +59,11 @@ class RegistrationsView(HomeAssistantView):
)
remote_ui_url = None
try:
remote_ui_url = async_remote_ui_url(hass)
except CloudNotAvailable:
pass
if cloud_loaded:
try:
remote_ui_url = hass.components.cloud.async_remote_ui_url()
except hass.components.cloud.CloudNotAvailable:
pass
return self.json(
{