control-ikea-lightbulb
This skill provides a lightweight Python script to control a local smart bulb (supports TP-Link Kasa-compatible bulbs via python-kasa). It is intended for local LAN devices that do not require cloud credentials; control is by IP address.
When to use this skill
- - When you want to turn a bulb on or off
- When you want to set brightness (0-100)
- When you want to set color (HSV)
- When you have the bulb's local IP and it's accessible from this machine
Contents
- - scripts/controlkasalight.py — main runnable script (Python 3.9+)
- scripts/light_show.py — small light-show controller for sequences (uses python-kasa). Changes include:
- Default white uses a high color temperature (9000K) to make white appear "whiter"; pass --white-temp to override.
- Bug fixes: the off-flash between blue→red now ignores transitions to white (saturation==0) to avoid white<->blue ping-pong, and white-temp is only applied to white steps (fixes red being skipped during off-flash). White steps also set brightness even without --double-write.
- - scripts/runtestlightshow.sh — helper to run lightshow via uv
Notes
- - This repo is set up for uv (no manual environment activation). Dependencies live in
pyproject.toml and wrappers prefer uv run.
Example:
uv run --project ./skills/control-ikea-lightbulb python ./skills/control-ikea-lightbulb/scripts/control
kasalight.py --ip 192.168.4.69 --on --hsv 0 100 80 --brightness 80
-
brew install uv (macOS)
-
pipx install uv (cross-platform)
- - The provided wrapper script requires uv:
./skills/control-ikea-lightbulb/scripts/run
controlkasa.sh --ip 192.168.4.69 --on --hsv 0 100 80 --brightness 80
- - The test helper also prefers uv:
./skills/control-ikea-lightbulb/scripts/run
testlight_show.sh --ip 192.168.4.69 --duration 6 --transition 1 --off-flash --verbose
- - If your device is actually an IKEA TRADFRI device (not Kasa), this script is a starting point; tell me and I will add TRADFRI support.
- No cloud credentials are required; control happens over LAN to the device's IP.
Quick start
- 1. Install uv (macOS):
brew install uv
- 2. Turn the bulb on (replace the IP):
./skills/control-ikea-lightbulb/scripts/run_control_kasa.sh --ip 192.168.4.69 --on
- 3. Set color and brightness:
INLINECODE6
Git note
- - No local environment artifacts are tracked; use uv.
Note about Python requirements and recent change
- - The skill previously declared python-kasa>=0.13.0 which caused dependency resolution failures on this machine. To make the skill runnable locally the project's pyproject.toml was adjusted to:
- requires-python = ">=3.11, <4.0"
- python-kasa>=0.10.2
- - This allows the resolver to pick a compatible python-kasa on machines with Python 3.11+. If you prefer a different constraint (or want me to revert this change), tell me and I will update the pyproject.toml and README accordingly.
control-ikea-lightbulb
本技能提供了一个轻量级Python脚本,用于控制本地智能灯泡(通过python-kasa支持兼容TP-Link Kasa的灯泡)。它适用于不需要云凭证的本地局域网设备;通过IP地址进行控制。
何时使用本技能
- - 当您想要打开或关闭灯泡时
- 当您想要设置亮度(0-100)时
- 当您想要设置颜色(HSV)时
- 当您拥有灯泡的本地IP且本机可访问时
内容
- - scripts/controlkasalight.py — 主运行脚本(Python 3.9+)
- scripts/light_show.py — 用于序列的小型灯光秀控制器(使用python-kasa)。变更包括:
- 默认白色使用高色温(9000K)使白色显得更白;传递--white-temp可覆盖。
- 错误修复:蓝色→红色之间的关闭闪烁现在忽略过渡到白色(饱和度==0)以避免白色<->蓝色乒乓效应,且white-temp仅应用于白色步骤(修复了关闭闪烁期间红色被跳过的问题)。白色步骤即使没有--double-write也会设置亮度。
- - scripts/runtestlightshow.sh — 通过uv运行lightshow的辅助脚本
注意事项
- - 本仓库设置为使用uv(无需手动激活环境)。依赖项位于pyproject.toml中,包装脚本优先使用uv run。
示例:
uv run --project ./skills/control-ikea-lightbulb python ./skills/control-ikea-lightbulb/scripts/control
kasalight.py --ip 192.168.4.69 --on --hsv 0 100 80 --brightness 80
- brew install uv(macOS)
- pipx install uv(跨平台)
./skills/control-ikea-lightbulb/scripts/run
controlkasa.sh --ip 192.168.4.69 --on --hsv 0 100 80 --brightness 80
./skills/control-ikea-lightbulb/scripts/run
testlight_show.sh --ip 192.168.4.69 --duration 6 --transition 1 --off-flash --verbose
- - 如果您的设备实际上是IKEA TRADFRI设备(而非Kasa),此脚本可作为起点;请告知我,我将添加TRADFRI支持。
- 无需云凭证;通过局域网控制设备IP。
快速开始
- 1. 安装uv(macOS):
brew install uv
- 2. 打开灯泡(替换IP):
./skills/control-ikea-lightbulb/scripts/run
controlkasa.sh --ip 192.168.4.69 --on
- 3. 设置颜色和亮度:
./skills/control-ikea-lightbulb/scripts/run
controlkasa.sh --ip 192.168.4.69 --hsv 0 100 80 --brightness 80
Git说明
关于Python要求和近期变更的说明
- - 本技能之前声明了python-kasa>=0.13.0,导致本机依赖解析失败。为使技能可在本地运行,项目的pyproject.toml已调整为:
- requires-python = >=3.11, <4.0
- python-kasa>=0.10.2
- - 这使得解析器能够在Python 3.11+的机器上选择兼容的python-kasa。如果您偏好不同的约束(或希望我恢复此变更),请告知我,我将相应更新pyproject.toml和README。