TP-Link/Kasa Bulbs and Plugs Control (Old, Unofficial Integration)

April 26, 2018. Added support for the HS220 Dimming Switch.

January 30, 2018. Update to Version 2. Changes
a. Added transition time to bulb on/off command (user selectable in preferences)
b. Fixed Energy Monitor to accommodate HS110(AU) data formats.
c. Commonized menus between Hub and Cloud versions.
d. Updated naming conventions to function based, supporting TP-Link’s expanding product line.
e. Changed naming conventions to support GitHub integration.

Upgrade Recommendation: Do not recommend upgrade unless you need to add device models not in previous baseline.

Verification Status:
HS100, HS105, HS200 - verified on exact device.
HS110 - previous version verified by other users.
HS115 - future product, same control as HS110.
KP100 - assumed same control as HS100.
HS210 - assumed same control as HS200.
LB100, LB110 - previous version verified by other users.
LB200, KB100 - assumed same control as LB100
LB120 - verified on exact device.
LB130 - verified on exact device
KB130, LB230 - assumed same control as LB130.
NEW: HS200 - awaiting confirmation from user.

There two options for TP-Link SmartThings Integration. Both provide control of the devices and energy monitor for capable devices.

Important Note: This integration has not been tested with the new Samsung SmartThings Application (formerly Samsung Connect). It was designed, integrated, and tested using what is now called the SmartThings Classic application. If you succeed in installation and running on the new app, Please add comments on this blog. Old users - do not upgrade to the new SmartThings App until the SmartThings staff says that upgrades are ready.

a. CLOUD-BASED: Integration of the TP-Link Plugs, Switches, and Bulbs through a SmartThings to TP-LInk cloud interface. Requires a TP-Link account as well as a SmartThings IDE account. Detailed installation instructions are provided. Below is the link to the Cloud-based version:
https://github.com/DaveGut/Cloud-Based_TP-Link-to-SmartThings-Integration

b. HUB-BASED: Integration of the TP-Link Plugs, Switches, and Bulbs through a SmartThings to YOUR HUB interface. Requires an always-on Hub (PC, Raspberry) running Node.js and a SmartThings IDE account. Detailed installation instructions are provided. Below is the link to the Hub-based version:
https://github.com/DaveGut/Hub-Based_TP-Link-to-SmartThings-Integration

02-19-2018. Update Energy Monitor versions of the device handlers to accommodate devices that maintain more than 31 days of data. Update:

  1. Replace file contents. Save and Publish.
  2. In phone app, go to preferences and select save (this will update the processing function). If you do not do this, it will update around midnight.
23 Likes

I’m also in the same boat with the TP-Link LB-130 Wi-Fi Smart Bulb. I bought it before I pulled the trigger and bought my ST hub.

I’m able to control it via Alexa & TP’s Kasa app, but haven’t had any luck figuring out an interface any other way…

Hi Dave,
I’m assuming the code is the same for the LB130. I would love to give it a try. I have a node.js server and working HS-100 switches…

I too purchased a few of these before I decided to go with Smartthings. I saw the limitations immediately after using them for five minutes. Right now, they work fine with Alexa. I only have three of them. Once I replace them with something else, I’ll put them in my outdoor wall sconces. Those lights often get turned on by accident and I use them very rarely.

I will continue to watch development for these devices but I’m not counting on anything. Frankly, I’d rather see good routines that control scenes and color.

Thanks Dave,
I will set it up this weekend and give you some feedback.
-Mike

Mike,

I created a LB130 version today. All files are the same except the LB130 Groovy file.

On/Off, Brightness, Color Temp, and Circadian/Normal should work file.

Color Wheel - see if this changes the colors. At the bottom of the wheel page, there are circles. These scroll and provide about 10 pre-set colors.

After setting color, see if
Color Temp changes back to non-color light.
Brightness works as expected.

One known problem - refresh does not capture the bulbs actual Hue and Saturation.

Hi Dave,
I have it set up per your instructions. Works fine for almost all
functions. I get an error message and the node server exits when I trigger
"off".
Attached is the error log.
Let me know how I can assist.
-Mike

Here is an additional error after restarting the node server and doing a
device refresh.

Testing so far-
Works:
ON
Refresh (while on)
Brightness
Color temp
Circadian mode

Does not work:
Off
Color change - commands are sent but no color change occurs.

Thanks!
-Mike

Mike,

Two things.

The problem is in some parameter that is set on the color bulb but not the LB-120. Need your help, if you wish.

Go to my GitHub page and download the directory LB-130 test, installing it in the LB1nn bulb directory.

The four .js files need update in about line 6, where you need to replace my IP address with your IP address.

Then run LB-130 Test.bat file. It will pop up a window with instruction. When done, you can copy the window and paste it here. It should give me information i need to get color working again. I am guessing that there are parameters I do not know - which would cause an error.

Dave

Sounds good Dave… Working on it now.

Here are the results… Not local but I will re-run the tests later tonight
and eyeball the colors… Thanks!

Mike, No results were displayed.

BTW - I will be getting a LB130 late tomorrow. So it will get solved soon.

Hi Dave,
Did you not get the text file or did it not contain what you expected to
see? I am willing to troubleshoot further if you wish…Thanks for all your
efforts.
-Mike

Trying this again…

did not get the text file. You probably have to copy and paste the content of the file vice the file itself.

