TP-Link Plugin v 0.9.3

Posted on
Mon Feb 15, 2021 2:46 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

TP-Link Plugin v 0.9.3

The new version supports these subtypes:
  1. the original Smart Plug (plug-ins and power strips)
  2. Smart Relay/Switch (wall switch with dimmer)
  3. Smart Bulb (light bulbs with dimmer)

Each type has a list of TP-link Model numbers (e.g. HS100, KP200, KL100) that are supported by each type.
Caveat: some of these assignments are guesses, because I can't test every model out there. (TP-Link keeps coming up with new ones!)
The reason for the 3 types is that they support fundamentally different JSON protocols.
If you discover a new model - it will show up as "unknown" - please add it to the appropriate model list in
tplink_*_plugin.py
.
If that works, let me know and I'll add it to the base code.
If it doesn't work with any existing type, use the command line tool (found in the top level directory of the plugin), run the 'info' command and send me the results. You may have discovered a new species!

I need to update the plugin description, because there are now several actions for the Smart Switch type, two of which also work for the dimmer bulb type to set its "ramp time" (the time it takes to change from one brightness to another). You can also set the rampTime in the Device Config dialog.

As always, let me know of any bugs or features you want to see.

Thanks, John

PS Does anyone have colored bulbs? How would you like them to behave? How about an action to set the color?

Posted on
Wed Feb 17, 2021 10:10 am
Ramias offline
Posts: 272
Joined: Nov 24, 2015

Re: TP-Link Plugin v 0.9.3

Upgraded from a previous version and getting this for a number of devices in my logs; it also disables comm for a number of my outlets. Rolling back to previous version resolves this.

Code: Select all
Stopped plugin TP-Link Devices
   Upgrading plugin TP-Link Devices to newer version 0.9.3 (previous version moved to trash)
   Loading plugin "TP-Link Devices 0.9.3"
   Starting plugin "TP-Link Devices 0.9.3" (pid 13633)
   TP-Link Devices                 Log level set to info
   Started plugin "TP-Link Devices 0.9.3"
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices                 Polling started for Basement Bass Speaker@192.168.0.131.
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Basement Bass Speaker: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Basement Bass Speaker connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:311): Unable to update Basement Bass Speaker: after 10 attempts. Polling for this device will now shut down. (local variable 'data' referenced before assignment)
   TP-Link Devices                 Polling started for Basement Sonos@192.168.0.131.
   TP-Link Devices                 Polling started for Basement Tivo@192.168.0.131.
   TP-Link Devices                 Polling started for Basement XBox 360@192.168.0.131.
   TP-Link Devices                 Polling started for Basement XBox One@192.168.0.131.
   TP-Link Devices                 Polling started for Basement Yamaha Receiver@192.168.0.131.
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Cabinet Lights Left: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Cabinet Lights Left: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Cabinet Lights Left: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Cabinet Lights Left: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')
   TP-Link Devices Error           (tpl_relay_poll.py:run:316): Error attempting to update Cabinet Lights Left: local variable 'data' referenced before assignment. Will try again in 30 seconds
   TP-Link Devices Error           (tpl_relay_poll.py:run:81): Cabinet Lights Left connection failed with ('NoneType' object has no attribute 'debug')

Posted on
Sun Feb 21, 2021 11:04 am
mintzps offline
Posts: 26
Joined: Apr 13, 2010

Re: TP-Link Plugin v 0.9.3

I just upgraded my mac to Big Sur and Indigo to 7.5. Just go a KASA Smart Outdoor plug. Trying to use the TP-Link plugin here is what I get in my log when I try to create a device. I dont have acluw when it comes to Python. What does all this mean?

Feb 21, 2021 at 11:42:36 AM
TP-Link Devices Error (plugin.py:getTpDevice:462): Discovery connection failed with ('NoneType' object has no attribute 'debug')

Feb 21, 2021 at 11:43:43 AM
TP-Link Devices Error Error in plugin execution UiAction:

