When changing light bulbs (KL125 in my case) between two states, the transition feature works as expected when changing the color or changing the brightness, but not both. I'm not sure if this is a limitation of the bulb or a bug in python-kasa but I wasn't able to find this behavior documented anywhere.
To reproduce from a command line, in order:
Set bulb to dim blue; Works as expected
kasa --type bulb --host 192.168.9.11 hsv 240 100 1
Transition to bright blue over 5 seconds; Works as expected
kasa --type bulb --host 192.168.9.11 hsv 240 100 100 --transition 5000
Transition to bright red over 5 seconds; Works as expected
kasa --type bulb --host 192.168.9.11 hsv 0 100 100 --transition 5000
Transition to dim blue over 5 seconds; Does NOT work as expected. Fades to dim pink/red and then changes to blue at final moment
kasa --type bulb --host 192.168.9.11 hsv 240 100 1 --transition 5000
Transition to bright red over 5 seconds; Does NOT work as expected. Changes color immediately and then increases brightness
kasa --type bulb --host 192.168.9.11 hsv 0 100 100 --transition 5000
Perhaps a similar issue. Trying the example command twice - first time seems to work, second time crashes.
hbarta@pilog3b:~$ kasa --type bulb --host 192.168.20.53 hsv 0 100 20 --transition 15000
Setting HSV: 0 100 20
hbarta@pilog3b:~$ kasa --type bulb --host 192.168.20.53 hsv 0 100 20 --transition 15000
Traceback (most recent call last):
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 94, in _execute_query
packed_block_size = await self.reader.readexactly(self.BLOCK_SIZE)
File "/usr/lib/python3.9/asyncio/streams.py", line 723, in readexactly
await self._wait_for_data('readexactly')
File "/usr/lib/python3.9/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.9/asyncio/tasks.py", line 492, in wait_for
fut.result()
asyncio.exceptions.CancelledError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 156, in _query
return await asyncio.wait_for(
File "/usr/lib/python3.9/asyncio/tasks.py", line 494, in wait_for
raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/hbarta/.local/bin/kasa", line 8, in <module>
sys.exit(cli())
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1157, in __call__
return anyio.run(self._main, main, args, kwargs, **opts)
File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 70, in run
return asynclib.run(func, *args, **backend_options)
File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 292, in run
return native_run(wrapper(), debug=debug)
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper
return await func(*args)
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1160, in _main
return await main(*args, **kwargs)
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1076, in main
rv = await self.invoke(ctx)
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1684, in invoke
await super().invoke(ctx)
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1434, in invoke
return await ctx.invoke(self.callback, **ctx.params)
File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 780, in invoke
rv = await rv
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/cli.py", line 100, in cli
await dev.update()
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 314, in update
self._last_update = await self.protocol.query(req)
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 73, in query
return await self._query(request, retry_count, timeout)
File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 163, in _query
raise SmartDeviceException(
kasa.exceptions.SmartDeviceException: Unable to query the device 192.168.20.53:
hbarta@pilog3b:~$
Does the command depend on the previous state of the bulb?
If you add --debug, you will get to see what is sent to the device and what it sends back. It could very well be that the implementation is doing something that (at least some) devices interpret differently.
There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs.
Please make sure to update to the latest python-kasa version and check if that solves the issue.
Thank you for your contributions.
Activity
HankB commented on Oct 18, 2022
Perhaps a similar issue. Trying the example command twice - first time seems to work, second time crashes.
hbarta@pilog3b:~$ kasa --type bulb --host 192.168.20.53 hsv 0 100 20 --transition 15000 Setting HSV: 0 100 20 hbarta@pilog3b:~$ kasa --type bulb --host 192.168.20.53 hsv 0 100 20 --transition 15000 Traceback (most recent call last): File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 94, in _execute_query packed_block_size = await self.reader.readexactly(self.BLOCK_SIZE) File "/usr/lib/python3.9/asyncio/streams.py", line 723, in readexactly await self._wait_for_data('readexactly') File "/usr/lib/python3.9/asyncio/streams.py", line 517, in _wait_for_data await self._waiter asyncio.exceptions.CancelledError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.9/asyncio/tasks.py", line 492, in wait_for fut.result() asyncio.exceptions.CancelledError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 156, in _query return await asyncio.wait_for( File "/usr/lib/python3.9/asyncio/tasks.py", line 494, in wait_for raise exceptions.TimeoutError() from exc asyncio.exceptions.TimeoutError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/hbarta/.local/bin/kasa", line 8, in <module> sys.exit(cli()) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1157, in __call__ return anyio.run(self._main, main, args, kwargs, **opts) File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 70, in run return asynclib.run(func, *args, **backend_options) File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 292, in run return native_run(wrapper(), debug=debug) File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete return future.result() File "/home/hbarta/.local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 287, in wrapper return await func(*args) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1160, in _main return await main(*args, **kwargs) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1076, in main rv = await self.invoke(ctx) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1684, in invoke await super().invoke(ctx) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 1434, in invoke return await ctx.invoke(self.callback, **ctx.params) File "/home/hbarta/.local/lib/python3.9/site-packages/asyncclick/core.py", line 780, in invoke rv = await rv File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/cli.py", line 100, in cli await dev.update() File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/smartdevice.py", line 314, in update self._last_update = await self.protocol.query(req) File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 73, in query return await self._query(request, retry_count, timeout) File "/home/hbarta/.local/lib/python3.9/site-packages/kasa/protocol.py", line 163, in _query raise SmartDeviceException( kasa.exceptions.SmartDeviceException: Unable to query the device 192.168.20.53: hbarta@pilog3b:~$Does the command depend on the previous state of the bulb?
Edit:
Bulb: KL130
kasa: 0.5.0
Python 3.9.2
Linux pilog3b 5.10.0-18-arm64 #1 SMP Debian 5.10.140-1 (2022-09-02) aarch64 GNU/Linux
rytilahti commented on Oct 18, 2022
If you add --debug, you will get to see what is sent to the device and what it sends back. It could very well be that the implementation is doing something that (at least some) devices interpret differently.
github-actions commented on Sep 28, 2024
There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs.
Please make sure to update to the latest python-kasa version and check if that solves the issue.
Thank you for your contributions.