Create a person during onboarding (#21057)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-02-13 20:00:08 -08:00
1 parent bf0a50cdb2
commit 50ba3d0427
4 files changed
+19

No files matched your search

@@ -11,6 +11,7 @@ DEPENDENCIES = (
'history',
'logbook',
'map',
'person',
'script',
'sun',
'system_health',
@@ -94,6 +94,10 @@ class UserOnboardingView(_BaseOnboardingView):
})
await provider.data.async_save()
await hass.auth.async_link_user(user, credentials)
if 'person' in hass.config.components:
await hass.components.person.async_create_person(
data['name'], user_id=user.id
)
await self._async_mark_done(hass)
@@ -24,6 +24,7 @@ from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.components import websocket_api
from homeassistant.helpers.typing import HomeAssistantType, ConfigType
from homeassistant.util import dt as dt_util
from homeassistant.loader import bind_hass
_LOGGER = logging.getLogger(__name__)
ATTR_EDITABLE = 'editable'
@@ -51,6 +52,17 @@ CONFIG_SCHEMA = vol.Schema({
_UNDEF = object()
@bind_hass
async def async_create_person(hass, name, *, user_id=None,
device_trackers=None):
"""Create a new person."""
await hass.data[DOMAIN].async_create_person(
name=name,
user_id=user_id,
device_trackers=device_trackers,
)
class PersonManager:
"""Manage person data."""