mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Fix cloud defaults (#19172)
This commit is contained in:
parent
92e19f6001
commit
557720b094
@ -252,8 +252,7 @@ class Cloud:
|
|||||||
return json.loads(file.read())
|
return json.loads(file.read())
|
||||||
|
|
||||||
info = await self.hass.async_add_job(load_config)
|
info = await self.hass.async_add_job(load_config)
|
||||||
|
await self.prefs.async_initialize()
|
||||||
await self.prefs.async_initialize(bool(info))
|
|
||||||
|
|
||||||
if info is None:
|
if info is None:
|
||||||
return
|
return
|
||||||
|
@ -16,19 +16,17 @@ class CloudPreferences:
|
|||||||
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||||
self._prefs = None
|
self._prefs = None
|
||||||
|
|
||||||
async def async_initialize(self, logged_in):
|
async def async_initialize(self):
|
||||||
"""Finish initializing the preferences."""
|
"""Finish initializing the preferences."""
|
||||||
prefs = await self._store.async_load()
|
prefs = await self._store.async_load()
|
||||||
|
|
||||||
if prefs is None:
|
if prefs is None:
|
||||||
# Backwards compat: we enable alexa/google if already logged in
|
|
||||||
prefs = {
|
prefs = {
|
||||||
PREF_ENABLE_ALEXA: logged_in,
|
PREF_ENABLE_ALEXA: True,
|
||||||
PREF_ENABLE_GOOGLE: logged_in,
|
PREF_ENABLE_GOOGLE: True,
|
||||||
PREF_GOOGLE_ALLOW_UNLOCK: False,
|
PREF_GOOGLE_ALLOW_UNLOCK: False,
|
||||||
PREF_CLOUDHOOKS: {}
|
PREF_CLOUDHOOKS: {}
|
||||||
}
|
}
|
||||||
await self._store.async_save(prefs)
|
|
||||||
|
|
||||||
self._prefs = prefs
|
self._prefs = prefs
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ def mock_cloudhooks(hass):
|
|||||||
cloud.iot = Mock(async_send_message=Mock(return_value=mock_coro()))
|
cloud.iot = Mock(async_send_message=Mock(return_value=mock_coro()))
|
||||||
cloud.cloudhook_create_url = 'https://webhook-create.url'
|
cloud.cloudhook_create_url = 'https://webhook-create.url'
|
||||||
cloud.prefs = prefs.CloudPreferences(hass)
|
cloud.prefs = prefs.CloudPreferences(hass)
|
||||||
hass.loop.run_until_complete(cloud.prefs.async_initialize(True))
|
hass.loop.run_until_complete(cloud.prefs.async_initialize())
|
||||||
return cloudhooks.Cloudhooks(cloud)
|
return cloudhooks.Cloudhooks(cloud)
|
||||||
|
|
||||||
|
|
||||||
|
@ -411,7 +411,7 @@ async def test_refresh_token_expired(hass):
|
|||||||
async def test_webhook_msg(hass):
|
async def test_webhook_msg(hass):
|
||||||
"""Test webhook msg."""
|
"""Test webhook msg."""
|
||||||
cloud = Cloud(hass, MODE_DEV, None, None)
|
cloud = Cloud(hass, MODE_DEV, None, None)
|
||||||
await cloud.prefs.async_initialize(True)
|
await cloud.prefs.async_initialize()
|
||||||
await cloud.prefs.async_update(cloudhooks={
|
await cloud.prefs.async_update(cloudhooks={
|
||||||
'hello': {
|
'hello': {
|
||||||
'webhook_id': 'mock-webhook-id',
|
'webhook_id': 'mock-webhook-id',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user