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 2017-03-05 00:10:36 +01:00 committed by Paulus Schoutsen
parent 3044aecbe9
commit 8232f1ef65
30 changed files with 124 additions and 108 deletions

View file

@ -71,7 +71,7 @@ def setup_proximity_component(hass, name, config):
zone_id, unit_of_measurement)
proximity.entity_id = '{}.{}'.format(DOMAIN, proximity_zone)
proximity.update_ha_state()
proximity.schedule_update_ha_state()
track_state_change(
hass, proximity_devices, proximity.check_proximity_state_change)
@ -161,7 +161,7 @@ class Proximity(Entity):
self.dist_to = 'not set'
self.dir_of_travel = 'not set'
self.nearest = 'not set'
self.update_ha_state()
self.schedule_update_ha_state()
return
# At least one device is in the monitored zone so update the entity.
@ -169,7 +169,7 @@ class Proximity(Entity):
self.dist_to = 0
self.dir_of_travel = 'arrived'
self.nearest = devices_in_zone
self.update_ha_state()
self.schedule_update_ha_state()
return
# We can't check proximity because latitude and longitude don't exist.
@ -214,7 +214,7 @@ class Proximity(Entity):
self.dir_of_travel = 'unknown'
device_state = self.hass.states.get(closest_device)
self.nearest = device_state.name
self.update_ha_state()
self.schedule_update_ha_state()
return
# Stop if we cannot calculate the direction of travel (i.e. we don't
@ -223,7 +223,7 @@ class Proximity(Entity):
self.dist_to = round(distances_to_zone[entity])
self.dir_of_travel = 'unknown'
self.nearest = entity_name
self.update_ha_state()
self.schedule_update_ha_state()
return
# Reset the variables
@ -250,7 +250,7 @@ class Proximity(Entity):
self.dist_to = round(dist_to_zone)
self.dir_of_travel = direction_of_travel
self.nearest = entity_name
self.update_ha_state()
self.schedule_update_ha_state()
_LOGGER.debug('proximity.%s update entity: distance=%s: direction=%s: '
'device=%s', self.friendly_name, round(dist_to_zone),
direction_of_travel, entity_name)