Fix cloud defaults (#19172)
parent
029d006beb
commit
aa45ff83bd
|
@ -252,8 +252,7 @@ class Cloud:
|
|||
return json.loads(file.read())
|
||||
|
||||
info = await self.hass.async_add_job(load_config)
|
||||
|
||||
await self.prefs.async_initialize(bool(info))
|
||||
await self.prefs.async_initialize()
|
||||
|
||||
if info is None:
|
||||
return
|
||||
|
|
|
@ -16,19 +16,17 @@ class CloudPreferences:
|
|||
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||
self._prefs = None
|
||||
|
||||
async def async_initialize(self, logged_in):
|
||||
async def async_initialize(self):
|
||||
"""Finish initializing the preferences."""
|
||||
prefs = await self._store.async_load()
|
||||
|
||||
if prefs is None:
|
||||
# Backwards compat: we enable alexa/google if already logged in
|
||||
prefs = {
|
||||
PREF_ENABLE_ALEXA: logged_in,
|
||||
PREF_ENABLE_GOOGLE: logged_in,
|
||||
PREF_ENABLE_ALEXA: True,
|
||||
PREF_ENABLE_GOOGLE: True,
|
||||
PREF_GOOGLE_ALLOW_UNLOCK: False,
|
||||
PREF_CLOUDHOOKS: {}
|
||||
}
|
||||
await self._store.async_save(prefs)
|
||||
|
||||
self._prefs = prefs
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ def mock_cloudhooks(hass):
|
|||
cloud.iot = Mock(async_send_message=Mock(return_value=mock_coro()))
|
||||
cloud.cloudhook_create_url = 'https://webhook-create.url'
|
||||
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)
|
||||
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ async def test_refresh_token_expired(hass):
|
|||
async def test_webhook_msg(hass):
|
||||
"""Test webhook msg."""
|
||||
cloud = Cloud(hass, MODE_DEV, None, None)
|
||||
await cloud.prefs.async_initialize(True)
|
||||
await cloud.prefs.async_initialize()
|
||||
await cloud.prefs.async_update(cloudhooks={
|
||||
'hello': {
|
||||
'webhook_id': 'mock-webhook-id',
|
||||
|
|
Loading…
Reference in New Issue