From aa45ff83bd6882968ce5726223a9554246a4f38b Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Tue, 11 Dec 2018 06:50:54 +0100 Subject: [PATCH] Fix cloud defaults (#19172) --- homeassistant/components/cloud/__init__.py | 3 +-- homeassistant/components/cloud/prefs.py | 8 +++----- tests/components/cloud/test_cloudhooks.py | 2 +- tests/components/cloud/test_iot.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 329f83768ce..fd5b413043e 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -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 diff --git a/homeassistant/components/cloud/prefs.py b/homeassistant/components/cloud/prefs.py index c4aa43c91d2..32362df2fa9 100644 --- a/homeassistant/components/cloud/prefs.py +++ b/homeassistant/components/cloud/prefs.py @@ -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 diff --git a/tests/components/cloud/test_cloudhooks.py b/tests/components/cloud/test_cloudhooks.py index b65046331a7..9306a6c6ef3 100644 --- a/tests/components/cloud/test_cloudhooks.py +++ b/tests/components/cloud/test_cloudhooks.py @@ -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) diff --git a/tests/components/cloud/test_iot.py b/tests/components/cloud/test_iot.py index b11de7da4e4..2133a803aef 100644 --- a/tests/components/cloud/test_iot.py +++ b/tests/components/cloud/test_iot.py @@ -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',