Lovelace: Fire event on save (#24104)
* Lovelace: Fire event on save * Add event to whitelistpull/23688/head^2
parent
9debbfb1a8
commit
5c86a51b45
|
@ -26,6 +26,7 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
EVENT_LOVELACE_UPDATED = 'lovelace_updated'
|
||||
|
||||
LOVELACE_CONFIG_FILE = 'ui-lovelace.yaml'
|
||||
|
||||
|
@ -83,6 +84,7 @@ class LovelaceStorage:
|
|||
"""Initialize Lovelace config based on storage helper."""
|
||||
self._store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
|
||||
self._data = None
|
||||
self._hass = hass
|
||||
|
||||
async def async_get_info(self):
|
||||
"""Return the YAML storage mode."""
|
||||
|
@ -115,6 +117,8 @@ class LovelaceStorage:
|
|||
self._data['config'] = config
|
||||
await self._store.async_save(self._data)
|
||||
|
||||
self._hass.bus.async_fire(EVENT_LOVELACE_UPDATED)
|
||||
|
||||
async def _load(self):
|
||||
"""Load the config."""
|
||||
data = await self._store.async_load()
|
||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.const import (
|
|||
EVENT_THEMES_UPDATED)
|
||||
from homeassistant.components.persistent_notification import (
|
||||
EVENT_PERSISTENT_NOTIFICATIONS_UPDATED)
|
||||
from homeassistant.components.lovelace import EVENT_LOVELACE_UPDATED
|
||||
from homeassistant.helpers.area_registry import EVENT_AREA_REGISTRY_UPDATED
|
||||
from homeassistant.helpers.device_registry import EVENT_DEVICE_REGISTRY_UPDATED
|
||||
from homeassistant.helpers.entity_registry import EVENT_ENTITY_REGISTRY_UPDATED
|
||||
|
@ -26,4 +27,5 @@ SUBSCRIBE_WHITELIST = {
|
|||
EVENT_AREA_REGISTRY_UPDATED,
|
||||
EVENT_DEVICE_REGISTRY_UPDATED,
|
||||
EVENT_ENTITY_REGISTRY_UPDATED,
|
||||
EVENT_LOVELACE_UPDATED,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue