softScheck / tplink-smartplug

TP-Link WiFi SmartPlug Client and Wireshark Dissector
Apache License 2.0
1.13k stars 296 forks source link

LB130 RGB Light #14

Open JohnnyErnest opened 7 years ago

JohnnyErnest commented 7 years ago

I wanted to share some good news that the same TP-Link Smart Home protocol works just about the same on the TP-Link LB130 RGB Light, it's a great light at $50 and pretty efficient in data transfer if you make it local only, I'm starting some dev work to try and sync the lighting to music.

Instead of TCP you'll connect to your light via UDP, and you won't pad the encrypted string with 4 0's at the beginning (or else it won't respond), starting key is still 171.

I copied and made a separate LUA script for the UDP decryption in Wireshark and for the Python if you'd like me to do a pull request.

You can send this string to the light and it does all the real functionality of the light:

{"smartlife.iot.smartbulb.lightingservice":{"transition_light_state":{"saturation:"100,"brightness":100,"mode":"normal","ignore_default":1,"color_temp":0,"hue":360,"on_off":1,"transition_period":3000}}}

Saturation and Brighness are 0-100, Hue is 0-360, on_off turns the light on or off (a brightness of 0 will still have some brightness), color_temp sets the color temperature.

Transition Period is the best functionality because it's not already included in the Kasa app. You can set the delay in milliseconds for fading between colors. I'm working on a UWP app for Windows 10.

mamejay commented 7 years ago

Hello ShiningKnightLight. Looks like you have a better understanding of the script that I do. I currently have a Australian version of the HS100 which looks like its a new hardware version and does not respond to commands VIA the python script. Looks like I get a blank response from the device when sending on/off commands. Is there anything type of trace or debug that can be done to see what could be the issue?

JohnnyErnest commented 7 years ago

Not really. If you don't send the right command syntax on the LB130 that I have you get no response. I had to change my code from Tcp to Udp. Also there was an autokey encryption at the beginning of the command string that I had to truncate.

Get Outlook for Androidhttps://aka.ms/ghei36


From: mamejay notifications@github.com Sent: Thursday, September 14, 2017 6:49:27 PM To: softScheck/tplink-smartplug Cc: Shining Knight Light; Author Subject: Re: [softScheck/tplink-smartplug] LB130 RGB Light (#14)

Hello ShiningKnightLight. Looks like you have a better understanding of the script that I do. I currently have a Australian version of the HS100 which looks like its a new hardware version and does not respond to commands VIA the python script. Looks like I get a blank response from the device when sending on/off commands. Is there anything type of trace or debug that can be done to see what could be the issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/softScheck/tplink-smartplug/issues/14#issuecomment-329639032, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AYvkRHL1s0i5vKW-C7upG46qrl3ZmpKLks5sibuGgaJpZM4Nzks5.

mamejay commented 7 years ago

Thanks for the response. Do you have a copy of your modified script that I can take a look at? Thanks

JohnnyErnest commented 7 years ago

Offhand no I ported it to C#/UWP here's a screen of my Encrypt function. I connect on UDP port 9999.

Get Outlook for Androidhttps://aka.ms/ghei36


From: mamejay notifications@github.com Sent: Thursday, September 14, 2017 7:06:05 PM To: softScheck/tplink-smartplug Cc: Shining Knight Light; Author Subject: Re: [softScheck/tplink-smartplug] LB130 RGB Light (#14)

Thanks for the response. Do you have a copy of your modified script that I can take a look at? Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/softScheck/tplink-smartplug/issues/14#issuecomment-329641396, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AYvkRJ5IjphgbQygXhnMnbYNsuwh9eOxks5sib9tgaJpZM4Nzks5.

wackydude1234 commented 6 years ago

Hey, did you ever get music to color working?

JohnnyErnest commented 6 years ago

Not quite. I moved over to the LIFX bulbs as the developer gives out docs. It also has waveform control on the lights for doing waveform animations like strobes and fades. They seem a lot more responsive over UDP as well and offer more brightness. I had some trouble as well with flickering on the TP-Link bulbs.


From: wackydude1234 notifications@github.com Sent: Friday, December 15, 2017 11:46:20 AM To: softScheck/tplink-smartplug Cc: Shining Knight Light; Author Subject: Re: [softScheck/tplink-smartplug] LB130 RGB Light (#14)

Hey, did you ever get music to color working?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/softScheck/tplink-smartplug/issues/14#issuecomment-352068252, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AYvkRENMb5Pe24sz-_2H37wGBtQMURQjks5tArBsgaJpZM4Nzks5.

sowbug commented 5 years ago

Some research results for posterity: I ordered a KL120 but Amazon mistakenly sent me a KL110. I'm about to package it back up to return, but here were the commands I successfully used before I figured out it doesn't have color temperature control.

Thanks to @GuardianArchangelJohn for filing this issue. The info I have here is merely a subset of what he posted, along with a confirmation that it works for the KL110.

pidg commented 4 years ago

Thanks @sowbug - I am using this script to control KL110 and KL110B bulbs and your comment was very helpful.

Just to add, you can set the brightness (as a percentage) using something like:

python tplink_smartplug.py -t 12.34.56.78 -j '{"smartlife.iot.smartbulb.lightingservice":{"transition_light_state":{"on_off":1,"ignore_default":1,"transition_period":100,"brightness":50}}}'

More json commands (including those for colour-changing bulbs) can be found here: https://www.briandorey.com/post/tp-link-lb130-smart-wi-fi-led-bulb-python-control