Computer/Controlling Kasa (TP-Link) smart devices (Bulb, Plug) on Linux
How to control Kasa (TP-Link) smart devices (Bulb, Plug) on Linux[edit | edit source]
Main_Page > Computer > Controlling Kasa (TP-Link) smart devices (Bulb, Plug) on Linux
Installing python-kasa (This example is for Ubuntu and Linux Mint)[edit | edit source]
If your Linux has no pip, then install it. (If you are using python3...)
apt install python3-pip
Install python-kasa.
pip install python-kasa
or some version of pip like this.
pip3.8 install python-kasa
Then you may get like below messages.
Collecting python-kasa Downloading python_kasa-0.4.0-py3-none-any.whl (99 kB) |████████████████████████████████| 99 kB 730 kB/s Collecting importlib-metadata Downloading importlib_metadata-4.8.2-py3-none-any.whl (17 kB) Collecting asyncclick<8,>=7 Downloading asyncclick-7.1.2.3.tar.gz (371 kB) |████████████████████████████████| 371 kB 4.0 MB/s Collecting zipp>=0.5 Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB) Collecting anyio>=2 Downloading anyio-3.4.0-py3-none-any.whl (78 kB) |████████████████████████████████| 78 kB 1.4 MB/s Requirement already satisfied: idna>=2.8 in /usr/lib/python3/dist-packages (from anyio>=2->asyncclick<8,>=7->python-kasa) (2.8) Collecting sniffio>=1.1 Downloading sniffio-1.2.0-py3-none-any.whl (10 kB) Building wheels for collected packages: asyncclick Building wheel for asyncclick (setup.py) ... done Created wheel for asyncclick: filename=asyncclick-7.1.2.3-py2.py3-none-any.whl size=82270 sha256=71d958996e367aaa94ee9cd6ab326f59505575b8dc3dd83ce588447c6a6e767a Stored in directory: /root/.cache/pip/wheels/fc/e3/0d/9db371e6593a82f274034ff04b4c9b8c20ef95b6ebd7bf3c7f Successfully built asyncclick Installing collected packages: zipp, importlib-metadata, sniffio, anyio, asyncclick, python-kasa Successfully installed anyio-3.4.0 asyncclick-7.1.2.3 importlib-metadata-4.8.2 python-kasa-0.4.0 sniffio-1.2.0 zipp-3.6.0
How to use the kasa program (with an example)[edit | edit source]
For example (I used a smart plug (an outdoor strip) KP400 and a smart bulb KL125)
KP400 has two plugs (Left side and right side). You can change the parameters from the examples. Enjoy controlling your devices. 😉💡🔌
Join the wifi network[edit | edit source]
If the LED is not blinking orange and green, then press and hold one of the button for five seconts until the LED light starts blinking. Then, you need to connect to Wifi SSID: TP-LINK... with your computer. Then...
kasa --host 192.168.0.1 wifi join --password theSSIDpassword yourSSID
After the green LED is blinking serveral times, you can connect to the smartplug. You have to know the smartplug IP address checking your wifi router or using some app to find the IP address.
you can execute simply kasa command without any options, then it can discover Kasa devices.
- Example... Smart plug IP address is 192.168.1.127
- Example... Smart bulb IP address is 192.168.1.98
Kasa Smart plug (strip)[edit | edit source]
- Turn on the plug 1 (Left plug)
kasa --strip --host 192.168.1.127 on --index 0
- Turn on the plug 2 (Right plug)
kasa --strip --host 192.168.1.127 off --index 1
- Turn on the name "Kitchen wall" plug.
kasa --strip --host <host> on --name "Kitchen wall"
- Turn off the LED indicators.
kasa --strip --host 192.168.1.127 led 0
- Turn on the LED indicators.
kasa --strip --host 192.168.1.127 led 1
Kasa smart bulb[edit | edit source]
- Turn on the bulb
kasa --bulb --host 192.168.1.98 on
- Turn off the bulb
kasa --bulb --host 192.168.1.98 off
- Adjust the bulb brightness (0~100)
Kasa --bulb --host 192.168.1.98 brightness 50
- Adjust the bulb colour temperature (min: 2500K, max: 6500K)
Kasa --bulb --host 192.168.1.98 temperature 3000
It's going to be warm white.
Kasa --bulb --host 192.168.1.98 temperature 6500
It's going to be cool white.
- Adjust the colour
kasa hsv [options] [H] [S] [V]
(H: 0~360, S: 0~100, V: 0~100)
- Turn red
Kasa --bulb --host 192.168.1.98 hsv 0 100 100
- Turn yellow
Kasa --bulb --host 192.168.1.98 hsv 60 100 100
- Turn green
Kasa --bulb --host 192.168.1.98 hsv 120 100 100
- Turn sky blue
Kasa --bulb --host 192.168.1.98 hsv 180 100 100
- Turn blue
Kasa --bulb --host 192.168.1.98 hsv 240 100 100
- Turn purple
Kasa --bulb --host 192.168.1.98 hsv 300 100 100
- Turn red
Kasa --bulb --host 192.168.1.98 hsv 360 100 100
How to reset Kasa smart devices[edit | edit source]
For LB130、KL110B 1.0、KL120、KL110 1.0、KL130B 1.0、KL130 1.0、LB230、LB110、LB100TKIT、LB200、LB100[edit | edit source]
- To reset the Smart Wi-Fi LED Bulbs without losing the configuration settings:
- Turn the light switch controlling the bulb to the OFF position.
- Flip the light switch on and off 3 times
- To reset the Smart Wi-Fi LED Bulbs to factory defaults:
- Turn the light switch controlling the bulb to the OFF position.
- Flip the light switch on and off 5 times
For KL50、KL110B 2.0、KL430 1.0、KL60、KL60B、KL110 2.0、KL130B 2.0、KL130 2.0、KL50B、KL125 1.20、KL125 2.0[edit | edit source]
- To reset the Smart Wi-Fi LED Bulbs without losing the configuration settings:
- Turn the light switch controlling the bulb to the OFF position.
- Flip the light switch on and off 5 times
- To reset the Smart Wi-Fi LED Bulbs to factory defaults:
- Turn the light switch controlling the bulb to the OFF position.
- Flip the light switch on and off 10 times
When resetting the bulb, please do not switch the bulb on and off too quickly, the time duration is around 1s.
For the KL430, please press and hold the button on the controller for 10 seconds until the Light Strip animates orange and green to enable Setup Mode.
For Smart plugs and strips[edit | edit source]
- To reset the Smart Wi-Fi plug without losing the configuration settings:
- Press and hold any one of the control buttons for 5s to reset Wi-Fi connection.
- To reset the Smart Wi-Fi plug to factory defaults:
- Press and hold any one of the control buttons for 10s to factory reset your plug.
Reference[edit | edit source]
- python-kasa GitHub - https://github.com/python-kasa/python-kasa
- TP-Link official page - How to reset smart plug - https://www.tp-link.com/ca/support/faq/2648/
- TP-Link official page - How to reset smart bulb - *https://www.tp-link.com/ca/support/faq/2660/