Traceback (most recent call last):
File "plugin.py", line 507, in selectTpDevice
File "plugin.py", line 311, in initializeDev
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/protocol.py", line 99, in send
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/protocol.py", line 193, in debugLog
AttributeError: 'NoneType' object has no attribute 'debug'

TP-Link Devices Error Error in plugin execution UiValidate:

Traceback (most recent call last):
File "plugin.py", line 210, in validateDeviceConfigUi
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_relay_plugin.py", line 35, in validateDeviceConfigUi
KeyError: key childId not found in dict

TP-Link Devices Error Error in plugin execution UiValidate:

Traceback (most recent call last):
File "plugin.py", line 210, in validateDeviceConfigUi
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_relay_plugin.py", line 35, in validateDeviceConfigUi
KeyError: key childId not found in dict


Feb 21, 2021 at 11:44:19 AM
Reloading plugin "TP-Link Devices 0.9.3"
Stopping plugin "TP-Link Devices 0.9.3" (pid 2495)
Stopped plugin "TP-Link Devices 0.9.3"
Starting plugin "TP-Link Devices 0.9.3" (pid 3546)
TP-Link Devices Log level set to
Started plugin "TP-Link Devices 0.9.3"

Feb 21, 2021 at 11:44:42 AM
TP-Link Devices Error (plugin.py:getTpDevice:462): Discovery connection failed with ('NoneType' object has no attribute 'debug')

Feb 21, 2021 at 11:50:00 AM
TP-Link Devices Changed log level to
Disabling plugin "TP-Link Devices 0.9.3"
Stopping plugin "TP-Link Devices 0.9.3" (pid 3546)
Stopped plugin "TP-Link Devices 0.9.3"
Enabling plugin "TP-Link Devices 0.9.3"
Starting plugin "TP-Link Devices 0.9.3" (pid 3555)
TP-Link Devices Log level set to
Started plugin "TP-Link Devices 0.9.3"

Feb 21, 2021 at 11:50:56 AM
TP-Link Devices Error (plugin.py:getTpDevice:462): Discovery connection failed with ('NoneType' object has no attribute 'debug')

Posted on
Tue Feb 23, 2021 2:40 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

I will look into both of these bugs. Stay tuned..

If the older version does everything you need, there’s no urgent reason to upgrade.
The upgrade is all about the new sub-types.
I tried not to break anything, but obviously I missed something.

Posted on
Wed Feb 24, 2021 9:46 pm
mintzps offline
Posts: 26
Joined: Apr 13, 2010

Re: TP-Link Plugin v 0.9.3

Which older version of the plug-in should I use? I am committed to Big Sur and Indigo 7.5.

Posted on
Wed Feb 24, 2021 10:22 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

Which older version of the plug-in should I use? I am committed to Big Sur and Indigo 7.5.

My home server is still on High Sierra and 7.4, but that shouldn’t matter.
The previous release was 0.8.1. Revert to that. It’s been out and stable for over a year.

Posted on
Thu Mar 04, 2021 4:56 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.4

With the help of user James Holcomb, I fixed a number of bugs in the RelaySwitch Type, and added a lot more error checking, specifically to make sure the device type chosen by the user when creating a new device is the correct one for that device. [ Thanks, James! ]

When you click device status, it now prints more information in the log. It's easy to add more if that would be useful.

I also worked on the command line tool, and the README now explains the included Actions, among other improvements.

Posted on
Sun Mar 21, 2021 6:49 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: TP-Link Plugin v 0.9.5

A HUGE Thank you for this....I updated to 0.9.5 and installed 6 bulbs, 4 switches and one smart plug at mom's over spring beak The only issue I have run into I may play with when I have a bit of time is thatit looks like the barn's WIFI may have a bit of a link problem and occasionally drops for a few minutes... and when it does, the switches out there disable communication... since 9 times out of 10, we are are switching the lights out there from Touch rather than Indigo on a Mac, how hard would it be to let me create an action that would attempt to reenable communication that I could create and execute from touch, or better yet make a single attempt to reopen communication on a turn off/on command?

