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

to clarify, when you selected the Energy Monitor feature in preferences, you then ran Preferences?

Enable debug logging and run Preferences again. I need to see if the energy monitor setup is properly setting up.

Dave

Following is is the debug log after I clicked "Save Preferences". After I did this, I did turned on the space heater that I have plugged into the HS110; still no power reading. I checked the Kasa app and it is reporting 754 watts - so the plug is working and the draw is sufficient that the lack of a "power" reading in Hubitat shouldn't be due to a rounding or truncating issue.

dev:2592019-09-24 05:26:00.809 pm infoTP-Link 4.4.01 Energy is 0 kilowatt hours.
dev:2592019-09-24 05:26:00.788 pm debugTP-Link 4.4.01 setEngrToday: [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.177000]], err_code:0]]]
dev:2592019-09-24 05:26:00.672 pm debugTP-Link 4.4.01 sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setEngrToday
dev:2592019-09-24 05:26:00.669 pm infoTP-Link 4.4.01 Power is 0 Watts.
dev:2592019-09-24 05:26:00.664 pm debugTP-Link 4.4.01 powerResponse: cmdResponse = [emeter:[get_realtime:[current:0.135035, total:0.177000, err_code:0, power:1.854120, voltage:122.686317]]]
dev:2592019-09-24 05:26:00.540 pm debugTP-Link 4.4.01 sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerResponse
dev:2592019-09-24 05:26:00.534 pm debugTP-Link 4.4.01 getPower
dev:2592019-09-24 05:25:59.609 pm infoTP-Link 4.4.01 Last month's energy stats set to 0 // 0
dev:2592019-09-24 05:25:59.575 pm debugTP-Link 4.4.01 setThisMonth: energyScale = null, cmdResponse = [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.177000]], err_code:0]]]
dev:2592019-09-24 05:25:59.404 pm debugTP-Link 4.4.01 refreshResponse: status = [dev_name:Wi-Fi Smart Plug With Energy Monitoring, hw_ver:1.0, rssi:-59, latitude:42., err_code:0, type:IOT.SMARTPLUGSWITCH, deviceId:8006C6AD0B18DD184F25C95D49FFD628173504D6, mac:50:C7:BF:01:EE:E5, icon_hash:, active_mode:schedule, updating:0, led_off:0, on_time:164783, feature:TIM:ENE, relay_state:1, oemId:FFF22CFF774A0B89F7624BFC6F50D5DE, alias:TP-Link, model:HS110(US), hwId:60FF6B258734EA6880E186F8C96DDC61, fwId:00000000000000000000000000000000, sw_ver:1.2.5 Build 171206 Rel.085954, longitude:-83.]
dev:2592019-09-24 05:25:59.091 pm debugTP-Link 4.4.01 sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setLastMonth
dev:2592019-09-24 05:25:59.088 pm infoTP-Link 4.4.01 This month's energy stats set to 0.18 // 0.01
dev:2592019-09-24 05:25:59.072 pm debugTP-Link 4.4.01 setThisMonth: energyScale = null, cmdResponse = [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.177000]], err_code:0]]]
dev:2592019-09-24 05:25:58.998 pm debugTP-Link 4.4.01 sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 10.0.10.19, action = commandResponse
dev:2592019-09-24 05:25:58.996 pm debugTP-Link 4.4.01 refresh
dev:2592019-09-24 05:25:58.971 pm debugTP-Link 4.4.01 sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setThisMonth
dev:2592019-09-24 05:25:58.968 pm debugTP-Link 4.4.01 updateStats
dev:2592019-09-24 05:25:58.946 pm infoTP-Link 4.4.01 Scheduling nightly energy statistics update.
dev:2592019-09-24 05:25:58.945 pm infoTP-Link 4.4.01 ShortPoll set for 0
dev:2592019-09-24 05:25:58.942 pm infoTP-Link 4.4.01 Refresh set for every 15 minute(s).
dev:2592019-09-24 05:25:58.940 pm infoTP-Link 4.4.01 Description text logging is true.
dev:2592019-09-24 05:25:58.938 pm infoTP-Link 4.4.01 Debug logging is: true.
dev:2592019-09-24 05:25:58.891 pm infoTP-Link 4.4.01 Device IP set to 10.0.10.19
dev:2592019-09-24 05:25:58.847 pm infoUpdating ..

I just noticed in the logs that the 'power' variable is correct and does update when refreshed. So, it appears that the problem is that it is not updating in the "Current States".

dev:2592019-09-24 05:42:25.604 pm debug TP-Link 4.4.01 powerResponse: cmdResponse = [emeter:[get_realtime:[current:6.336879, total:0.238000, err_code:0, power:747.083222, voltage:118.206375]]]

New Update 4.5 now on GitHub. I am combining some driver files into single files. Update steps:

  • Update Application file with new file
  • Update relevant Driver files with new files
  • Start the logs page in Hubitat
  • In each device:
    1. Turn on debug logging in preferences
    1. Run "Save Preferences"
    1. Execute some of the command in the device, looking at attributes, etc.
    1. Review logs for ERRORS and WARNINGS for the device.
    1. Turn of debug logging and run Save Preferences.
  • After testing all, evaluate and provide anomalous data here.

Dave

1 Like

The new update should solve your problem.

