Alexa sync state report (#24835)

* Do a sync after changing state reporting

* Fix entity config being None
This commit is contained in:
Paulus Schoutsen committed 2019-06-28 20:44:19 -07:00
1 parent 6cbfc63311
commit cc75adfed6
4 files changed
+187 -158

No files matched your search

+11 -1
View File
@@ -78,7 +78,7 @@ class AlexaConfig(alexa_config.AbstractConfig):
@property
def entity_config(self):
"""Return entity config."""
return self._config.get(CONF_ENTITY_CONFIG, {})
return self._config.get(CONF_ENTITY_CONFIG) or {}
def should_expose(self, entity_id):
"""If an entity should be exposed."""
@@ -129,6 +129,11 @@ class AlexaConfig(alexa_config.AbstractConfig):
else:
await self.async_disable_proactive_mode()
# State reporting is reported as a property on entities.
# So when we change it, we need to sync all entities.
await self.async_sync_entities()
return
# If entity prefs are the same or we have filter in config.yaml,
# don't sync.
if (self._cur_entity_prefs is prefs.alexa_entity_configs or
@@ -190,6 +195,11 @@ class AlexaConfig(alexa_config.AbstractConfig):
async def async_sync_entities(self):
"""Sync all entities to Alexa."""
# Remove any pending sync
if self._alexa_sync_unsub:
self._alexa_sync_unsub()
self._alexa_sync_unsub = None
to_update = []
to_remove = []