Fix LIFX unregister races (#6723)

* Fix LIFX unregister races

If the initial state request never got a response, we tried to unregister
a device that was not yet registered.

Also, aiolifx 0.4.2 has an "unregister" race fix.

* Update requirements
This commit is contained in:
Anders Melchiorsen 2017-03-21 07:17:58 +01:00 committed by Pascal Vizeli
parent 4ee8be52fe
commit ba3c9f9765
2 changed files with 8 additions and 7 deletions

View File

@ -25,7 +25,7 @@ import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['aiolifx==0.4.1.post1']
REQUIREMENTS = ['aiolifx==0.4.2']
UDP_BROADCAST_PORT = 56700
@ -95,11 +95,12 @@ class LIFXManager(object):
@callback
def unregister(self, device):
"""Callback for disappearing bulb."""
entity = self.entities[device.mac_addr]
_LOGGER.debug("%s unregister", entity.ipaddr)
entity.available = False
entity.updated_event.set()
self.hass.async_add_job(entity.async_update_ha_state())
if device.mac_addr in self.entities:
entity = self.entities[device.mac_addr]
_LOGGER.debug("%s unregister", entity.ipaddr)
entity.available = False
entity.updated_event.set()
self.hass.async_add_job(entity.async_update_ha_state())
def convert_rgb_to_hsv(rgb):

View File

@ -41,7 +41,7 @@ aiodns==1.1.1
aiohttp_cors==0.5.0
# homeassistant.components.light.lifx
aiolifx==0.4.1.post1
aiolifx==0.4.2
# homeassistant.components.camera.amcrest
# homeassistant.components.sensor.amcrest