bulb: allow set_hsv without v, add fallback ct range (#200)

* bulb: allow set_hsv without v, add fallback ct range

* add ColorTempRange and HSV named tuples
* add a fallback color temp range if unknown, log a warning
* set_hsv: the value is now optional

* Fix tests, change fallback range to 2700-5000
This commit is contained in:
Teemu R
2021-09-21 13:23:56 +02:00
committed by GitHub
parent 7565d03c8e
commit 2c83d8ee6d
2 changed files with 48 additions and 27 deletions

View File

@@ -148,10 +148,11 @@ async def test_set_color_temp_transition(dev, mocker):
@variable_temp
async def test_unknown_temp_range(dev, monkeypatch):
with pytest.raises(SmartDeviceException):
monkeypatch.setitem(dev._sys_info, "model", "unknown bulb")
dev.valid_temperature_range()
async def test_unknown_temp_range(dev, monkeypatch, caplog):
monkeypatch.setitem(dev._sys_info, "model", "unknown bulb")
assert dev.valid_temperature_range == (2700, 5000)
assert "Unknown color temperature range, fallback to 2700-5000" in caplog.text
@variable_temp