From b0734e613fc1849f78ab7431d2102fe343a90677 Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 30 Dec 2015 13:36:47 -0500 Subject: [PATCH 1/3] Add support for deCONZ (Raspbee-GW hue-like API) - Doesn't support the none transition type, so don't send it --- homeassistant/components/light/hue.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 77672c9aaf5..29ee523dec4 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -121,10 +121,19 @@ def setup_bridge(host, hass, add_devices_callback): new_lights = [] + api_name = api.get('config').get('name') + if api_name == 'RaspBee-GW': + bridge_type = 'deconz' + _LOGGER.info("Found DeCONZ gateway (%s)", api_name) + else: + _LOGGER.info("Found Hue bridge (%s)", api_name) + bridge_type = 'hue' + for light_id, info in api_states.items(): if light_id not in lights: lights[light_id] = HueLight(int(light_id), info, - bridge, update_lights) + bridge, update_lights, + bridge_type=bridge_type) new_lights.append(lights[light_id]) else: lights[light_id].info = info @@ -163,11 +172,13 @@ def request_configuration(host, hass, add_devices_callback): class HueLight(Light): """ Represents a Hue light """ - def __init__(self, light_id, info, bridge, update_lights): + # pylint: disable=too-many-arguments + def __init__(self, light_id, info, bridge, update_lights, bridge_type='hue'): self.light_id = light_id self.info = info self.bridge = bridge self.update_lights = update_lights + self.bridge_type = bridge_type @property def unique_id(self): @@ -227,7 +238,7 @@ class HueLight(Light): command['alert'] = 'lselect' elif flash == FLASH_SHORT: command['alert'] = 'select' - else: + elif self.bridge_type == 'hue': command['alert'] = 'none' effect = kwargs.get(ATTR_EFFECT) @@ -237,7 +248,7 @@ class HueLight(Light): elif effect == EFFECT_RANDOM: command['hue'] = random.randrange(0, 65535) command['sat'] = random.randrange(150, 254) - else: + elif self.bridge_type == 'hue': command['effect'] = 'none' self.bridge.set_light(self.light_id, command) From 4e2d75a8f48cc7bfe3cc4de59508968488246dad Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Wed, 30 Dec 2015 16:59:22 -0500 Subject: [PATCH 2/3] fix style --- homeassistant/components/light/hue.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 29ee523dec4..40875d8ea0e 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -173,7 +173,8 @@ class HueLight(Light): """ Represents a Hue light """ # pylint: disable=too-many-arguments - def __init__(self, light_id, info, bridge, update_lights, bridge_type='hue'): + def __init__(self, light_id, info, bridge, update_lights, + bridge_type='hue'): self.light_id = light_id self.info = info self.bridge = bridge From a36ae4b24af3d4903203abe206aebfbc2734be2c Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Sat, 2 Jan 2016 01:01:11 -0500 Subject: [PATCH 3/3] Reduce chatiness --- homeassistant/components/light/hue.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 40875d8ea0e..61bff75bbd3 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -124,9 +124,7 @@ def setup_bridge(host, hass, add_devices_callback): api_name = api.get('config').get('name') if api_name == 'RaspBee-GW': bridge_type = 'deconz' - _LOGGER.info("Found DeCONZ gateway (%s)", api_name) else: - _LOGGER.info("Found Hue bridge (%s)", api_name) bridge_type = 'hue' for light_id, info in api_states.items():