[RELEASE] TP-Link Plug, Switch, and Bulb integration


Um, the difference I was finding in the instructions vs. code was:

HS110 TP-Link Plug-Switch (Hubitat).groovy

tpLinkModel << ["HS110" : "TP-Link Engr Mon Plug"]

Not necessarily the Hubitat vs. SmartThings designation (which I would have loved to have known about this app when I was using SmartThings as my primary..) Thank you!


Instructions had an error. Just corrected to HS110: TP-Link Engr Mon Plug (Hubitat).groovy

I added the energy monitor plug later since the UDP version of the driver had some problems with the energy monitor status return (message length). I did a work-around.




Does this look right for the app?


Yes. It says that there are no new devices to add to the system (none were detected).



Yeah I have been experiencing TP-Link communication failures a lot over the past 2-3 weeks and Hub slow downs. Not sure what is contributing to all of this so I began investigating. Since I cannot force the IP address of the devices anymore I am unsure if the app works 100% of the time. We have had outages for internet in the past 2-3 weeks but that shouldn't cause issues...at least I hope not. :slight_smile: Anyways, the COMMs errors I am experiencing seem to go away after a hub reboot and not with a wait of 5-30 minutes. At least no after initializing the app in HE.

My setup:

  • all TP-Link devices have reserved IP addresses
  • all TP-Link devices can be controlled remotely through Kasa App if needed
  • I am the only one who has the Kasa app and access to the lights outside of HE
  • I have refresh on all devices set to 5 minutes



Do you have logs from when you run the discovery?


I see no errors...the DNI is updating when the app runs and every so often. But when the hub slowness is experienced I do not see any new logs from TP-Link. Hence my suspicions.


Comms Errors. Comms errors are automatically generated when a device does not respond to a command within 2 seconds. Do not know why these are occurring. The comms are relatively straignt forward. Several possibilities:

  • The UPD polling is interfering (see below fix and fixed in later versions).
  • A device is itself powered-off.

Some design notes that may help. See below. You are using an older version of the integration (Newer does not have auto polling.) DO NOT UPGRADE. I am working on an update for this month that will include a Application method to update (will automatically update data structures to latest version.) I apologize for these changes, but the UDP has been a learning curve.

Fixes based on App Version at top of file.
def appVersion() { return "4.0.01" }

  • Go to method initialize() and comment out the line "runEvery30Minutes(discoverDevices)"
  • run the application.

