[DEPRECATED] Kasa Plug, Switch, and Bulb integration

It is likely an early version of the same device. Kasa apparently rebranded the device after an initial release. If you are interested in integrating with Hubitat, the Dimming Switch driver should work for basic functions (on/off/dim level). And I could work with you to get motion and ambient light values out as well as the smart tap function (a built in button interface?). (PS - the KS220M product is no longer available on Amazon nor the tp-link.com website.)

Yeah, my guess as well. I'll reach out once I get them installed to check with you about integrations.

@djgutheinz First, thanks so much for the Kasa integration, it's been a life saver this year with the shortage of supply on ZWave & Zigbee multi-plugs with power monitoring.

Anyhoo, After upgrading to the newest driver set one of my Kasa EM multi plugs has started throwing exceptions frequently:

This seems to be from this code line, where it appears to be looking for "preferred" but doesn't find it so returns -1 (-2 == -3 reported in the exception):

295:		clearResp = clearResp.substring(0,clearResp.indexOf("preferred")-2) + "}}}" // library marker davegut.kasaCommunications, line 51

Do you have a suggestion for a workaround ? Thanks much.

One of the limitations of the Hubitat UDP implementation is that it is limited to a single return packet. For the HS300 (6-outlet) multiplug, the return message can (often does) exceed this. This is solved by limiting the name lengths of the device and/or editing the return to create a psuedo-good retrun (which is what this section does).

Work-around. Limit the name lengths as stated below from the instructions. Try this and see if it solves the problem. Reply if not.

My fix: Modify the code to throw a warning telling the user the corrective action.

From instructions: For the HS300 6-outlet multi-plug, the Kasa names for ALL of the outlets must not exceed 96 characters (about 16 characters per outlet). This is due to Hubitat comms limitation of a single return packet from the device. This limitation does not exist if you choose a cloud implementation.

I recently got a plug, and both in the Kasa app and via the local integration (Hubitat), I found the state did not change when I pressed the button. Therefore, I cannot use it to instantly trigger automations. Is this the case with the switch (if so, I will avoid buying Kasa switches).

You can change the polling rate of the device so it will detect the button press faster. "instant" might be a tall ask but you can usually get it within 3-5 seconds.

This also increases the load of the hub, right? Iā€™d rather stay away in that case.

It is minimal hub load and if used on only a few devices your hub will not fail. On a HS200, once per minute is .02 percent of hub load and about .15 percent at 5 second.

Dave

1 Like

Sorry, I must not have clarified. I would rather stay away due to the delay (3-5 secs is too long from when you enter the room considering there are so many instantaneous alternatives). I was also curious about the load of such polling for my current plug.

1 Like

@djgutheinz Thanks for the guidance. I'm suspecting there may be two limits.

The total length of names used in the HS300 was 72, which is under the 96 characters you mentioned.

OTOH only one plug was generating the exception, and that had a very long name (18 characters). I changed just that plug's name to under 16 characters and the problem appears to have gone away. So, there could be a per-plug-name limit also.

Best,

Rob

1 Like

Thanks. I will check my character count. The 96 was based on my older HS300 and the message base message may have grown in length (reducing the number of allowed characters). Very HELPFUL.

1 Like

Are these devices still connected to wifi?

Hi,

I tried adding 2 new devices Kasa app -> Add device

That action takes a little bit to run so I navigated away and ended up coming back to that screen several minutes later. I had 2 new devices to add so I checked them both and hit 'next' but got an error.

Now I can't get back into the Kasa app screen - I always get the same error message

app:3742021-12-06 03:50:33.623 pm errorjava.lang.NullPointerException: Cannot get property 'value' on null object on line 629 (method startPage)

edit: I found this post which sounds a lot like what I tried to do.. [RELEASE] TP-Link/Kasa Plug, Switch, and Bulb integration - #62 by xxgbhxx

Update your app to the latest. In HPM, do a repair or manually replace the code

FWIW - I was able to get the app to work by adding "?"'s to this line:

		//	See if any installing devices are IP = CLOUD. 
		//	If so, set useKasaCloud to true so device can be controlled.
		if (device?.value?.ip == "CLOUD") {
			app?.updateSetting("useKasaCloud", true)
		}

update: I just noticed your reply and I'll check if I have the latest and update if not

Hmm.. HPM says I have the latest version already

Kasa Plugs, Switches and Bulbs Documentation | Community Thread 
Kasa Integration v6.4.3 (app)
Dimming Switch (HS220) v6.4.3 (driver)
EM Plug (HS110) v6.4.3 (driver)
Multi Plug (HS107, KP200/303/400) v6.4.3 (driver)
Plug Switch (HS100/103/105/200/210, KP100) v6.4.3 (driver)

Just update, please, using a repair. I did a mx release in one hour after the update.

It is something I will never do again.

ok, thanks I'll do that

Hello, Which ports and protocols are used for the communications between TP-Link devices and Hubitat. Please also indicate the directionality or from which side the connections are initiated.

My TP-Link devices are on a separate subnet from my Hubitat C-7 so I must setup port forwarding.

Thx

Update:

TP-link device port: 9999
Protocol: UDP
Hubitat Port: I do not know (this is not visable in the normal Hubitat Implementation.

1 Like