Mobile App: Update Location schema updates & device ID generation (#21849)

* Update location schema

* Generate a random device ID at registration time for later use with device_tracker.see

* Remove host name from device_tracker.see payload

* Drop consider_home from the payload

* Remove stale consider_home in schema

* Remove source_type
This commit is contained in:
Robbie Trencheny 2019-03-13 15:38:53 -07:00 committed by GitHub
parent 5ef602bc2e
commit 673c8907e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 17 deletions

View file

@ -1,4 +1,5 @@
"""Provides an HTTP API for mobile_app."""
import uuid
from typing import Dict
from aiohttp.web import Response, Request
@ -15,10 +16,11 @@ from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import get_component
from .const import (ATTR_APP_COMPONENT, ATTR_SUPPORTS_ENCRYPTION,
CONF_CLOUDHOOK_URL, CONF_SECRET, CONF_USER_ID,
DATA_REGISTRATIONS, DOMAIN, ERR_INVALID_COMPONENT,
ERR_SAVE_FAILURE, REGISTRATION_SCHEMA)
from .const import (ATTR_APP_COMPONENT, ATTR_DEVICE_ID,
ATTR_SUPPORTS_ENCRYPTION, CONF_CLOUDHOOK_URL, CONF_SECRET,
CONF_USER_ID, DATA_REGISTRATIONS, DOMAIN,
ERR_INVALID_COMPONENT, ERR_SAVE_FAILURE,
REGISTRATION_SCHEMA)
from .helpers import error_response, supports_encryption, savable_state
@ -66,6 +68,8 @@ class RegistrationsView(HomeAssistantView):
data[CONF_CLOUDHOOK_URL] = \
await async_create_cloudhook(hass, webhook_id)
data[ATTR_DEVICE_ID] = str(uuid.uuid4()).replace("-", "")
data[CONF_WEBHOOK_ID] = webhook_id
if data[ATTR_SUPPORTS_ENCRYPTION] and supports_encryption():