mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 03:07:50 +00:00
Support LIFX Mini products (#10996)
* Support new LIFX products * Remove lint
This commit is contained in:
parent
0a7e6ac222
commit
4d6070e33a
@ -33,7 +33,7 @@ import homeassistant.util.color as color_util
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REQUIREMENTS = ['aiolifx==0.6.0', 'aiolifx_effects==0.1.2']
|
REQUIREMENTS = ['aiolifx==0.6.1', 'aiolifx_effects==0.1.2']
|
||||||
|
|
||||||
UDP_BROADCAST_PORT = 56700
|
UDP_BROADCAST_PORT = 56700
|
||||||
|
|
||||||
@ -157,20 +157,10 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def lifxwhite(device):
|
def lifx_features(device):
|
||||||
"""Return whether this is a white-only bulb."""
|
"""Return a feature map for this device, or a default map if unknown."""
|
||||||
features = aiolifx().products.features_map.get(device.product, None)
|
return aiolifx().products.features_map.get(device.product) or \
|
||||||
if features:
|
aiolifx().products.features_map.get(1)
|
||||||
return not features["color"]
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def lifxmultizone(device):
|
|
||||||
"""Return whether this is a multizone bulb/strip."""
|
|
||||||
features = aiolifx().products.features_map.get(device.product, None)
|
|
||||||
if features:
|
|
||||||
return features["multizone"]
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def find_hsbk(**kwargs):
|
def find_hsbk(**kwargs):
|
||||||
@ -342,12 +332,12 @@ class LIFXManager(object):
|
|||||||
device.retry_count = MESSAGE_RETRIES
|
device.retry_count = MESSAGE_RETRIES
|
||||||
device.unregister_timeout = UNAVAILABLE_GRACE
|
device.unregister_timeout = UNAVAILABLE_GRACE
|
||||||
|
|
||||||
if lifxwhite(device):
|
if lifx_features(device)["multizone"]:
|
||||||
entity = LIFXWhite(device, self.effects_conductor)
|
|
||||||
elif lifxmultizone(device):
|
|
||||||
entity = LIFXStrip(device, self.effects_conductor)
|
entity = LIFXStrip(device, self.effects_conductor)
|
||||||
else:
|
elif lifx_features(device)["color"]:
|
||||||
entity = LIFXColor(device, self.effects_conductor)
|
entity = LIFXColor(device, self.effects_conductor)
|
||||||
|
else:
|
||||||
|
entity = LIFXWhite(device, self.effects_conductor)
|
||||||
|
|
||||||
_LOGGER.debug("%s register READY", entity.who)
|
_LOGGER.debug("%s register READY", entity.who)
|
||||||
self.entities[device.mac_addr] = entity
|
self.entities[device.mac_addr] = entity
|
||||||
@ -427,6 +417,29 @@ class LIFXLight(Light):
|
|||||||
"""Return a string identifying the device."""
|
"""Return a string identifying the device."""
|
||||||
return "%s (%s)" % (self.device.ip_addr, self.name)
|
return "%s (%s)" % (self.device.ip_addr, self.name)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def min_mireds(self):
|
||||||
|
"""Return the coldest color_temp that this light supports."""
|
||||||
|
kelvin = lifx_features(self.device)['max_kelvin']
|
||||||
|
return math.floor(color_util.color_temperature_kelvin_to_mired(kelvin))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def max_mireds(self):
|
||||||
|
"""Return the warmest color_temp that this light supports."""
|
||||||
|
kelvin = lifx_features(self.device)['min_kelvin']
|
||||||
|
return math.ceil(color_util.color_temperature_kelvin_to_mired(kelvin))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def supported_features(self):
|
||||||
|
"""Flag supported features."""
|
||||||
|
support = SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION | SUPPORT_EFFECT
|
||||||
|
|
||||||
|
device_features = lifx_features(self.device)
|
||||||
|
if device_features['min_kelvin'] != device_features['max_kelvin']:
|
||||||
|
support |= SUPPORT_COLOR_TEMP
|
||||||
|
|
||||||
|
return support
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def brightness(self):
|
def brightness(self):
|
||||||
"""Return the brightness of this light between 0..255."""
|
"""Return the brightness of this light between 0..255."""
|
||||||
@ -571,22 +584,6 @@ class LIFXLight(Light):
|
|||||||
class LIFXWhite(LIFXLight):
|
class LIFXWhite(LIFXLight):
|
||||||
"""Representation of a white-only LIFX light."""
|
"""Representation of a white-only LIFX light."""
|
||||||
|
|
||||||
@property
|
|
||||||
def min_mireds(self):
|
|
||||||
"""Return the coldest color_temp that this light supports."""
|
|
||||||
return math.floor(color_util.color_temperature_kelvin_to_mired(6500))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_mireds(self):
|
|
||||||
"""Return the warmest color_temp that this light supports."""
|
|
||||||
return math.ceil(color_util.color_temperature_kelvin_to_mired(2700))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def supported_features(self):
|
|
||||||
"""Flag supported features."""
|
|
||||||
return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_TRANSITION |
|
|
||||||
SUPPORT_EFFECT)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def effect_list(self):
|
def effect_list(self):
|
||||||
"""Return the list of supported effects for this light."""
|
"""Return the list of supported effects for this light."""
|
||||||
@ -599,21 +596,12 @@ class LIFXWhite(LIFXLight):
|
|||||||
class LIFXColor(LIFXLight):
|
class LIFXColor(LIFXLight):
|
||||||
"""Representation of a color LIFX light."""
|
"""Representation of a color LIFX light."""
|
||||||
|
|
||||||
@property
|
|
||||||
def min_mireds(self):
|
|
||||||
"""Return the coldest color_temp that this light supports."""
|
|
||||||
return math.floor(color_util.color_temperature_kelvin_to_mired(9000))
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_mireds(self):
|
|
||||||
"""Return the warmest color_temp that this light supports."""
|
|
||||||
return math.ceil(color_util.color_temperature_kelvin_to_mired(2500))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_TRANSITION |
|
support = super().supported_features
|
||||||
SUPPORT_EFFECT | SUPPORT_RGB_COLOR | SUPPORT_XY_COLOR)
|
support |= SUPPORT_RGB_COLOR | SUPPORT_XY_COLOR
|
||||||
|
return support
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def effect_list(self):
|
def effect_list(self):
|
||||||
|
@ -72,7 +72,7 @@ aiohttp_cors==0.5.3
|
|||||||
aioimaplib==0.7.13
|
aioimaplib==0.7.13
|
||||||
|
|
||||||
# homeassistant.components.light.lifx
|
# homeassistant.components.light.lifx
|
||||||
aiolifx==0.6.0
|
aiolifx==0.6.1
|
||||||
|
|
||||||
# homeassistant.components.light.lifx
|
# homeassistant.components.light.lifx
|
||||||
aiolifx_effects==0.1.2
|
aiolifx_effects==0.1.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user