diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 13cb7de62ef..be67ebd9cc3 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -323,6 +323,10 @@ class ConfigEntries: old_conf_migrate_func=_old_conf_migrator ) + if config is None: + self._entries = [] + return + self._entries = [ConfigEntry(**entry) for entry in config['entries']] async def async_forward_entry_setup(self, entry, component): diff --git a/homeassistant/helpers/storage.py b/homeassistant/helpers/storage.py index 4b0c576f129..18c3ddf7fcd 100644 --- a/homeassistant/helpers/storage.py +++ b/homeassistant/helpers/storage.py @@ -72,7 +72,7 @@ class Store: json.load_json, self.path, None) if data is None: - return {} + return None if data['version'] == self.version: return data['data'] diff --git a/tests/helpers/test_storage.py b/tests/helpers/test_storage.py index 289d07edab2..04de920b036 100644 --- a/tests/helpers/test_storage.py +++ b/tests/helpers/test_storage.py @@ -52,7 +52,7 @@ async def test_loading_non_existing(hass, store): """Test we can save and load data.""" with patch('homeassistant.util.json.open', side_effect=FileNotFoundError): data = await store.async_load() - assert data == {} + assert data is None async def test_saving_with_delay(hass, store, mock_save): diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index fc0a549f1ae..b65e0dd62e7 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -309,3 +309,13 @@ async def test_discovery_notification_not_created(hass): await hass.async_block_till_done() state = hass.states.get('persistent_notification.config_entry_discovery') assert state is None + + +async def test_loading_default_config(hass): + """Test loading the default config.""" + manager = config_entries.ConfigEntries(hass, {}) + + with patch('homeassistant.util.json.open', side_effect=FileNotFoundError): + await manager.async_load() + + assert len(manager.async_entries()) == 0