TP-Link WiFi Switches

Forum rules

Questions about hardware that can be controlled by Indigo (but not through the interfaces and plugins listed). If Indigo doesn't support some bit of hardware you're interested in, and you don't find a 3rd Party Plugin for it, add it to this forum. Be sure to include links to as much information as you can find about it.

Note: adding it here does not mean we're going to add it - in fact it's possible one of our 3rd party developers may decide to write a plugin for it. We add hardware/features based on a lot of different factors beyond just having a request for it.

Posted on
Wed Jan 20, 2021 9:48 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: TP-Link WiFi Switches

I started getting an error in my log:
(tpl_polling.py:run:126): 2 consecutive polling error for device "Office Lights": TP-Link connection timeout

Seems to go away when I reload the plugin. Not sure what the cause is but it happened on5 or 6 different evenings.

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

Re: TP-Link WiFi Switches

pgershon wrote:
I started getting an error in my log:
(tpl_polling.py:run:126): 2 consecutive polling error for device "Office Lights": TP-Link connection timeout

Seems to go away when I reload the plugin. Not sure what the cause is but it happened on5 or 6 different evenings.

It really should be a warning, indicating a timeout waiting for a response. You’ll get a similar message after 5 consecutive errors and 8 consecutive errors before it finally gives up at 10. Then the message is
Code: Select all
Unable to poll device %s: %s after 10 attempts. Polling for this device will now shut down.
And then you really might want to restart.

If you never see that, you have nothing to worry about. The worst case is that it won’t record a state change as quickly.

Posted on
Tue Feb 02, 2021 1:15 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: TP-Link WiFi Switches

I was messing around with the plugin, looking to dim my lights through Indigo as well as turn them on/off. I figured I might come up with a quick hack while the plugin was expanded. I found the reverse engineering code for the Kasa line, and I modified "commands" in protocol.py to included dimmer references. Then I modified the devices.xml to allow the device to dim as well as go on/off. Finally I added logic to the plugin.py to react to dimmer commands:

Code: Select all
        elif action.deviceAction == indigo.kDimmerRelayAction.SetBrightness:
            cmd = "setBright"

Unfortunately, I get an error message:

TP-Link Device Error (plugin.py:actionControlDimmerRelay:319): send "new device" setBright failed with result "{"dimmer":{"err_code":-1,"err_msg":"module not support"}}"

I am not sure why the module thinks my HS220 is not supported - it should be per

Any ideas?

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

Re: TP-Link WiFi Switches

It’s not quite as simple as that. The bulbs use a much different JSON schema than plugs.
There is a beta available on my GitHub site that supports dimming.
Check it out : https://github.com/jtburgess/indigo-TP-LInk.
I’m waiting for confirmation that I didn’t break anything (like energy management) before I finalize an indigo release.

Let me know what you think.

Posted on
Tue Feb 02, 2021 5:00 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: TP-Link WiFi Switches

Thanks - I gave it a whirl. Unfortunately, I think I have a tweener. I have an HS220 dimming light switch - not a bulb. In essence, I believe, it's a relay with a dimmer. The old plugin worked fine with my HS220 except I had no capability to change the dimmer state - so if it were set to 50% with the iPhone app, Indigo could turn on/off at 50%. I believe your new code is for a bulb, which as you said, is a different JSON.

Here was my error log when I tried to set up a new device using the beta:

1) for dimmable bulb:

Feb 2, 2021 at 5:58:45 PM
TP-Link Devices Error (plugin.py:getSubType:115): model HS220 is not recognised
TP-Link Devices Error Error in plugin execution UiAction:

Traceback (most recent call last):
File "plugin.py", line 500, in selectTpDevice
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_dimmer_plugin.py", line 106, in selectTpDevice
KeyError: ('mic_mac',)

TP-Link Devices Error Error in plugin execution ServerReplacedElem:

Traceback (most recent call last):
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/IndigoPluginHost.app/Contents/Resources/PlugIns/plugin_base.py", line 1179, in deviceUpdated
File "plugin.py", line 219, in deviceStartComm
KeyError: key model not found in dict


2) for smartplug

TP-Link Devices Error (plugin.py:getSubType:115): model HS220 is not recognised
TP-Link Devices Error Error in plugin execution ServerReplacedElem:

Traceback (most recent call last):
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/IndigoPluginHost.app/Contents/Resources/PlugIns/plugin_base.py", line 1179, in deviceUpdated
File "plugin.py", line 225, in deviceStartComm
File "/Library/Application Support/Perceptive Automation/Indigo 7.5/Plugins/TP-Link-Device.indigoPlugin/Contents/Server Plugin/tplink_relay_plugin.py", line 51, in deviceStartComm
NameError: global name 'description' is not defined

This may help: https://python-kasa.readthedocs.io/en/latest/

Posted on
Tue Feb 02, 2021 6:05 pm
pgershon offline
Posts: 506
Joined: Jul 10, 2004

Re: TP-Link WiFi Switches

Found what I needed:

'setBright': '{"system": {"set_relay_state": {"state": 1}},"smartlife.iot.dimmer": {"set_brightness": {"brightness": 100}}}',

Will set brightness to 100. I can modify the brightness from there. Need to fix the device state reporting to, but at least I can dim and brighten lights now. Useful for when I wake up in middle of night and don't want to wake the puppy etc

Who is online

Users browsing this forum: No registered users and 1 guest

cron