From 4cb28a3b254cd149b3dbc6d8210147c18eb582d7 Mon Sep 17 00:00:00 2001 From: Annika Jacobs <7255210+annikajayuk@users.noreply.github.com> Date: Wed, 16 Jan 2019 20:50:48 +0000 Subject: [PATCH] Updated valid range to 360 (with passing tests) (#153) * Updated valid range to 360 with it set to 359 it will not show the color red. Just tested this with a buddies bulb - same model/fw https://imgur.com/a/kSNZIuL * Updated valid range to 360 with it set to 359 it will not show the color red. Just tested this with a buddies bulb - same model/fw https://imgur.com/a/kSNZIuL * Update valid range to 360 * Fix tests --- README.md | 2 +- pyHS100/smartbulb.py | 4 ++-- pyHS100/tests/test_bulb.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e5849463..e6919ea8 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ if bulb.is_variable_color_temp: ### Setting the color -Hue is given in degrees (0-359) and saturation and value in percentage. +Hue is given in degrees (0-360) and saturation and value in percentage. ```python print(bulb.hsv) diff --git a/pyHS100/smartbulb.py b/pyHS100/smartbulb.py index 22306891..55919744 100644 --- a/pyHS100/smartbulb.py +++ b/pyHS100/smartbulb.py @@ -142,10 +142,10 @@ class SmartBulb(SmartDevice): if not self.is_color: return None - if not isinstance(state[0], int) or not (0 <= state[0] <= 359): + if not isinstance(state[0], int) or not (0 <= state[0] <= 360): raise SmartDeviceException( 'Invalid hue value: {} ' - '(valid range: 0-359)'.format(state[0])) + '(valid range: 0-360)'.format(state[0])) if not isinstance(state[1], int) or not (0 <= state[1] <= 100): raise SmartDeviceException( diff --git a/pyHS100/tests/test_bulb.py b/pyHS100/tests/test_bulb.py index c89fc940..74d67200 100644 --- a/pyHS100/tests/test_bulb.py +++ b/pyHS100/tests/test_bulb.py @@ -51,7 +51,7 @@ class TestSmartBulb(TestCase): 'light_state': { 'brightness': All(int, Range(min=0, max=100)), 'color_temp': int, - 'hue': All(int, Range(min=0, max=359)), + 'hue': All(int, Range(min=0, max=360)), 'mode': str, 'on_off': check_int_bool, 'saturation': All(int, Range(min=0, max=255)), @@ -63,7 +63,7 @@ class TestSmartBulb(TestCase): 'preferred_state': [{ 'brightness': All(int, Range(min=0, max=100)), 'color_temp': int, - 'hue': All(int, Range(min=0, max=359)), + 'hue': All(int, Range(min=0, max=360)), 'index': int, 'saturation': All(int, Range(min=0, max=255)), }], @@ -210,10 +210,10 @@ class TestSmartBulb(TestCase): def test_hsv(self): hue, saturation, brightness = self.bulb.hsv - self.assertTrue(0 <= hue <= 359) + self.assertTrue(0 <= hue <= 360) self.assertTrue(0 <= saturation <= 100) self.assertTrue(0 <= brightness <= 100) - for invalid_hue in [-1, 360, 0.5]: + for invalid_hue in [-1, 361, 0.5]: with self.assertRaises(SmartDeviceException): self.bulb.hsv = (invalid_hue, 0, 0)