Cleanup async handling (#6388)

* Cleanups unneeded blocks

* Cleanup bootstrap

* dedicated update_ha_state

* Fix imap_email_content

* fx tests

* Fix lint & spell
This commit is contained in:
Pascal Vizeli authored and Paulus Schoutsen committed 2017-03-04 15:10:36 -08:00
1 parent 3044aecbe9
commit 8232f1ef65
30 files changed
+124 -108

No files matched your search

+3 -13
View File
@@ -180,14 +180,9 @@ class Entity(object):
If force_refresh == True will update entity before setting state.
"""
# We're already in a thread, do the force refresh here.
if force_refresh and not hasattr(self, 'async_update'):
self.update()
force_refresh = False
run_coroutine_threadsafe(
self.async_update_ha_state(force_refresh), self.hass.loop
).result()
_LOGGER.warning("'update_ha_state' is deprecated. "
"Use 'schedule_update_ha_state' instead.")
self.schedule_update_ha_state(force_refresh)
@asyncio.coroutine
def async_update_ha_state(self, force_refresh=False):
@@ -280,11 +275,6 @@ class Entity(object):
That is only needed on executor to not block.
"""
# We're already in a thread, do the force refresh here.
if force_refresh and not hasattr(self, 'async_update'):
self.update()
force_refresh = False
self.hass.add_job(self.async_update_ha_state(force_refresh))
def remove(self) -> None:
+2 -5
View File
@@ -309,13 +309,10 @@ class EntityPlatform(object):
def schedule_add_entities(self, new_entities, update_before_add=False):
"""Add entities for a single platform."""
if update_before_add:
for entity in new_entities:
entity.update()
run_callback_threadsafe(
self.component.hass.loop,
self.async_schedule_add_entities, list(new_entities), False
self.async_schedule_add_entities, list(new_entities),
update_before_add
).result()
@callback