RGB Tradfri simple support (#9703)

This commit is contained in:
Maciej Sokołowski 2017-10-22 17:22:51 +02:00 committed by Lewis Juggins
parent 4197c9ee85
commit 193188b965
3 changed files with 18 additions and 21 deletions

View file

@ -161,14 +161,16 @@ class TradfriLight(Light):
@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
from pytradfri.color import MAX_KELVIN_WS
return color_util.color_temperature_kelvin_to_mired(MAX_KELVIN_WS)
return color_util.color_temperature_kelvin_to_mired(
self._light_control.max_kelvin
)
@property
def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
from pytradfri.color import MIN_KELVIN_WS
return color_util.color_temperature_kelvin_to_mired(MIN_KELVIN_WS)
return color_util.color_temperature_kelvin_to_mired(
self._light_control.min_kelvin
)
@property
def device_state_attributes(self):
@ -217,12 +219,8 @@ class TradfriLight(Light):
@property
def color_temp(self):
"""Return the CT color value in mireds."""
if (self._light_data.kelvin_color is None or
self.supported_features & SUPPORT_COLOR_TEMP == 0 or
not self._temp_supported):
return None
return color_util.color_temperature_kelvin_to_mired(
self._light_data.kelvin_color
self._light_data.kelvin_color_inferred
)
@property
@ -297,10 +295,13 @@ class TradfriLight(Light):
self._rgb_color = None
self._features = SUPPORTED_FEATURES
if self._light_data.hex_color is not None:
if self._light.device_info.manufacturer == IKEA:
if self._light.device_info.manufacturer == IKEA:
if self._light_control.can_set_kelvin:
self._features |= SUPPORT_COLOR_TEMP
else:
if self._light_control.can_set_color:
self._features |= SUPPORT_RGB_COLOR
else:
if self._light_data.hex_color is not None:
self._features |= SUPPORT_RGB_COLOR
self._temp_supported = self._light.device_info.manufacturer \
@ -309,11 +310,7 @@ class TradfriLight(Light):
def _observe_update(self, tradfri_device):
"""Receive new state data for this light."""
self._refresh(tradfri_device)
# Handle Hue lights paired with the gateway
# hex_color is 0 when bulb is unreachable
if self._light_data.hex_color not in (None, '0'):
self._rgb_color = color_util.rgb_hex_to_rgb_list(
self._light_data.hex_color)
self._rgb_color = color_util.rgb_hex_to_rgb_list(
self._light_data.hex_color_inferred
)
self.hass.async_add_job(self.async_update_ha_state())

View file

@ -16,7 +16,7 @@ from homeassistant.helpers import discovery
from homeassistant.const import CONF_HOST, CONF_API_KEY
from homeassistant.components.discovery import SERVICE_IKEA_TRADFRI
REQUIREMENTS = ['pytradfri==3.0',
REQUIREMENTS = ['pytradfri==3.0.2',
'DTLSSocket==0.1.3',
'https://github.com/chrysn/aiocoap/archive/'
'3286f48f0b949901c8b5c04c0719dc54ab63d431.zip'

View file

@ -852,7 +852,7 @@ pythonegardia==1.0.22
pytrackr==0.0.5
# homeassistant.components.tradfri
pytradfri==3.0
pytradfri==3.0.2
# homeassistant.components.device_tracker.unifi
pyunifi==2.13