Note: I do not have a HS110, so I combined the driver files with the HS300 multi-plug. That way, I am able to test all functionality except basic communications. I then tested as a HS-110 device (to a surrogate device) to validate that the code generates the expected commands.

Dave

I scanned this thread but didn't see this answer. I've done all the setup on the PDF and installed the HS200. It just blinks amber/green which I assume indicates it isn't sitting on my network. The App also doesn't find it, of course. Is there something I need to do to get the switch on my home wireless network other than powering it up? I've also done a basic and a factory reset on it. Moved it into the same room with my wireless router. No change. I'm sure I've missed something despite using the PDF instructions to install this. Do I have to use their app to install it initially? Guidance would be appreciated!

I had to use the Kasa app to install the devices. You can then go into your router settings and make their addresses fixed, so that if your router reboots they don't get a different IP address.

You must first install the device using the Kasa App. That app sets the device up on the network.

Edit. This process connects to the device on it's factory wifi address and connects it to your local wifi.

Thanks for the replies. I was afraid of that but thought it would be a step in the App Doc PDF if it was necessary. I was really hoping not to have yet another random App invading my phone data, even temporarily. And yes, I am one of those tin-foil-hat people. One reason I chose Hubitat to begin with.

I love tin-foil. After you set up the device, use my Kasa Tools to unbind the devices from the Kasa Cloud (then the cloud will no longer control the devices). You could also delete the Kasa phone application (you do not need it anymore). Just remember your password so you can re-install in case of problems (sometimes the devices reset to factory default).

I keep my Kasa app as a backup in-case the hub fails. I also keep it since I am continually developing/checking drivers.

2 Likes

After using the Kasa app on my Android, I go to the phone's system apps page and do a "force stop" on the app. It will not run again until I manually start it. This has the added benefit of reducing battery usage.

Need Volunteer for HS220 testing.

One item missing from the HS220 driver is the ability to set a transition on/off time to gently turn on and off the device. I am looking for a volunteer with a HS200 to test an implementation of a transition time for the dimmer. I will provide a link to test code and test instructions that will NOT impact your current installation.

Hi Dave,

Thanks for all of your work. I realize you have other things you could be doing with your time and I appreciate the donations of time and experience you've made to get the app and drivers developed not to mention the extra time to debug and support them.

I updated the app and the driver, deleted the existing device, and installed a new device using the app. Unfortunately, I'm still having trouble with the power state updating even though the pwrResponse returns an energy value. Any thoughts?

Logs follow:

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.333 am [info](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** Power is 0 Watts.

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.325 am [debug](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** powerResponse: cmdResponse = [emeter:[get_realtime:[current:0.137164, total:0.473000, err_code:0, power:1.837040, voltage:123.339750]]]

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.220 am [debug](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerResponse

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.218 am [info](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** Power: on

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.214 am [debug](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** refreshResponse: status = [dev_name:Wi-Fi Smart Plug With Energy Monitoring, hw_ver:1.0, rssi:-65, latitude:42., err_code:0, type:IOT.SMARTPLUGSWITCH, deviceId:8006C6AD0B18DD184F25C95D49FFD628173504D6, mac:50:C7:BF:01:EE:E5, icon_hash:, active_mode:schedule, updating:0, led_off:0, on_time:259, feature:TIM:ENE, relay_state:1, oemId:FFF22CFF774A0B89F7624BFC6F50D5DE, alias:energy plug, model:HS110(US), hwId:60FF6B258734EA6880E186F8C96DDC61, fwId:00000000000000000000000000000000, sw_ver:1.2.5 Build 171206 Rel.085954, longitude:-83.]

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.096 am [debug](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 10.0.10.19, action = commandResponse

[dev:263](http://10.0.10.220/logs/past#dev263)2019-09-30 11:24:37.090 am [debug](http://10.0.10.220/device/edit/263) **energy plug 4.5.01** refresh

Thank you!

1 Like

Jason,
Thanks for reporting the error. I have updated the driver. The url for either copy or import is:

https://raw.githubusercontent.com/DaveGut/Hubitat-TP-Link-Integration/master/DeviceDrivers/TP-LinkEM-Plug(Hubitat).groovy

Please report on failure or success.

Dave

Dave,

I'm happy to report a success - it works exactly as designed! Thanks for your hard work!

Jason

Thanks for the updates. I've just updated and it's all working well. I like the bolding in the logs as well, and you can be sure that I'll be utilising that little gem. I've not seen it in any logs before.

Is it possible to get the retry count increased to at least 5? With some of the most recent updates, I've started to get the setCommsError: Parent commanded to poll for devices to correct error. warning, which results in a flood of warning messages as the parent app searches for devices. The previous retry limit of 5 seemed to work a majority of the time.

Another option would be to make the retry count a configurable option.

Updated to allow 6 retries. I also increased the command time-out. I am interested in the TP-Link devices you have installed. Can you provide
Device Type (i.e., HS100)
Number of each device type
Devices you are seeing commands repeated.

Dave

I have 4 HS105s and 1 HS300. I looked through my logs, and it looks like every single one of them has had to retry connections at least once in the past 1-2 days. The HS300 has to retry far more frequently (and each occurrence requires more retries before success) than the HS105s.

1 Like

let me know if the update works.