RGB Tradfri simple support (#9703)
This commit is contained in:
parent
4197c9ee85
commit
193188b965
3 changed files with 18 additions and 21 deletions
|
@ -161,14 +161,16 @@ class TradfriLight(Light):
|
||||||
@property
|
@property
|
||||||
def min_mireds(self):
|
def min_mireds(self):
|
||||||
"""Return the coldest color_temp that this light supports."""
|
"""Return the coldest color_temp that this light supports."""
|
||||||
from pytradfri.color import MAX_KELVIN_WS
|
return color_util.color_temperature_kelvin_to_mired(
|
||||||
return color_util.color_temperature_kelvin_to_mired(MAX_KELVIN_WS)
|
self._light_control.max_kelvin
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_mireds(self):
|
def max_mireds(self):
|
||||||
"""Return the warmest color_temp that this light supports."""
|
"""Return the warmest color_temp that this light supports."""
|
||||||
from pytradfri.color import MIN_KELVIN_WS
|
return color_util.color_temperature_kelvin_to_mired(
|
||||||
return color_util.color_temperature_kelvin_to_mired(MIN_KELVIN_WS)
|
self._light_control.min_kelvin
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
@ -217,12 +219,8 @@ class TradfriLight(Light):
|
||||||
@property
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the CT color value in mireds."""
|
"""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(
|
return color_util.color_temperature_kelvin_to_mired(
|
||||||
self._light_data.kelvin_color
|
self._light_data.kelvin_color_inferred
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -297,10 +295,13 @@ class TradfriLight(Light):
|
||||||
self._rgb_color = None
|
self._rgb_color = None
|
||||||
self._features = SUPPORTED_FEATURES
|
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
|
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._features |= SUPPORT_RGB_COLOR
|
||||||
|
|
||||||
self._temp_supported = self._light.device_info.manufacturer \
|
self._temp_supported = self._light.device_info.manufacturer \
|
||||||
|
@ -309,11 +310,7 @@ class TradfriLight(Light):
|
||||||
def _observe_update(self, tradfri_device):
|
def _observe_update(self, tradfri_device):
|
||||||
"""Receive new state data for this light."""
|
"""Receive new state data for this light."""
|
||||||
self._refresh(tradfri_device)
|
self._refresh(tradfri_device)
|
||||||
|
self._rgb_color = color_util.rgb_hex_to_rgb_list(
|
||||||
# Handle Hue lights paired with the gateway
|
self._light_data.hex_color_inferred
|
||||||
# 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.hass.async_add_job(self.async_update_ha_state())
|
self.hass.async_add_job(self.async_update_ha_state())
|
||||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.helpers import discovery
|
||||||
from homeassistant.const import CONF_HOST, CONF_API_KEY
|
from homeassistant.const import CONF_HOST, CONF_API_KEY
|
||||||
from homeassistant.components.discovery import SERVICE_IKEA_TRADFRI
|
from homeassistant.components.discovery import SERVICE_IKEA_TRADFRI
|
||||||
|
|
||||||
REQUIREMENTS = ['pytradfri==3.0',
|
REQUIREMENTS = ['pytradfri==3.0.2',
|
||||||
'DTLSSocket==0.1.3',
|
'DTLSSocket==0.1.3',
|
||||||
'https://github.com/chrysn/aiocoap/archive/'
|
'https://github.com/chrysn/aiocoap/archive/'
|
||||||
'3286f48f0b949901c8b5c04c0719dc54ab63d431.zip'
|
'3286f48f0b949901c8b5c04c0719dc54ab63d431.zip'
|
||||||
|
|
|
@ -852,7 +852,7 @@ pythonegardia==1.0.22
|
||||||
pytrackr==0.0.5
|
pytrackr==0.0.5
|
||||||
|
|
||||||
# homeassistant.components.tradfri
|
# homeassistant.components.tradfri
|
||||||
pytradfri==3.0
|
pytradfri==3.0.2
|
||||||
|
|
||||||
# homeassistant.components.device_tracker.unifi
|
# homeassistant.components.device_tracker.unifi
|
||||||
pyunifi==2.13
|
pyunifi==2.13
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue