mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-06 10:44:04 +00:00
Bulbs: allow specifying transition for state changes (#70)
All state changing functions now allow defining transition time in milliseconds
This commit is contained in:
@@ -69,6 +69,17 @@ async def test_hsv(dev, turn_on):
|
||||
assert brightness == 1
|
||||
|
||||
|
||||
@color_bulb
|
||||
async def test_set_hsv_transition(dev, mocker):
|
||||
set_light_state = mocker.patch("kasa.SmartBulb.set_light_state")
|
||||
await dev.set_hsv(10, 10, 100, transition=1000)
|
||||
|
||||
set_light_state.assert_called_with(
|
||||
{"hue": 10, "saturation": 10, "brightness": 100, "color_temp": 0},
|
||||
transition=1000,
|
||||
)
|
||||
|
||||
|
||||
@color_bulb
|
||||
@turn_on
|
||||
async def test_invalid_hsv(dev, turn_on):
|
||||
@@ -123,6 +134,14 @@ async def test_try_set_colortemp(dev, turn_on):
|
||||
assert dev.color_temp == 2700
|
||||
|
||||
|
||||
@variable_temp
|
||||
async def test_set_color_temp_transition(dev, mocker):
|
||||
set_light_state = mocker.patch("kasa.SmartBulb.set_light_state")
|
||||
await dev.set_color_temp(2700, transition=100)
|
||||
|
||||
set_light_state.assert_called_with({"color_temp": 2700}, transition=100)
|
||||
|
||||
|
||||
@variable_temp
|
||||
async def test_unknown_temp_range(dev, monkeypatch):
|
||||
with pytest.raises(SmartDeviceException):
|
||||
@@ -166,6 +185,26 @@ async def test_dimmable_brightness(dev, turn_on):
|
||||
await dev.set_brightness("foo")
|
||||
|
||||
|
||||
@bulb
|
||||
async def test_turn_on_transition(dev, mocker):
|
||||
set_light_state = mocker.patch("kasa.SmartBulb.set_light_state")
|
||||
await dev.turn_on(transition=1000)
|
||||
|
||||
set_light_state.assert_called_with({"on_off": 1}, transition=1000)
|
||||
|
||||
await dev.turn_off(transition=100)
|
||||
|
||||
set_light_state.assert_called_with({"on_off": 0}, transition=100)
|
||||
|
||||
|
||||
@bulb
|
||||
async def test_dimmable_brightness_transition(dev, mocker):
|
||||
set_light_state = mocker.patch("kasa.SmartBulb.set_light_state")
|
||||
await dev.set_brightness(10, transition=1000)
|
||||
|
||||
set_light_state.assert_called_with({"brightness": 10}, transition=1000)
|
||||
|
||||
|
||||
@dimmable
|
||||
async def test_invalid_brightness(dev):
|
||||
assert dev.is_dimmable
|
||||
|
Reference in New Issue
Block a user