TP-Link Plugin - How To (v0.1.2)

Posted on
Wed Jul 25, 2018 9:22 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

TP-Link Plugin - How To (v0.1.2)

The TP-Link Plugin brings TP-Link SmartPlugs into indigo.
This is a trial release. I know it needs work and I'd appreciate your input.

A SmartPlug is a WiFi enabled plug, similar in behavior to an Insteon or X-10 plug, so it is modeled as a "relay" (on/off) type Device.

Download the plugin here: https://github.com/jtburgess/indigo-TP-LInk/releases/download/0.1.2/TP-Link-Device.indigoPlugin.zip.
Install by double-clicking the downloaded plugin.

You'll need to know the IP address of your SmartPlug, which you can get from your DHCP server, typically your gateway/Wifi Router.
It's a good idea to configure a static IP for SmartPlugs on the DHCP server if it supports that capability.
This will make sure it always gets the same address should the router reboot or otherwise has its DHCP cache cleared.

Then add a new Device. Select Type = "TP-Link Device", and Model = "SmartPlug".
Aside - There may be other TP-Link device types. If you know of any, let me know.
It will ask for the address.
That's it!
Click On to turn it on, and Off to turn it off.

Repeat for other SmartPlugs.

Since a SmartPlug can also be controlled by Alexa or the "Kasa" app, the "Send Status Request" button will update Indigo with the on/off state returned from the device itself. It also prints complete information about the device into the Indigo Log.

Known bug: The state value shows as" true"/"false" when you turn it on/off, but shows as "on"/"off" as returned by status. I'm working on it. Suggestions on a fix are welcomed.

Posted on
Mon Aug 13, 2018 7:44 pm
akimball offline
Posts: 559
Joined: Aug 07, 2013
Location: Sandy, Utah

Re: TP-Link Plugin - How To (v0.1.2)

Picked up a TP Link Kasa smart plug from Amazon.com. They were on sale for $10 (quantity one). I didn't even know there might be a plugin and your timing was great. This one...

https://www.amazon.com/gp/product/B01K1 ... UTF8&psc=1

Not sure if they are still on sale; if you've bought an Amazon Echo, ever, Amazon will let you buy one of these for $10 at checkout by entering the code "SMART10" ... but i think the sale may be over.

Thought I'd report no issues whatsoever. Worked first time and it's speedy. I suppose I can delete the TP-LINK app they made me download to get the unit online initially... I won't use it, we have indigo after all. Except for one contingency...

If I pull this thing out of the wall there is no way to force it into the same IP address on my DNS without doing a DHCP RESERVATION. I locked it down on my network. That required knowing the MAC Address of the TP Link device... which is what the APP gave me.

Using the MAC address I ID'd the device for your plugin and then also did the reservation.... very easy. Thanks for the plugin.

-Al

Posted on
Mon Aug 13, 2018 8:03 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin - How To (v0.1.2)

I did the same thing, bought one for $10 along with an Echo Dot, and that’s why I created the plugin.
For mine, I created a static DHCP mapping to solve the reboot problem.

I hadn’t thought about using MAC address. That’s a good idea, and I’ll look into it.
Another thought is that maybe it uses the name you give it in the Kasa app for the local DNS. That would be even easier, if it’s true.

I’m adding both to my ToDo list.

Thanks for the feedback.

Posted on
Mon Aug 13, 2018 8:41 pm
akimball offline
Posts: 559
Joined: Aug 07, 2013
Location: Sandy, Utah

Re: TP-Link Plugin - How To (v0.1.2)

I prefer in-wall devices mostly....but sometimes a roaming outlet fits the bill, like this tp link. That’s why I bought this and also why it’s likely to get unplugged and reassigned with another IP address when used again. The reservation works well. Typically I have about 25% of my network IP addresses populated with wifi devices so there’s plenty of reservation space on my network.

Thanks again. Your plugin does a great job. I love having such low latency.

-Al

Posted on
Tue Aug 14, 2018 9:45 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: TP-Link Plugin - How To (v0.1.2)

akimball wrote:
I love having such low latency.


Big +1 for locally controllable WiFi devices!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Aug 14, 2018 7:49 pm
akimball offline
Posts: 559
Joined: Aug 07, 2013
Location: Sandy, Utah

Re: TP-Link Plugin - How To (v0.1.2)

So tonight I tried to do a little more with the pluging. I got it going easily with both Siri and Alexa. But not so good with indigo touch. I use a toggle control to turn on/turn off all my other plugs, with a little fake blue led on the indigo touch interface. Looking at the log, the off command is sent, but the fake glowing led in my interface stays on (no status reported I guess). The real led on the tp-link goes off as the event log showed. So it did get turned off. Trying to turn it back on with the same toggle switch control doen’t work since it always thinks its on. Even though it was clearly sent the off command and turns off. I can turn it back on by sending it a turn ‘on’ command from siri, alexa, indigo, but not my indigo touch user interface.