Posted on
Sun Mar 21, 2021 6:56 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

Thanks, John.

johnpolasek wrote:
... how hard would it be to let me create an action that would attempt to reenable communication that I could create and execute from touch, or better yet make a single attempt to reopen communication on a turn off/on command?

I assume it gets disabled after 10 unsuccessful polls, yes? Have you tried increasing the poll time?
I’ll look into creating a “re-enable” action, it doesn’t sound too hard. Not so sure about the auto-reenable on a turn on/off.

—John

Posted on
Mon Mar 22, 2021 6:55 am
johnpolasek offline
Posts: 911
Joined: Aug 05, 2011
Location: Aggieland, Texas

Re: TP-Link Plugin v 0.9.3

I am also assuming that it's due to a number of failed tries, although we were only noticing it when we try to turn something on or off and it fails to respond, but which time the actual disconnect is buried somewhere way back in the log. I didn't have a chance to roll back the log to the failure points or play with the access point much and am now 300 miles away till the next time I run home for Easter, but I'll try increasing the poll time since when we are out at the barn, we don't usually seen any visible indication that the wifi is down, but may be getting delayed App messages and slow safari response without noticing. That access point is 3 years old and survived a lightning strike that took out a camera and Ethernet over powerline module on the same circuit, so it may be time to replace it.

Posted on
Mon Mar 22, 2021 7:39 am
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

Here’s an alternate approach:
Instead of disabling all communication, how about it just slows the polling rate by a second after 5 fails, and another after 10, and so on - resetting to the configured value when it does get a reply?

What do you think?

— john

Posted on
Mon Apr 12, 2021 8:20 am
Alain offline
Posts: 88
Joined: Apr 19, 2008

Re: TP-Link Plugin v 0.9.3

Hi,
Will this plugin work with the KP-200 wall outlet?
Thanks
Alain

Posted on
Mon Apr 12, 2021 2:57 pm
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

Alain wrote:
Will this plugin work with the KP-200 wall outlet?

Yes. I don’t have one personally, but it is a known device type.
— John

Posted on
Fri Apr 16, 2021 8:49 pm
rhanson offline
Posts: 192
Joined: Apr 30, 2013

Re: TP-Link Plugin v 0.9.3

Looks like KP-115 isn't supported:

Code: Select all
   TP-Link Devices Error           (plugin.py:getSubType:120): model 'KP115' is not recognised
   TP-Link Devices Error           (plugin.py:getSubClass:134): deviceTypeId 'unknown' is not recognised
   TP-Link Devices Error           Error in plugin execution UiAction:

Traceback (most recent call last):
  File "plugin.py", line 524, in selectTpDevice
  File "plugin.py", line 322, in initializeDev
AttributeError: 'NoneType' object has no attribute 'initializeDev'

   TP-Link Devices Error           Error in plugin execution UiValidate:

Traceback (most recent call last):
  File "plugin.py", line 210, in validateDeviceConfigUi
  File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_relay_plugin.py", line 38, in validateDeviceConfigUi
KeyError: key deviceId not found in dict


It's a wall plug with energy monitoring, probably just a synonym for a bunch of others. :-)

Edit:

Yep, I added 2 and they work fine. Just added KP115 into the list, and it's all good.

I don't think the 8 characters is worth a pull request...


Posted on
Sat Apr 17, 2021 6:41 am
jtburgess offline
User avatar
Posts: 77
Joined: Jan 17, 2018
Location: NJ

Re: TP-Link Plugin v 0.9.3

rhanson wrote:
Looks like KP-115 isn't supported:

. . .

Yep, I added 2 and they work fine. Just added KP115 into the list, and it's all good.

I don't think the 8 characters is worth a pull request...


Yet another new model! They keep on coming.
So I assume you added ‘KP115’ to the list in the _relay_ module. yes?

Thanks! It’ll be in the next release, with other changes already in progress.

Who is online

Users browsing this forum: No registered users and 15 guests