def appVersion() { return "4.0.05" }
Go to the method checkIp and comment out the instructions so the code looks like:
def checkIp() {
// if (state.allowDiscovery == false) { return }
// state.allowDiscovery = false
// runIn(600, resetAllowDiscovery)
// discoverDevices()

  • run the application.

Design Notes: The original integration was designed to automatically poll for devices if there was a comms error. This was throttled to a maximum of once every 5 minutes.
Errors are automatically created when the device does not respond within 2 seconds.
A common cause of a never-ending loop is to have a device powered off (unplugged, switch off). This will drive an every 5 minute polling.

Next version out this month. The next version will address this issue by eliminating the automatic polling function. The comms error message will indicate that the corrective action is to run the Application. The new version will also contain a user-selected method to UPDATE from previous version. This method will update the data elements so the upgrade will work. My plan is to test/validate against all hubitat versions; including the old cloud and hub based integrations.



I am on version 4.1.01. The above doesn't seem to follow with the code I have installed. :frowning:


@djgutheinz I changed from 2 to 5 seconds as you requested. Any update on your progress?


Update to version 4.2: The drivers and application have been updated to version 4.2. Changes

  • Application only does device search when run manually. (Note: If an IP address changes, the user runs the app to update. To preclude this, set your IP addresses to STATIC in your wifi router.)
  • Application automatically updates the device data for older versions, assuring upgrade is as smooth as possible. You must run the application during the upgrade process.
  • Bulbs now support capability "change level". This allows pressing an up/down button then stopping to gradually change the bulb brightness.
  • All devices added a user command to synchronize the Kasa App device name with the set Hubitat label.
  • Cleaned up error messages for comms error with explicit recommendations to resolve.

Compatibility. When installed per the instructions, the upgrade will work when upgrading from any earlier Hubitat version.

Upgrade: You MUST follow the upgrade instructions in the README.md file on the main GitHub page.

  • The new drivers are not compatible with version 3.x and earlier Application (and no guaranteed with version 4.0 / 4.1).
  • The new Application must be run to update the device data to assure that earlier versions run.

Upgrade instructions

  1. Replace the contents of the existing driver and application.
  2. Run the application (this will update the required data elements.
  3. Test a sampling of devices.


Updated and all my comms errors have disappeared AND hub has gained in speed. Much appreciated!


Hi, Dave. Would you please look at this and tell me what I'm doing wrong?

Every five minutes:

And if I hit the on or off from the device:

Thanks for your time and talents.

EDIT: With trace logging:


Just upgraded? What I am seeing indicates you may not have followed the upgrade instructions (on gitHub readme.md shown on main page):

  1. Replace the contents of the existing driver and application.
  2. Run the application (this will update the required data elements.
  3. Test a sampling of devices.

What I need to know to continue:

  • Version upgraded from (best of your recollection). I assume it is 3.x or earlier from the checkError running every 5 minutes (used on old version in the Smart App.
  • Confirmation you upgraded both the Application and Drivers per the instructions above.
  • Did you run the Application at least once?


Appreciate the help. I'll try to answer as best I can. I don't know the previous version, but here's what I have now.


I've tried running the app, but it doesn't find any devices. I checked via the official Kasa app and it does see and correctly control, including status, the device. Interestingly, using your DH, the on/off functionality works, but it does not correctly see the status.

Please advise. Thank you!


So... Never mind. :japanese_ogre:

I realized I was using the wrong driver. The plug is an HS105 and the right driver is the Plug Switch but I was using the Multi Plug. It's working just fine, now.

Although, I still don't know why the app doesn't see the device.


Glad you are up and running. Mistakes are allowed!

The app will not see the device since it is already installed. Although not required, I use the method of only displaying devices that are not already children. Makes the interface make more sense (to this old man).



Hello Dave,
I have two HS110 plugs and both of them are showing this error log.
2019-03-18 08:53:37.336 pm [error] java.lang.NullPointerException: Cannot get property 'get_monthstat' on null object on line 183 (energyThisMonthResponse)
Living 4.2.01 LED Living: Power is 0 Watts.
Living 4.2.01 LED Living: Power: off
Apps and drivers are on V4.2 Thanks!


Hey @djgutheinz,
FYI, like @KVHubitat, I'm seeing this error using a HS110 with both App and Driver (TP-Link Engr Mon Plug) on v4.2.01, however it's being listed as line 207 in the log but it's otherwise functioning well...

dev:9302019-03-19 07:49:34.225 pm errorjava.lang.NullPointerException: Cannot get property 'get_monthstat' on null object on line 207 (energyThisMonthResponse)

dev:9302019-03-19 07:49:34.081 pm infoTP-Link Outlet #1 4.2.01 TP-Link Outlet #1: Power is 0 Watts.

dev:9302019-03-19 07:49:33.967 pm infoTP-Link Outlet #1 4.2.01 TP-Link Outlet #1: Power: on

dev:9302019-03-19 07:49:19.925 pm errorjava.lang.NullPointerException: Cannot get property 'get_monthstat' on null object on line 207 (energyThisMonthResponse)

dev:9302019-03-19 07:49:19.824 pm infoTP-Link Outlet #1 4.2.01 TP-Link Outlet #1: Power is 5.809 Watts.

dev:9302019-03-19 07:49:19.708 pm infoTP-Link Outlet #1 4.2.01 TP-Link Outlet #1: Power: off



Fixed and uploaded. NEED your response on if it works (do not need logs if it works). I do not have a HS110.

I believe I found and corrected the error. I used the incorrect preamble for the return data in two places (used bulb preamble vice plug).