From 63fd5f2d31bb713bdcbcc616ec206204ec7c07d0 Mon Sep 17 00:00:00 2001 From: kennedyshead Date: Fri, 25 Jan 2019 23:27:44 +0100 Subject: [PATCH 1/5] Bumps aioasuswrt (#20432) --- homeassistant/components/asuswrt.py | 2 +- requirements_all.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/asuswrt.py b/homeassistant/components/asuswrt.py index 8dedb1f640a..898485b5cb3 100644 --- a/homeassistant/components/asuswrt.py +++ b/homeassistant/components/asuswrt.py @@ -14,7 +14,7 @@ from homeassistant.const import ( from homeassistant.helpers import config_validation as cv from homeassistant.helpers.discovery import async_load_platform -REQUIREMENTS = ['aioasuswrt==1.1.17'] +REQUIREMENTS = ['aioasuswrt==1.1.18'] _LOGGER = logging.getLogger(__name__) diff --git a/requirements_all.txt b/requirements_all.txt index 549b8fe3503..441d0490fb3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -87,7 +87,7 @@ abodepy==0.15.0 afsapi==0.0.4 # homeassistant.components.asuswrt -aioasuswrt==1.1.17 +aioasuswrt==1.1.18 # homeassistant.components.device_tracker.automatic aioautomatic==0.6.5 From d7bbdb033decce3d59eb643516877210a79cb42e Mon Sep 17 00:00:00 2001 From: starkillerOG Date: Tue, 29 Jan 2019 02:52:00 +0100 Subject: [PATCH 2/5] Add check to validate gamut (#20518) * color.util - Add check to validate gamut * fix indents * fix typo * Add check to validate gamut * Add tests for gamut checker * fix test * fix pylint issues * fix hue light gamut tests * add check to validate gamut * move None check * Move None check * Include prompt to update bridge/bulb on error * fix wrong commit * fix error message * Update light.py --- homeassistant/components/hue/light.py | 12 +++++++++++- homeassistant/util/color.py | 18 ++++++++++++++++++ tests/components/hue/test_light.py | 12 +++++++++--- tests/util/test_color.py | 20 ++++++++++++++++++++ 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/hue/light.py b/homeassistant/components/hue/light.py index a10b42fbeee..3327d0f9dc2 100644 --- a/homeassistant/components/hue/light.py +++ b/homeassistant/components/hue/light.py @@ -41,6 +41,7 @@ SUPPORT_HUE = { } ATTR_IS_HUE_GROUP = 'is_hue_group' +GAMUT_TYPE_UNAVAILABLE = 'None' # Minimum Hue Bridge API version to support groups # 1.4.0 introduced extended group info # 1.12 introduced the state object for groups @@ -221,7 +222,7 @@ class HueLight(Light): if is_group: self.is_osram = False self.is_philips = False - self.gamut_typ = 'None' + self.gamut_typ = GAMUT_TYPE_UNAVAILABLE self.gamut = None else: self.is_osram = light.manufacturername == 'OSRAM' @@ -229,6 +230,15 @@ class HueLight(Light): self.gamut_typ = self.light.colorgamuttype self.gamut = self.light.colorgamut _LOGGER.debug("Color gamut of %s: %s", self.name, str(self.gamut)) + if self.gamut: + if not color.check_valid_gamut(self.gamut): + err = "Please check for software updates of the bridge " \ + "and/or bulb in the Philips Hue App, " \ + "Color gamut of %s: %s, not valid, " \ + "setting gamut to None." + _LOGGER.warning(err, self.name, str(self.gamut)) + self.gamut_typ = GAMUT_TYPE_UNAVAILABLE + self.gamut = None @property def unique_id(self): diff --git a/homeassistant/util/color.py b/homeassistant/util/color.py index 5a32d89a793..6d7f3336566 100644 --- a/homeassistant/util/color.py +++ b/homeassistant/util/color.py @@ -600,3 +600,21 @@ def check_point_in_lamps_reach(p: Tuple[float, float], t = cross_product(v1, q) / cross_product(v1, v2) return (s >= 0.0) and (t >= 0.0) and (s + t <= 1.0) + + +def check_valid_gamut(Gamut: GamutType) -> bool: + """Check if the supplied gamut is valid.""" + # Check if the three points of the supplied gamut are not on the same line. + v1 = XYPoint(Gamut.green.x - Gamut.red.x, Gamut.green.y - Gamut.red.y) + v2 = XYPoint(Gamut.blue.x - Gamut.red.x, Gamut.blue.y - Gamut.red.y) + not_on_line = cross_product(v1, v2) > 0.0001 + + # Check if all six coordinates of the gamut lie between 0 and 1. + red_valid = Gamut.red.x >= 0 and Gamut.red.x <= 1 and \ + Gamut.red.y >= 0 and Gamut.red.y <= 1 + green_valid = Gamut.green.x >= 0 and Gamut.green.x <= 1 and \ + Gamut.green.y >= 0 and Gamut.green.y <= 1 + blue_valid = Gamut.blue.x >= 0 and Gamut.blue.x <= 1 and \ + Gamut.blue.y >= 0 and Gamut.blue.y <= 1 + + return not_on_line and red_valid and green_valid and blue_valid diff --git a/tests/components/hue/test_light.py b/tests/components/hue/test_light.py index f7865fcf4f8..eabfd6d35aa 100644 --- a/tests/components/hue/test_light.py +++ b/tests/components/hue/test_light.py @@ -701,7 +701,9 @@ def test_available(): """Test available property.""" light = hue_light.HueLight( light=Mock(state={'reachable': False}, - raw=LIGHT_RAW), + raw=LIGHT_RAW, + colorgamuttype=LIGHT_GAMUT_TYPE, + colorgamut=LIGHT_GAMUT), request_bridge_update=None, bridge=Mock(allow_unreachable=False), is_group=False, @@ -711,7 +713,9 @@ def test_available(): light = hue_light.HueLight( light=Mock(state={'reachable': False}, - raw=LIGHT_RAW), + raw=LIGHT_RAW, + colorgamuttype=LIGHT_GAMUT_TYPE, + colorgamut=LIGHT_GAMUT), request_bridge_update=None, bridge=Mock(allow_unreachable=True), is_group=False, @@ -721,7 +725,9 @@ def test_available(): light = hue_light.HueLight( light=Mock(state={'reachable': False}, - raw=LIGHT_RAW), + raw=LIGHT_RAW, + colorgamuttype=LIGHT_GAMUT_TYPE, + colorgamut=LIGHT_GAMUT), request_bridge_update=None, bridge=Mock(allow_unreachable=False), is_group=True, diff --git a/tests/util/test_color.py b/tests/util/test_color.py index b54b2bc5776..14195d43821 100644 --- a/tests/util/test_color.py +++ b/tests/util/test_color.py @@ -8,6 +8,18 @@ import voluptuous as vol GAMUT = color_util.GamutType(color_util.XYPoint(0.704, 0.296), color_util.XYPoint(0.2151, 0.7106), color_util.XYPoint(0.138, 0.08)) +GAMUT_INVALID_1 = color_util.GamutType(color_util.XYPoint(0.704, 0.296), + color_util.XYPoint(-0.201, 0.7106), + color_util.XYPoint(0.138, 0.08)) +GAMUT_INVALID_2 = color_util.GamutType(color_util.XYPoint(0.704, 1.296), + color_util.XYPoint(0.2151, 0.7106), + color_util.XYPoint(0.138, 0.08)) +GAMUT_INVALID_3 = color_util.GamutType(color_util.XYPoint(0.0, 0.0), + color_util.XYPoint(0.0, 0.0), + color_util.XYPoint(0.0, 0.0)) +GAMUT_INVALID_4 = color_util.GamutType(color_util.XYPoint(0.1, 0.1), + color_util.XYPoint(0.3, 0.3), + color_util.XYPoint(0.7, 0.7)) class TestColorUtil(unittest.TestCase): @@ -338,6 +350,14 @@ class TestColorUtil(unittest.TestCase): assert color_util.color_rgb_to_hex(51, 153, 255) == '3399ff' assert color_util.color_rgb_to_hex(255, 67.9204190, 0) == 'ff4400' + def test_gamut(self): + """Test gamut functions.""" + assert color_util.check_valid_gamut(GAMUT) + assert not color_util.check_valid_gamut(GAMUT_INVALID_1) + assert not color_util.check_valid_gamut(GAMUT_INVALID_2) + assert not color_util.check_valid_gamut(GAMUT_INVALID_3) + assert not color_util.check_valid_gamut(GAMUT_INVALID_4) + class ColorTemperatureMiredToKelvinTests(unittest.TestCase): """Test color_temperature_mired_to_kelvin.""" From ba4d4bcd29557f236213dabdd2aec7c20caa3379 Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Tue, 29 Jan 2019 01:46:37 +0100 Subject: [PATCH 3/5] fix #20387 devices without model/protocol (#20530) --- homeassistant/components/tellduslive/entry.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/tellduslive/entry.py b/homeassistant/components/tellduslive/entry.py index 929dc700afb..d6e56329699 100644 --- a/homeassistant/components/tellduslive/entry.py +++ b/homeassistant/components/tellduslive/entry.py @@ -116,10 +116,17 @@ class TelldusLiveEntity(Entity): def device_info(self): """Return device info.""" device = self._client.device_info(self.device.device_id) - return { + device_info = { 'identifiers': {('tellduslive', self.device.device_id)}, 'name': self.device.name, - 'model': device['model'].title(), - 'manufacturer': device['protocol'].title(), - 'via_hub': ('tellduslive', device.get('client')), } + model = device.get('model') + if model is not None: + device_info['model'] = model.title() + protocol = device.get('protocol') + if protocol is not None: + device_info['manufacturer'] = protocol.title() + client = device.get('client') + if client is not None: + device_info['via_hub'] = ('tellduslive', client) + return device_info From 234c759b45aa6ba602c2966e6140fc52e7fed8a3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 28 Jan 2019 17:52:42 -0800 Subject: [PATCH 4/5] Bumped version to 0.86.4 --- homeassistant/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/const.py b/homeassistant/const.py index dca028e0681..28e94d0a666 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -2,7 +2,7 @@ """Constants used by Home Assistant components.""" MAJOR_VERSION = 0 MINOR_VERSION = 86 -PATCH_VERSION = '3' +PATCH_VERSION = '4' __short_version__ = '{}.{}'.format(MAJOR_VERSION, MINOR_VERSION) __version__ = '{}.{}'.format(__short_version__, PATCH_VERSION) REQUIRED_PYTHON_VER = (3, 5, 3) From fe47253f683fde9b8153bebf47d2e34286ba2249 Mon Sep 17 00:00:00 2001 From: Rohan Kapoor Date: Sat, 26 Jan 2019 17:11:09 -0800 Subject: [PATCH 5/5] Fix linting error (#20488) --- homeassistant/helpers/config_validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 1edf52cbb7f..56d64cd8fd9 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -156,7 +156,7 @@ def entity_id(value: Any) -> str: value = string(value).lower() if valid_entity_id(value): return value - elif re.match(OLD_ENTITY_ID_VALIDATION, value): + if re.match(OLD_ENTITY_ID_VALIDATION, value): # To ease the breaking change, we allow old slugs for now # Remove after 0.94 or 1.0 fixed = '.'.join(util_slugify(part) for part in value.split('.', 1))