[OBSOLETE] [Deprecated] New TP-Link/Kasa Plug, Switch, and Bulb Integration

Resolved. See post two below titled: " Updated device handler to correct."

Need some information.

a. Log into the IDE.
b. go to “My Locations” and select your location
c. near the bottom is "Installed SmartApps: List SmartApps. Select this.
d. at bottom is Other. Select “TP-Link SmartThings Manager”
e. Under “Application State”, I need the data in the devices cell.

Here is the data under Application State:
{50C7BF03F275={alias=Audrey’s Bed Side Lamp, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=8006A7B2BDDF29197AD33AF077B509241755B877, deviceModel=HS110, deviceNetworkId=50C7BF03F275, plugId=}, 50C7BF082537={alias=Living Room Lamp, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=800690705F9DA02D59862C72622D972517824D93, deviceModel=HS100, deviceNetworkId=50C7BF082537, plugId=}, 50C7BF09F307={alias=Family Room Lamp, appServerUrl=https://use1-wap.tplinkcloud.com, deviceIP=, deviceId=800695475ECDDEA4CFD1333BDFD3000A175F5061, deviceModel=HS100, deviceNetworkId=50C7BF09F307, plugId=}}

This didn’t fix my problem, still no energy monitoring as shown in the screenshot that I posted.

When I set this up, I set it up with two HS110s that I had just added to Kasa a few minutes prior. When I added them to Smartthings, one of the two plugs went offline with a blinking orange light and I haven’t been able to get it back since. I just deleted it from Smartthings and Kasa. I’ll try and re-add it later.

I really appreciate your work on this. Both in coming up with this to begin with and in troubleshooting. While looking around at things, I noticed these errors in the Job History. I don’t know if they’re related.

Thank you for looking into this! Audrey’s lamp does work, which why the whole thing is weird. Here’s what I see, which I believe is all listed correctly:

and the second will be in another post since I’m a “new user”

(Hopefully the photos come across, trying to do this over the phone)

Here’s the additional photo to verify published

My mistake. Copied wrong file over. TRY AGAIN and please forgive me.

Device going offline. Nothing in my code should cause this. If it persists, tell me and I will revisit the code design for a potential error.
dave

I do not see the HS 100 driver in your device handler page. May just be a copy error on the page you inserted, but please verify that “davegut: TP-Linkk Smart Plug” is published.

I believe I am missing that!! I will go back to the installation PDF and see how to add that. I’m sorry I wasted your time on my personal error.

My hs110 is having the same problem of not being able to see any energy use, even after following the above instructions.

9f552d01-d698-4027-96aa-172bd38eda57  1:30:24 PM: error Prusa i3 MK3: Sending Command Exception: java.lang.NullPointerException: Cannot get property 'get_realtime' on null object. Communications error with device.
9f552d01-d698-4027-96aa-172bd38eda57  1:30:15 PM: error Prusa i3 MK3: Sending Command Exception: java.lang.NullPointerException: Cannot get property 'get_daystat' on null object. Communications error with device.
76a893de-c6c2-4101-8ce6-fcdc189e9f2d  1:30:15 PM: debug getChildDevices(false), children=0
76a893de-c6c2-4101-8ce6-fcdc189e9f2d  1:30:15 PM: trace Refreshing all devices
76a893de-c6c2-4101-8ce6-fcdc189e9f2d  1:30:15 PM: trace Checking for next app update after Sun Mar 10 2019 12:00 CDT
b898635a-37db-4339-b0d8-71444f0cb6c5  1:30:12 PM: trace Pending actions: [1E:null]
0934569f-666f-4335-921b-e38af5292a7b  1:30:11 PM: info No errors detected.
9f552d01-d698-4027-96aa-172bd38eda57  1:30:09 PM: error Prusa i3 MK3: Sending Command Exception: java.lang.NullPointerException: Cannot get property 'get_realtime' on null object. Communications error with device.
9f552d01-d698-4027-96aa-172bd38eda57  1:30:07 PM: info Prusa i3 MK3: Power: on

That didn’t do it either. Still no energy info.

Sorry, I didn’t mean to imply that your stuff broke my offline plug. I only mentioned that in case there was something weird about the non-working one in that screenshot that I posted.

Never a waste of time.

Spence and Brandido. After updating the code, you did save the preferences??

Please help by one more indulgence. Do the following (all on the IDE).

  • start liveLogging
  • In a NEW window, go to My Devices and select a HS110 plug.
  • Under the row “Preferences (edit)” select the “edit”.
  • Change nothing. Just do a “Save” in lower right.
  • You should see something like the below in “Current States” row of the Device’s page:
energy: 7
power: 0
DeviceWatch-DeviceStatus: online
monthTotalE: 0.06
monthAvgE: 0
weekTotalE: 0.02
weekAvgE: 0
  • If successful, let me know. If not, I will do a line-by-line review of the relevant code.

Note: I do not own a HS110 unit. I rely on users to assist in keeping it working and resolving issues. I use my LB130 as a testbed (it has energy monitor functions that I have coded for TEST purposes only). This device uses the same basic methods with the difference being the target method on the TP-Link device. It ran as expected using the steps above. When done, the Device’s IDE page should the following Current States:
energy: 7
power: 0
monthTotalE: 0.06
monthAvgE: 0
weekTotalE: 0.02
weekAvgE: 0

All I get when following the above directions is the following

* switch: on
* DeviceWatch-DeviceStatus: online

Will start aftesh tomorrow. I really need to work on a Hubitat Speaker Driver

My current states section only has two lines, compared to the seven that you showed. This is after saving the preferences both through the ide and through the app.

Here are the live logs taken while saving.

cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: info ╔ Event processed successfully (324ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: trace ║╔ Execution stage complete. (30ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Condition group #6 evaluated false (state did not change) (8ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Condition #7 evaluated false (6ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Comparison (enum) not present changes_to (string) present = false (1ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Condition group #1 evaluated false (state did not change) (11ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Condition #2 evaluated false (8ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║║ Cancelling condition #2's schedules...
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: trace ║╚ Execution stage started
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: trace ║ Runtime (39666 bytes) successfully initialized in 199ms (v0.3.10a.20190223) (288ms)
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: debug ║ RunTime Analysis CS > 24ms > PS > 199ms > PE > 65ms > CE
cce6202c-e092-45bb-805a-c45caf2fabc2  4:21:48 PM: info ╚ Received event [Phone Kamisa Wifi].presence = not present with a delay of 99ms
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug Event: Phone Kamisa Wifi has left Home
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug Updating: sVjMCN8yL
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug {"id":"sVjMCN8yL","present":false,"gaId":null,"location":"Away","lastUpdate":1552173707906,"battery":80,"name":"Phone Kamisa Wifi","charging":false,"stId":"2c2016bf-c46d-4b69-8e8e-d735f1cec319"}
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug Received push from server
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug Presence set
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug Previous location: Home
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug Current location: null
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug Setting location to: Away
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug setPresence(false)
4c604684-fec1-4b07-9792-8c6cd17ec52b  4:21:48 PM: debug setPresence(false)
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug getChildDevices(false), children=4
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug {"id":"sVjMCN8yL","present":false,"gaId":null,"location":"Away","lastUpdate":1552173707906,"battery":80,"name":"Phone Kamisa Wifi","charging":false,"stId":"2c2016bf-c46d-4b69-8e8e-d735f1cec319"}
65e2d52b-83e8-4b4c-aa2f-46b448fec6c0  4:21:48 PM: debug Received push from server
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:38 PM: error Right: Sending Command Exception: java.lang.NullPointerException. Communications error with device.
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:38 PM: error Right: Sending Command Exception: java.lang.NullPointerException: Cannot get property 'get_daystat' on null object. Communications error with device.
c6b8ae09-0a33-43a7-98d4-9c63e61bda12  4:21:38 PM: debug Xiaomi Temp 3: Parse returned [name:battery, value:100, unit:%, isStateChange:true, descriptionText:Xiaomi Temp 3 Battery at 100% (3.015 Volts)]
c6b8ae09-0a33-43a7-98d4-9c63e61bda12  4:21:38 PM: debug SmartShield(text: null, manufacturerId: 0x0000, direction: 0x01, data: [0x01, 0xff, 0x42, 0x1f, 0x01, 0x21, 0xc7, 0x0b, 0x04, 0x21, 0xa8, 0x13, 0x05, 0x21, 0x22, 0x00, 0x06, 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x64, 0x29, 0x60, 0x08, 0x65, 0x21, 0xb3, 0x11, 0x0a, 0x21, 0x00, 0x00], number: null, isManufacturerSpecific: false, messageType: 0x00, senderShortId: 0xbb64, isClusterSpecific: false, sourceEndpoint: 0x01, profileId: 0x0104, command: 0x0a, clusterId: 0x0000, destinationEndpoint: 0x01, options: 0x0100)
c6b8ae09-0a33-43a7-98d4-9c63e61bda12  4:21:38 PM: debug Xiaomi Temp 3: Parsing description: catchall: 0104 0000 01 01 0100 00 BB64 00 00 0000 0A 01 01FF421F0121C70B0421A8130521220006240200000000642960086521B3110A210000
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:34 PM: error Right: Sending Command Exception: java.lang.NullPointerException: Cannot get property 'get_realtime' on null object. Communications error with device.
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:34 PM: error Right: Sending Command Exception: java.lang.NullPointerException. Communications error with device.
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:31 PM: info Right: Power: on
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:27 PM: info Right: Refresh Scheduled for every minute.
48d4ee44-4bc0-40ae-aaac-adf76c6e395e  4:21:27 PM: info Updating Right...
2474231f-04d3-417b-ad00-e66c12259d0e  4:21:23 PM: debug Event data successfully posted to SharpTools.io
2474231f-04d3-417b-ad00-e66c12259d0e  4:21:22 PM: debug Event data successfully posted to SharpTools.io
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: trace Not sending alert, no preferences set
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: trace oncePerDayOk = true
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: debug HH autoExecute(), newMode: null
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: debug HH auto execute Monitors And Office Lights On Things Start Happening
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: trace daysOk = true
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: debug startTime: 2018-07-05T00:00:00.000-0600, endTime: 2018-07-05T23:59:00.000-0600, t0: Sat Mar 09 23:21:22 UTC 2019
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: trace motionActiveHandler(motion: active), timeOfDay: 2018-07-05T00:00:00.000-0600, endTime: 2018-07-05T23:59:00.000-0600
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: trace Not sending alert, no preferences set
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: trace oncePerDayOk = true
87124933-a147-48d1-bd10-19f20f424bf0  4:21:22 PM: debug HH autoExecute(), newMode: null
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: debug HH auto execute Monitors And Office Lights On Things Start Happening
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: trace daysOk = true
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: debug startTime: 2018-07-05T00:00:00.000-0600, endTime: 2018-07-05T23:59:00.000-0600, t0: Sat Mar 09 23:21:22 UTC 2019
d818bdc5-117d-46a3-8260-e4f709eabfcc  4:21:22 PM: trace motionActiveHandler(motion: active), timeOfDay: 2018-07-05T00:00:00.000-0600, endTime: 2018-07-05T23:59:00.000-0600
f546ab45-7259-443c-81f3-0872dd95e8fa  4:21:22 PM: debug Motion active
f546ab45-7259-443c-81f3-0872dd95e8fa  4:21:22 PM: debug Motion active

I reinstalled And When I am on The installation type It’s not giving me a safe box When entering my Kasa Account information

save is not present in Upper right hand corner of Application sign in

OK signed out of another tablet gave it time and now it gave me a save box

Installed all devices

I tried the quick fix and it did not work

Quick Fix Try:

  • Open the device details page in the phone app

  • Go to the setting page (gear at top-left)

  • Select Save.

  • If it fixed, tell me. If not, see next
    Next try:

  • go to “https://github.com/DaveGut/TP-Link-SmartThings” and copy the contents of the file “EMETER Test Code.groovy”

  • open the IDE and My Device Handlers

  • select the Energy monitor device and remove the text

  • copy the new text.

  • Select save and Publish.

  • Turn on live logging

  • Repeat the Quick Fix Try to generate more details for troubleshooting.
    I do not see the location of the file “EMETER Test Code.groovy”

Please provide me with where I could find this.

TY

We are out of sync.

See below for next try. You do not need to reinstall the app or the device. Also, I do not need more live logs. I know the problem. we are testing the solution. Your visual on the phone app will be sufficient.

  • go to “https://github.com/DaveGut/TP-Link-SmartThings/blob/master/Device%20Handlers/TP-Link%20Energy%20Monitor%20Plug.groovy ” and copy the contents of the file.
  • open the IDE and My Device Handlers
  • select and open the Energy monitor device handler and remove the text
  • copy the new text to the window
  • Select save and Publish.
  • Open the phone app and go to the device detail page.
  • Select settings (gear at top-left)
  • Save (top-left)
  • Observation: The six energy monitor tiles should now be populated (in about 10 seconds)
  • Observation: the current usage button updates when the device is turned on/off.

other notes:

  • unprotected password: Had to do this since a LOT of users were having problems with devices autofilling old or invalid passwords. Using text, the user can see what they entered.
  • No save button. I think this is due to having not exited the password field (move back to the username field). I will test out and update code if I can avoid.

Dave