TP-Link Kasa Edge Driver (also LIFX)

Power monitoring and energy consumption is now supported for energy capable devices. To prevent event spam, events will only be emitted when there is a 1W or 1Wh delta. Energy consumption is taken directly from the value provided by the device. I’m not sure if this value increments indefinitely or auto resets after a number of days. The resetEnergyMeter command is not yet implemented, I may move to calculating consumption directly in the driver and implement the reset in a future update.

I created a new beta channel with these changes. I will merge into the release channel after a week or so of run time. The invite to the beta channel is here: https://bestow-regional.api.smartthings.com/invite/VD2Nra5KoL25

Both the release and beta drivers can run simultaneously on the hub and driver switching via the app works nicely. However, I strongly recommend against running both drivers long term. Since discovery is done locally within the driver and both drivers will attempt discovery at the same time, there is no guarantee which driver a new device will pair to.

@Paul_Oliver - This change should fix your KP115

1 Like

The best way to request new feature/device support, or to fix a currently supported but broken one, is by sending me a dump of the decrypted responses from the device. Currently only available in the beta driver (but will me merged into the release channel in the coming weeks), there is a TRACE log entry that dumps out the decrypted payload of a responding device. Example:

2022-09-04T16:42:10.454133831+00:00 TRACE TP-Link Beta  Decrypted response: {"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.6 Build 200727 Rel.121701","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(US)","mac":"50:C7:BF:02:AA:19","deviceId":"8006B4E136D2349A8D812AC824BFB26A174BA561","hwId":"60FF6B258734EA6880E186F8C96DDC61","fwId":"00000000000000000000000000000000","oemId":"FFF22CFF774A0B89F7624BFC6F50D5DE","alias":"Old ENE","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":1,"on_time":7156,"active_mode":"schedule","feature":"TIM:ENE","updating":0,"rssi":-70,"led_off":0,"latitude":45.012401,"longitude":-93.240804}},"emeter":{"get_realtime":{"current":0.293142,"voltage":118.004241,"power":21.390760,"total":0.043000,"err_code":0}}}

This can be viewed by running the smartthings edge:drivers:logcat command. If you send me that log output when a device responds during discovery, I can look to see if any new features are needed to support that device.

1 Like

I just installed your beta TP-LINK driver and power monitoring is working on my KP115.

Thanks again for sharing and debugging the TP-LINK driver.

Do you have a list of supported TP Link devices?

So I enrolled and installed the driver, did a scan, and instantly all my Kasa switches showed up - 3x HS200, 3x HS220, and 2x HS210. I didn’t even remove the TP-Link|Kasa Smart linked service. They function, though they’re surprisingly slow, particularly when controlled through the app. In routines they seem about the same speed as the cloud connection with TP-link (which I still have linked), although sometimes they take a noticeably longer time to respond (when interacted with multiple times in quick succession).

Is anyone else encountering a big delay (2-3 seconds) when controlling the devices running on the edge driver? By comparison, the TP-Link cloud integration is almost as instant as using the Kasa app.

1 Like

I was able to get the driver to pick up the LiFX bulbs after a reboot. All is well. Thank you for your work, its nice to have local LiFX control!

I ran the logcat command and here is a log I extracted.
Basically I just started the logging, went to the app and toggled one light on and off a few times:

As a test, since I don’t want to lose all 8 devices (some are parts of automations), I removed one of my HS220 switches so that there isn’t a “duplicate” (from the TP link service and edge driver). Still, the delay is about 1.5-2s, sometimes 3s even. It’s certainly inconsistent.

I am not seeing any delays. The 2 Kasa plugs I have seem to operates almost instantaneously.

1 Like

That’s fantastic, hopefully I can get my switches operating like that too. Did you remove the TP-Link | Kasa Smart linked service in SmartThings?

No, I have not removed the TP-Link Kasa Smart linked service in SmartThings. So I currently have duplicate devices. Once I am confident the Edge link is reliable, I will remove the c2c link.

1 Like

@pavichokche - Thanks for sending logs. I see two commands come through, ~2s apart, with a round trip time of ~100-200ms. This RTT is from the driver receiving the command to emitting a state change event. So the driver itself is handling the command pretty quickly. Do you know how many other drivers are currently running on your hub? The bottleneck may be the hub relaying commands to the driver. Or could certainly be somewhere between mobile → cloud → hub. May need some ST engineers to help dig into this one further.

I have 10 drivers installed on my hub currently (two of those are your original and beta drivers). I have 6 currently connected and functioning zigbee devices using custom edge drivers (from other developers’ channels, no official ones).
After installing your driver, I also onboarded my 8 kasa switches as edge driver devices, bringing the total to 14.
Watching the log as I interact with the device in the app, it seems like the delay happens before the log registers the received command. That could explain why the delay always felt a bit lesser when actions were triggered by a locally-executed routine (and not by the cloud-based app).
Still, that inconsistency in the delay is very noticeable. Sometimes it’s close to instant and sometimes there is a big delay.
Is it normal for the log to (almost) constantly be posting messages?

I have notice the delay when itrigger on the app from the first time (since the last time) so if I trigger again 8t will be fast , like a sleeping device

Yes of course, I’ve noticed that a lot with zigbee devices. This delay is very random and it keeps happening as i keep turning the same device on and off.

Thank you, I have 2x kasa HS110 and thought I’d let you know they’re working perfectly in the beta with power consumption! Thanks

3 Likes

I have your Beta driver working with the HS105, KP115, & KP125 (same as EP25). Power monitoring is working with both the KP115 & KP125.

Thanks again.

2 Likes

did i not install correctly or is there integration for the dimming function of the hs220? my devices are recognized but do not show dimming in the ST app.

For me, one of my three HS220 switches properly shows the dimmer slider. The others show a cloud. I think I had a routine adjust its level and afterwards the slider appeared and stuck around. Maybe try that?
Also, how is your speed of response between turning the switch on/off in the SmartThings app and it actually turning on/off, compared to the regular TP Kasa link service integration?

Does the tplink tapo outlet have support ?