Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions homeassistant/components/light/lifx.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_LOGGER = logging.getLogger(__name__)

REQUIREMENTS = ['aiolifx==0.6.1', 'aiolifx_effects==0.1.2']
REQUIREMENTS = ['aiolifx==0.6.3', 'aiolifx_effects==0.1.2']

UDP_BROADCAST_PORT = 56700

Expand Down Expand Up @@ -201,7 +201,7 @@ def merge_hsbk(base, change):
"""Copy change on top of base, except when None."""
if change is None:
return None
return list(map(lambda x, y: y if y is not None else x, base, change))
return [b if c is None else c for b, c in zip(base, change)]


class LIFXManager(object):
Expand Down Expand Up @@ -256,7 +256,7 @@ async def service_handler(service):

async def start_effect(self, entities, service, **kwargs):
"""Start a light effect on entities."""
devices = list(map(lambda l: l.device, entities))
devices = [light.device for light in entities]

if service == SERVICE_EFFECT_PULSE:
effect = aiolifx_effects().EffectPulse(
Expand Down Expand Up @@ -314,12 +314,13 @@ async def register_new_device(self, device):

# Read initial state
ack = AwaitAioLIFX().wait
version_resp = await ack(device.get_version)
if version_resp:
color_resp = await ack(device.get_color)
color_resp = await ack(device.get_color)
if color_resp:
version_resp = await ack(device.get_version)

if version_resp is None or color_resp is None:
if color_resp is None or version_resp is None:
_LOGGER.error("Failed to initialize %s", device.ip_addr)
device.registered = False
else:
device.timeout = MESSAGE_TIMEOUT
device.retry_count = MESSAGE_RETRIES
Expand Down Expand Up @@ -440,18 +441,13 @@ def supported_features(self):
@property
def brightness(self):
"""Return the brightness of this light between 0..255."""
brightness = convert_16_to_8(self.device.color[2])
_LOGGER.debug("brightness: %d", brightness)
return brightness
return convert_16_to_8(self.device.color[2])

@property
def color_temp(self):
"""Return the color temperature."""
kelvin = self.device.color[3]
temperature = color_util.color_temperature_kelvin_to_mired(kelvin)

_LOGGER.debug("color_temp: %d", temperature)
return temperature
return color_util.color_temperature_kelvin_to_mired(kelvin)

@property
def is_on(self):
Expand Down Expand Up @@ -564,7 +560,6 @@ async def default_effect(self, **kwargs):

async def async_update(self):
"""Update bulb status."""
_LOGGER.debug("%s async_update", self.who)
if self.available and not self.lock.locked():
await AwaitAioLIFX().wait(self.device.get_color)

Expand Down Expand Up @@ -627,7 +622,7 @@ async def set_color(self, ack, hsbk, kwargs, duration=0):

zones = list(range(0, num_zones))
else:
zones = list(filter(lambda x: x < num_zones, set(zones)))
zones = [x for x in set(zones) if x < num_zones]

# Zone brightness is not reported when powered off
if not self.is_on and hsbk[2] is None:
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ aiohue==1.5.0
aioimaplib==0.7.13

# homeassistant.components.light.lifx
aiolifx==0.6.1
aiolifx==0.6.3

# homeassistant.components.light.lifx
aiolifx_effects==0.1.2
Expand Down