mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-05-17 03:51:09 +00:00
* Change valid hue range to 0-359 (fixes #130) Tested on LB130(EU) hardware 1.0, firmware 1.8.6 Build 180809 Rel.091659 Co-Authored-By: nkonopinski <nkonopinski@users.noreply.github.com> * Update README.md * Update test_bulb.py
This commit is contained in:
parent
189029b199
commit
c65d4c0b30
@ -206,7 +206,7 @@ if bulb.is_variable_color_temp:
|
|||||||
|
|
||||||
### Setting the color
|
### Setting the color
|
||||||
|
|
||||||
Hue is given in degrees (0-360) and saturation and value in percentage.
|
Hue is given in degrees (0-359) and saturation and value in percentage.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
print(bulb.hsv)
|
print(bulb.hsv)
|
||||||
|
@ -142,10 +142,10 @@ class SmartBulb(SmartDevice):
|
|||||||
if not self.is_color:
|
if not self.is_color:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if not isinstance(state[0], int) or not (0 <= state[0] <= 255):
|
if not isinstance(state[0], int) or not (0 <= state[0] <= 359):
|
||||||
raise SmartDeviceException(
|
raise SmartDeviceException(
|
||||||
'Invalid hue value: {} '
|
'Invalid hue value: {} '
|
||||||
'(valid range: 0-255)'.format(state[0]))
|
'(valid range: 0-359)'.format(state[0]))
|
||||||
|
|
||||||
if not isinstance(state[1], int) or not (0 <= state[1] <= 100):
|
if not isinstance(state[1], int) or not (0 <= state[1] <= 100):
|
||||||
raise SmartDeviceException(
|
raise SmartDeviceException(
|
||||||
|
@ -51,7 +51,7 @@ class TestSmartBulb(TestCase):
|
|||||||
'light_state': {
|
'light_state': {
|
||||||
'brightness': All(int, Range(min=0, max=100)),
|
'brightness': All(int, Range(min=0, max=100)),
|
||||||
'color_temp': int,
|
'color_temp': int,
|
||||||
'hue': All(int, Range(min=0, max=255)),
|
'hue': All(int, Range(min=0, max=359)),
|
||||||
'mode': str,
|
'mode': str,
|
||||||
'on_off': check_int_bool,
|
'on_off': check_int_bool,
|
||||||
'saturation': All(int, Range(min=0, max=255)),
|
'saturation': All(int, Range(min=0, max=255)),
|
||||||
@ -63,7 +63,7 @@ class TestSmartBulb(TestCase):
|
|||||||
'preferred_state': [{
|
'preferred_state': [{
|
||||||
'brightness': All(int, Range(min=0, max=100)),
|
'brightness': All(int, Range(min=0, max=100)),
|
||||||
'color_temp': int,
|
'color_temp': int,
|
||||||
'hue': All(int, Range(min=0, max=255)),
|
'hue': All(int, Range(min=0, max=359)),
|
||||||
'index': int,
|
'index': int,
|
||||||
'saturation': All(int, Range(min=0, max=255)),
|
'saturation': All(int, Range(min=0, max=255)),
|
||||||
}],
|
}],
|
||||||
@ -210,10 +210,10 @@ class TestSmartBulb(TestCase):
|
|||||||
|
|
||||||
def test_hsv(self):
|
def test_hsv(self):
|
||||||
hue, saturation, brightness = self.bulb.hsv
|
hue, saturation, brightness = self.bulb.hsv
|
||||||
self.assertTrue(0 <= hue <= 255)
|
self.assertTrue(0 <= hue <= 359)
|
||||||
self.assertTrue(0 <= saturation <= 100)
|
self.assertTrue(0 <= saturation <= 100)
|
||||||
self.assertTrue(0 <= brightness <= 100)
|
self.assertTrue(0 <= brightness <= 100)
|
||||||
for invalid_hue in [-1, 256, 0.5]:
|
for invalid_hue in [-1, 360, 0.5]:
|
||||||
with self.assertRaises(SmartDeviceException):
|
with self.assertRaises(SmartDeviceException):
|
||||||
self.bulb.hsv = (invalid_hue, 0, 0)
|
self.bulb.hsv = (invalid_hue, 0, 0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user