I know the work around is to not use the toggle commands and use two separate UI controls, one for off command and the other for on command....but wanted you to know something’s not reporting status on the plugin.

More information: From the device screen in Indigo 7, if I press the “send status request” button...this is what i get in the event log (see below).

Theory: i may have messed it up by giving it the name “roamIO Plug” in the KASA app initialization, the I renamed it to “Great Room Camera” in indigo for Alexa purposes.
Attachments
IMG_0428.jpg
IMG_0428.jpg (227.8 KiB) Viewed 9676 times

-Al

Posted on
Thu Nov 22, 2018 12:21 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: TP-Link Plugin - How To (v0.1.2)

Thanks for your work on this plugin. Smart plugs are proliferating. I just purchased two Amazon Smart Plugs. I am guessing they use the same chip as the TP-Link, Wemo, and others. I setup the two Smart Plugs and they work fine with Alexa. I discovered their IP addresses with IP Scanner Pro app and added the two devices to Indigo with the TP-Link Plugin. The plugin is not able to turn the Smart Plugs on or off. I don't know if this is a plugin problem or if the Amazon Smart Plug is not compatible. Following is the error message received when I attempted to turn the plug off. Thoughts?

TP-Link Device Error Error in plugin execution ExecuteAction:

Traceback (most recent call last):
File "plugin.py", line 118, in actionControlDimmerRelay
File "/Library/Application Support/Perceptive Automation/Indigo 7.2/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_smartplug.py", line 96, in send
NameError: global name 'ip' is not defined

John R Patrick
Author of
Home Attitude

Posted on
Thu Nov 22, 2018 7:31 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: TP-Link Plugin - How To (v0.1.2)

Just because a device is WiFi doesn't mean it uses the same API. Wemo is definitely not the same api as the tp-link, and it's unlikely (thought possible) the Amazon one uses the same API as either of those (they may not even publish the API).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Nov 23, 2018 7:56 am
siclark offline
Posts: 1960
Joined: Jun 13, 2017
Location: UK

Re: TP-Link Plugin - How To (v0.1.2)

Thanks for this timely comment. 3 pack on Amazon is £36 today, means I can ditch the 433mhz ones that have poor range and automate more Christmas lights inside!!

Posted on
Fri Nov 23, 2018 1:55 pm
wideglidejrp offline
User avatar
Posts: 555
Joined: Jan 15, 2012
Location: Danbury, CT

Re: TP-Link Plugin - How To (v0.1.2)

Does the fact the Amazon Smart Plugs work with Alexa make it any more likely there is or will be an API available to enable Indigo support through this plugin or otherwise?

John R Patrick
Author of
Home Attitude

Posted on
Mon Dec 10, 2018 1:44 pm
stanleykrasnow offline
Posts: 28
Joined: Dec 10, 2018

Re: TP-Link Plugin - How To (v0.1.2)

I just installed the TP Link Plugin from the Plug In Store and am able to add a TP Link device (plug relay) and turn if off and on both in a Python script and using the Indigo main UI. My issue is that the device status icon on the main UI does not turn to "Off".

It does indicate on when I use the UI to turn on the plug, and although the plug turns off from the UI, the ON/Off state in the UI does not go to off.

Do you have any suggestions? If I can turn the UI state indicator off from a Python script that would be a good enough workaround.

The status of the device in the Indigo Log when when I use the UI to send a status request is 0 when the device is off and 1 when the device is on.

Thank you,

Posted on
Mon Dec 10, 2018 4:21 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: TP-Link Plugin - How To (v0.1.2)

I just submitted a Github pull request to fix the status update problem. The developer will need to accept the pull request, add a new release and update the Plugin Store.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 10, 2018 9:03 pm
stanleykrasnow offline
Posts: 28
Joined: Dec 10, 2018

Re: TP-Link Plugin - How To (v0.1.2)

Thank you very much, Jay.


jay (support) wrote:
I just submitted a Github pull request to fix the status update problem. The developer will need to accept the pull request, add a new release and update the Plugin Store.

Posted on
Mon Dec 10, 2018 10:15 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin - How To (v0.1.2)

Thanks, Jay. I will check out and integrate your fix.

I also found the bug reported last month on "tplink_smartplug.py, line 96"
(missing "self.").

I'll build a new release this week.

Posted on
Tue Dec 11, 2018 1:59 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: TP-Link Plugin - How To (v0.1.2)

On Amazon Germany they look actually different, and there are two models (with energy consumption report and without)

https://www.amazon.de/TP-Link-Steckdose ... smart+plug

Will they work with they plugin?

Who is online

Users browsing this forum: No registered users and 5 guests