Hi Dave - thanks for writing this integration, I’m trying to get it setup. I’m technical, but haven’t been a developer in 15+ years. Hoping you can help with the problem I’m seeing. I’ve tried setting up the interface on 2 different PCs, both have the same problem. When running node with the LB1nn.js script, everything seems ok and connected, but I always get this error:

Sun 02/12/2017
11:51 AM
The LB-1nn controller has started
(This script is designed to work with the LB1nn.groovy device handler)

Sun Feb 12 2017 11:51:04 GMT-0500 (Eastern Standard Time):
        Sent command: "on_off" // value: 0 // // bulb: 192.128.1.221
C:\Users\steve\Downloads\TP-Link-LB1nn-Bulb-master\LB1nn.js:79
                console.log("   Status: Power: " + on_off + " / Mode: " + mode + " / Level: " + level)
                                                   ^

ReferenceError: on_off is not defined
    at Timeout.displayResults [as _onTimeout] (C:\Users\steve\Downloads\TP-Link-LB1nn-Bulb-master\LB1nn.js:79:36)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)
Sun 02/12/2017
11:51 AM
The LB-1nn controller has started
(This script is designed to work with the LB1nn.groovy device handler) 

Any thoughts on what I’m missing?

I did try your LB130 scripts, they all worked fine talking directly to the bulb.

Thanks again!
Steve

Steve,

Error indicates that the LB-130 has a different status string than the LB-120. So parsing is incorrect.

Can you run the scripts again and copy the data to this blog. The data from the script results will tell me how the bulb works and what I need to change.

I currently have only an LB120, and had to make assumptions for the LB130. I am getting an LB130 late this afternoon, and should resolve problem quickly. So worst-case, sometime Monday.

PS - I am a retired Aerospace engineering project manager. This is my first JAVA effort (ever).

Sorry for not being clear, I have the LB120, not the LB130.

Do you still want me to run the scripts? I only ran the LB130 scripts because I was out of options.

Congrats on retirement! I work in aerospace, jet engines actually.

It was the IP addresses… I fat fingered one of the addresses. Sorry about that. Once I saw your script I realized why your LB130 test scripts worked but from the ST IDE they failed.

Everything is working great now. Thanks for the help!

EDIT - looks like I’m seeing some inconsistencies with the commands. Sometimes it works, sometimes it fails. Not sure if you’ve seen this too?

The LB-1nn controller has started
(This script is designed to work with the LB1nn.groovy device handler)

Sun Feb 12 2017 14:13:18 GMT-0500 (Eastern Standard Time):
        Sent command: "on_off" // value: 1 // // bulb: 192.168.1.221
        Status: Power: on / Mode: normal / Level: 100
                Color Temp: 2700 / Hue: 0 / Saturation: 0

Sun Feb 12 2017 14:13:22 GMT-0500 (Eastern Standard Time):
        Sent command: "on_off" // value: 0 // // bulb: 192.168.1.221
        Status: Power: on / Mode: normal / Level: 100
                Color Temp: 2700 / Hue: 0 / Saturation: 0

Sun Feb 12 2017 14:13:33 GMT-0500 (Eastern Standard Time):
        Sent command: "on_off" // value: 0 // // bulb: 192.168.1.221
        Status: Power: off / Mode: normal / Level: 100
                Color Temp: 2700 / Hue: 0 / Saturation: 0

Sun Feb 12 2017 14:25:54 GMT-0500 (Eastern Standard Time):
        Sent command: "status" // value:  // // bulb: 192.168.1.221
undefined:1
{"system":{"get_sysinfo":{"sw_ver":"1.1.0 Build 160630 Rel.085319","hw_ver":"1.0
","model":"LB120(US)","description":"Smart Wi-Fi LED Bulb with Tunable White Lig
ht","alias":"Living Room","mic_type":"IOT.SMARTBULB","dev_state":"normal","mic_m
ac":"50C7BF1AC59D","deviceId":"80126440BC5ABBB01768774BFE8BBC3A17EDDCDC","oemId"
:"3444835A20788C514CB24B9F869A0A5E","hwId":"111E35908497A05512E259BB76801E10","i
s_factory":false,"disco_ver":"1.0","ctrl_protocols":{"name":"Linkie","version":"
1.0"},"light_state":{"on_off":0,"dft_on_state":{"mode":"normal","hue":0,"saturat
ion":0,"color_temp":2700,"brightness":100}},"is_dimmable":1,"is_color":0,"is_var
iable_color_temp":1,"preferred_state":[{"index":0,"hue":0,"saturation":0,"color_
temp":3500,"brightness":100},{"index":1,"hue":0,"saturation":0,"color_temp":6500
,"brightness":50},{"index":2,"hue":0,"saturation":0,"color_temp":2700,"brightnes
s":50},{"index":3,"hue":0,"saturation":0,"color_temp":2700,"brightness":1}],"rss
i":-40,"active_mode":"schedule","heapsize":416644,

SyntaxError: Unexpected end of JSON input
    at Object.parse (native)
    at Socket.socket.on (G:\Software\Applications-Utilities\TP-Link-LB1nn-Bulb-m
aster\node_modules\lb1nn-api\lib\bulb.js:60:15)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)
Sun 02/12/2017
02:25 PM
The LB-1nn controller has started
(This script is designed to work with the LB1nn.groovy device handler)