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

All you had to do was replace the code then run the app preferences. It would not find the device since it is already installed.

However, you must replace the code.

1 Like

It actually works. I just had one of my devices not respond to an "on" command. It auto repeated the command once and recovered. The delay was perceivable very short!

2 Likes

thanks so much - seems to be working really well now!
appreciate your hard work

1 Like

New Tools Application - Kasa Tools
I have created a new Hubitat Application, Kasa Tools, that supports some nice-to-have device control capabilities:

  • Unbind: Allows you to convert the device to "local only" control. This feature is no longer available in the Kasa app.
  • Bind: Allows you to turn off "local only" control. Also available in the Kasa App.
  • Reboot: Reboot an individual device. For use if all else fails.
1 Like

we just need to update the "app" from github ?

No, it is purposely a different app. You will need the IP address of the device. It is separate for now to see how it is received.

1 Like

excellent, apologies - im quite slow.

Slow is a 71 year old who never programmed until he was 68.

5 Likes

kudos to you sir!
I've found the app on your github, i'll give it a go tonight!

Hi Dave,

Nice work on the driver, I have bought two HS110 plugs and was easily able to add them to hubitat. I was iterested in seeing an attribute showing the current power usage, knowing that it would only be updated at best every minute. I wanted to use this on my dashboard and potentially in rules down the track. Should there be an attribute for this? If not, would it be hard to add?

Thanks,
Simon

2 Likes

Go to the preferences section and enable the energy monitor functions. (emEnable). Save and that should kick-start the em functionality.

Thanks for the tip. I can only see stats for the current month and last month. I was hoping to see a current power usage level, similar to what the Kasa App shows. For example to use to determine when an appliance might be in use or finished a particular activity. Is that something that you can get from the device?

You should be getting current power and today's usage. Try refreshing several times. If you are not, turn on debug logging and press refresh. Then post here.

Here's two refreshes with the debug logging turned on

dev:1952019-09-01 01:19:28.144 debugBedroom Dehumidifier 4.3.04 refreshResponse: status = [dev_name:Smart Wi-Fi Plug With Energy Monitoring, hw_ver:2.0, rssi:-53, latitude_i:-327264, err_code:0, type:IOT.SMARTPLUGSWITCH, longitude_i:1521544, deviceId:8006341C3495231B8C3137878E5DB1601B20DE44, mac:D8:0D:17:CE:4D:F3, active_mode:none, icon_hash:, updating:0, led_off:0, on_time:40864, feature:TIM:ENE, relay_state:1, next_action:[type:-1], alias:Bedroom Dehumidifier, oemId:6480C2101948463DC65D7009CAECDECC, model:HS110(AU), hwId:A28C8BB92AFCB6CAFB83A8C00145F7E2, fwId:00000000000000000000000000000000, sw_ver:1.5.5 Build 181225 Rel.102720]

dev:1952019-09-01 01:19:28.022 debugBedroom Dehumidifier 4.3.04 sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 192.168.0.13, action = commandResponse

dev:1952019-09-01 01:19:28.019 debugBedroom Dehumidifier 4.3.04 refresh

dev:1952019-09-01 01:18:40.312 debugBedroom Dehumidifier 4.3.04 refreshResponse: status = [dev_name:Smart Wi-Fi Plug With Energy Monitoring, hw_ver:2.0, rssi:-55, latitude_i:-327264, err_code:0, type:IOT.SMARTPLUGSWITCH, longitude_i:1521544, deviceId:8006341C3495231B8C3137878E5DB1601B20DE44, mac:D8:0D:17:CE:4D:F3, active_mode:none, icon_hash:, updating:0, led_off:0, on_time:40817, feature:TIM:ENE, relay_state:1, next_action:[type:-1], alias:Bedroom Dehumidifier, oemId:6480C2101948463DC65D7009CAECDECC, model:HS110(AU), hwId:A28C8BB92AFCB6CAFB83A8C00145F7E2, fwId:00000000000000000000000000000000, sw_ver:1.5.5 Build 181225 Rel.102720]

dev:1952019-09-01 01:18:40.267 debugBedroom Dehumidifier 4.3.04 sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 192.168.0.13, action = commandResponse

dev:1952019-09-01 01:18:40.265 debugBedroom Dehumidifier 4.3.04 refresh

just realised you might be more interested in this, from the logs for the second plug

dev:1962019-09-01 01:27:32.467 infoKitchen Dehumidifier 4.3.04 Hubit name for device changed to Kitchen Dehumidifier.

dev:1962019-09-01 01:27:32.421 errorjava.lang.ArithmeticException: Division by zero on line 244 (setThisMonth)

dev:1962019-09-01 01:27:32.411 infoKitchen Dehumidifier 4.3.04 Refresh set for every 1 minute(s).

dev:1962019-09-01 01:27:32.400 debugKitchen Dehumidifier 4.3.04 setThisMonth: energyScale = null, cmdResponse = [emeter:[get_monthstat:[month_list:[[month:8, year:2019, energy_wh:4428], [month:9, year:2019, energy_wh:172]], err_code:0]]]

