diff --git a/homeassistant/components/lovelace/dashboard.py b/homeassistant/components/lovelace/dashboard.py index a04a2376c74..11cb3266755 100644 --- a/homeassistant/components/lovelace/dashboard.py +++ b/homeassistant/components/lovelace/dashboard.py @@ -101,6 +101,9 @@ class LovelaceStorage(LovelaceConfig): async def async_save(self, config): """Save config.""" + if self.hass.config.safe_mode: + raise HomeAssistantError("Saving not supported in safe mode") + if self._data is None: await self._load() self._data["config"] = config @@ -109,6 +112,9 @@ class LovelaceStorage(LovelaceConfig): async def async_delete(self): """Delete config.""" + if self.hass.config.safe_mode: + raise HomeAssistantError("Deleting not supported in safe mode") + await self.async_save(None) async def _load(self): diff --git a/tests/components/lovelace/test_dashboard.py b/tests/components/lovelace/test_dashboard.py index 9511e001197..1d385ba3bec 100644 --- a/tests/components/lovelace/test_dashboard.py +++ b/tests/components/lovelace/test_dashboard.py @@ -50,6 +50,16 @@ async def test_lovelace_from_storage(hass, hass_ws_client, hass_storage): assert not response["success"] assert response["error"]["code"] == "config_not_found" + await client.send_json( + {"id": 9, "type": "lovelace/config/save", "config": {"yo": "hello"}} + ) + response = await client.receive_json() + assert not response["success"] + + await client.send_json({"id": 10, "type": "lovelace/config/delete"}) + response = await client.receive_json() + assert not response["success"] + async def test_lovelace_from_storage_save_before_load( hass, hass_ws_client, hass_storage