8000 tradfri: Improve color temp support detection by balloob · Pull Request #7211 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tradfri: Improve color temp support detection #7211

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 1 commit into from
Apr 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
32 changes: 19 additions & 13 deletions homeassistant/components/light/tradfri.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = ['tradfri']
SUPPORTED_FEATURES = (SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR)
SUPPORTED_FEATURES_IKEA = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP)
PLATFORM_SCHEMA = LIGHT_PLATFORM_SCHEMA
IKEA = 'ikea_of_sweden'

ALLOWED_TEMPERATURES = {IKEA: {2200: 'efd275', 2700: 'f1e0b5', 4000: 'f5faf6'}}
ALLOWED_FEATURES = {IKEA: SUPPORTED_FEATURES_IKEA}
IKEA = 'IKEA of Sweden'
ALLOWED_TEMPERATURES = {
IKEA: {2200: 'efd275', 2700: 'f1e0b5', 4000: 'f5faf6'}
}


def setup_platform(hass, config, add_devices, discovery_info=None):
Expand All @@ -46,8 +44,14 @@ def __init__(self, light):
self._light_data = light.light_control.lights[0]
self._name = light.name
self._rgb_color = None
self._features = ALLOWED_FEATURES.get(
slugify(self._light.device_info.manufacturer), SUPPORTED_FEATURES)
self._features = SUPPORT_BRIGHTNESS

if self._light_data.hex_color is not None:
if self._light.device_info.manufacturer == IKEA:
self._features &= SUPPORT_COLOR_TEMP
else:
self._features &= SUPPORT_RGB_COLOR

self._ok_temps = ALLOWED_TEMPERATURES.get(
slugify(self._light.device_info.manufacturer))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove use of slugify, since you changed IKEA.


Expand All @@ -74,16 +78,18 @@ def brightness(self):
@property
def color_temp(self):
"""Return the CT color value in mireds."""
if not self.supported_features & SUPPORT_COLOR_TEMP or \
not self._ok_temps:
return
if (self._light_data.hex_color is None or
self.supported_features & SUPPORT_COLOR_TEMP == 0 or
not self._ok_temps):
return None

kelvin = next((
kelvin for kelvin, hex_color in self._ok_temps.items()
if hex_color == self._light_data.hex_color), None)
if kelvin is None:
_LOGGER.error(
'unexpected color temperature found %s',
self._light_data.hex_color)
'unexpected color temperature found for %s: %s',
self.name, self._light_data.hex_color)
return
return color_util.color_temperature_kelvin_to_mired(kelvin)

Expand Down
1 change: 1 addition & 0 deletions script/dev_docker
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ else
-v /etc/localtime:/etc/localtime:ro \
-v `pwd`:/usr/src/app \
-v `pwd`/config:/config \
--rm \
-t -i home-assistant-dev

fi
3 changes: 2 additions & 1 deletion virtualization/Docker/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ MAINTAINER Paulus Schoutsen <Paulus@PaulusSchoutsen.nl>
#ENV INSTALL_OPENZWAVE no
#ENV INSTALL_LIBCEC no
#ENV INSTALL_PHANTOMJS no
#ENV INSTALL_COAP_CLIENT no

VOLUME /config

Expand All @@ -25,7 +26,7 @@ RUN virtualization/Docker/setup_docker_prereqs
# Install hass component dependencies
COPY requirements_all.txt requirements_all.txt
RUN pip3 install --no-cache-dir -r requirements_all.txt && \
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop
pip3 install --no-cache-dir mysqlclient psycopg2 uvloop cchardet

# BEGIN: Development additions

Expand Down
0