8000 RGB Tradfri simple support by matemaciek · Pull Request #9703 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

RGB Tradfri simple support #9703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 22, 2017
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
35 changes: 16 additions & 19 deletions homeassistant/components/light/tradfri.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,16 @@ def __init__(self, light, api):
@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):
Expand Down Expand Up @@ -217,12 +219,8 @@ def brightness(self):
@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
Expand Down Expand Up @@ -297,10 +295,13 @@ def _refresh(self, 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 \
Expand All @@ -309,11 +310,7 @@ def _refresh(self, 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())
2 changes: 1 addition & 1 deletion homeassistant/components/tradfri.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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'
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,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
Expand Down
0