dev:1962019-09-01 01:27:32.391 debugKitchen Dehumidifier 4.3.04 setRefreshInterval: interval = 1

dev:1962019-09-01 01:27:32.357 debugKitchen Dehumidifier 4.3.04 sendCmd: command = {"system":{"get_sysinfo":{}}} // device IP = 192.168.0.16, action = nameSyncDevice

dev:1962019-09-01 01:27:32.354 debugKitchen Dehumidifier 4.3.04 syncName. Synchronizing device name and label with master = device

dev:1962019-09-01 01:27:32.343 debugKitchen Dehumidifier 4.3.04 sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 192.168.0.16, action = setThisMonth

dev:1962019-09-01 01:27:32.340 debugKitchen Dehumidifier 4.3.04 updateStats

dev:1962019-09-01 01:27:32.337 infoKitchen Dehumidifier 4.3.04 Scheduling nightly energy statistics update.

dev:1962019-09-01 01:27:32.335 infoKitchen Dehumidifier 4.3.04 Description text logging is true.

dev:1962019-09-01 01:27:32.332 infoKitchen Dehumidifier 4.3.04 Debug logging is: true.

dev:1962019-09-01 01:27:32.312 infoUpdating .

Thanks for discovering this error. The driver has been updated. To install,

  • go to the Driver Code tab
  • select the existing driver
  • replace the driver with the code at the below location
  • go to Devices then the device
  • run Save Preferences.

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

Check out and reply to me either way (working or not). IF not working. I will need the same logs again.

Dave

1 Like

Bingo!! I now have the power reading. Thanks Dave.

1 Like

Current power reading is working for me now as well with the same model of plug. Thank you.

1 Like

Hi Dave,

I appreciate the driver - I'm glad I can use my existing HS110 on my new Hubitat.

I, too, am having trouble getting a real-time power reading. I am, and have been, using the most current version of the driver (v 4.4.01). I've also tried toggling the "Enable energy monitory features" switch several times, refreshing several times, and reinstalling the device a couple times. Everything else seems to work. Any ideas?

FWIW, here are debug logs:

[ev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:15.003 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Power is 0 Watts.

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:15.000 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** powerResponse: cmdResponse = [emeter:[get_realtime:[current:0.131451, total:0.089000, err_code:0, power:1.823785, voltage:119.845363]]]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:14.902 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:14.896 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** getPower

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:14.217 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:13.796 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** refreshResponse: status = [dev_name:Wi-Fi Smart Plug With Energy Monitoring, hw_ver:1.0, rssi:-62, latitude:42.2, 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:1214, 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.773485]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:13.689 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 10.0.10.19, action = commandResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:13.685 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** refresh

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:13.027 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:11.722 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:10.564 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:09.378 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:08.224 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:07.097 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:05.949 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:04.775 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:03.597 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:02.427 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:01.271 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:39:00.124 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:58.979 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:57.007 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:53.678 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:52.404 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:51.295 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** setEngrToday: [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.089000]], err_code:0]]]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:51.146 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setEngrToday

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:51.143 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Power is 0 Watts.

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:51.111 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** powerResponse: cmdResponse = [emeter:[get_realtime:[current:0.131294, total:0.089000, err_code:0, power:1.819564, voltage:119.880405]]]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:50.506 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:50.497 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** getPower

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:50.483 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_realtime":{}}} // device IP = 10.0.10.19, action = powerPollResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:48.063 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Last month's energy stats set to 0 // 0

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:48.038 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** setThisMonth: energyScale = null, cmdResponse = [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.089000]], err_code:0]]]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.757 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** refreshResponse: status = [dev_name:Wi-Fi Smart Plug With Energy Monitoring, hw_ver:1.0, rssi:-63, latitude:42.2, 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:1188, 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.773485]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.627 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setLastMonth

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.624 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** This month's energy stats set to 0.09 // 0

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.611 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** setThisMonth: energyScale = null, cmdResponse = [emeter:[get_monthstat:[month_list:[[month:9, year:2019, energy:0.089000]], err_code:0]]]

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.541 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"system" :{"get_sysinfo" :{}}} // device IP = 10.0.10.19, action = commandResponse

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.538 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** refresh

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.513 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** sendCmd: command = {"emeter":{"get_monthstat":{"year": 2019}}} // device IP = 10.0.10.19, action = setThisMonth

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.510 pm [debug](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** updateStats

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.481 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Scheduling nightly energy statistics update.

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.466 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** ShortPoll set for 1

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.464 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Refresh set for every 15 minute(s).

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.462 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Description text logging is true.

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.460 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Debug logging is: true.

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.429 pm [info](http://10.0.10.220/device/edit/259) **TP-Link 4.4.01** Device IP set to 10.0.10.19

[dev:259](http://10.0.10.220/logs/past#dev259)2019-09-22 07:38:47.368 pm [info](http://10.0.10.220/device/edit/259)Updating ..

I will look into the problem.