[DEPRECATED] Kasa Plug, Switch, and Bulb integration

Thanks, updated my drivers, and it took all of 5 seconds with the import function. Great work @djgutheinz !

1 Like

I think something is wrong with your dimmer switch driver. I'm on 4.5.12

The device in HE doesn't show any dimming options. Also, when using HubConnect, these dimmer switches are not listed as dimmers but shows as switches instead. Let me know if you need screen shots.

I messed up. JUST FIXED and UPDATED driver on GitHub.

Feedback welcome.
Dave

@djgutheinz, couldn't agree more - the Import function works great.
Thanks

You did understand that a fix is on GitHub? My wording was imperfect.

Dave,

Not sure if this recent fix was supposed to fix this, but I'm still getting a fair few state changes where nothing has changed flow through to the hubconnect main hub.

For example, yesterday I set up Christmas lights with a brand new tp-link plug.
Real device: 89 events in about 24 hours....

Hubconnect device in 24 hours.

For this device, it's a TP-Link Engr Mon Plug, at version 4.5.12.

I don't have anything to add yet, just wanted to drop a big thanks to @djgutheinz, during my research phase this thread is basically the reason I bought a hubitat. Thanks!
:+1:

2 Likes

For the EM plug, I monitor change in Power in quick poll. If not the same as previous, the event is generated and will feed throughout the system. The anticipated use case was monitoring the device (i.e., a washer) for when the power went below a threshold, indicating time to change out to dryer. It could also be used if someone turned or unplugged a connected device. It is working as intended.

There are other checks I could implement and I will play with the code; however, the processing impact is extensive.

Dave

Hi, new to hubitat (as in just installed it). Added your app and its working perfectly.
Just wondering if that status can be faster, sometimes my HS110's are changed outside of hubitat. I tried fast power polling and thats great, surely a postive power reading means the switch is on?

You realise that you can go into the device page and update it to 1 minute.

Alternatively, create a rule in Rule Machine that says when power is > x, refresh device every 60 seconds.

Hi, yes i did see the refresh internal and thanks for that automation i'll take a look.
I'm just used to home assistant where it had had basically no delay if i was to change the status of the plug via an outside means (eg with the kasa app)

Awesome! Thank you for all your hard work putting this together. It is very much appreciated.

Log Message Implementation in TP-Link Device Integration
There has been significant discussion on log messaging for the TP-Link device integration, mostly complaints about too many entries. I have reduced to a minimum the log lines within the various methods. When completing the logging implementation, I also consider that the device events log report when an attribute (state) has changed.

Events. The logs work with the device events list to determine what has occurred in the past. I use the capability events that report when the device states change, as below:

  • On/Off
  • Level
  • Bulb Color States
  • Energy Monitor Data
  • Communications errors (turns on if comms fail, back off when comms are normal) - a custom attribute.

Warning logs. (No user filter.) Purpose: Identify if a command was not executed for a known and anticipated reason. These are generated when an abnormal condition occurs. Examples are the user enters an invalid parameter, a communications error, or an invalid return from the device.

Debug Logs. (Recommend Disable.) Purpose: troubleshoot the interface in case of error messages. I uses debug log entries through the code and display raw returns from the device. When you select Debug Logs, logging will stop after 30 minutes. Use debug logging if you are having problems and want to post detailed data on the issue.

Information Logging. (Recommend Disable.) Purpose: Determine if the device commands and refresh are working and returning data. I use info log entries to report any time the attributes are updated, whether there is a change or not. This includes on Refresh, but not on quick polling. If turned-on, it will occur at each refresh as well as each command sent to the device. Exception: For quick-polling, I do not log the event being sent.

Quick Polling Information
I have added two types of quick polling to some of the drivers. I added these on request of the user - but they should be used only in limited cases. These exact a significant processing bandwidth on the Hubitat server. Wherever possible, consider using a faster refresh rate instead. Consider resetting to normal polling when not needed.

Switch Quick Polling.

  • Only available on the non-energy monitor plugs and switches.
  • Anticipated use case is for a SWITCH, not a plug, to monitor when someone activates the switch manually and a 1 minute refresh rate is insufficient.

Energy Monitor Quick Polling.

  • Only available on Energy Monitoring devices.
  • Track power in watts for the device.
  • Anticipated use case is for monitor power consumption within a rule to determine if power is above or below a (rule-defined) threshold. For use when one minute refresh is insufficient.

If anyone disagrees with these or has other comments now is the time.

Dave

3 Likes

Thanks for your hard work getting these drivers to work Dave! I have just bought myself my first pair of TP-link smart plugs and they work brilliantly with your drivers. Thanks again! I will get some more plugs tomorrow :slight_smile:

Just one tiny feature request. Would you be able to include the URL to the git repository in the introductory comments inside the drivers and the app? That way I would be able to quickly find my way back if/when Iā€™d be looking for an updated version.

1 Like

Good idea. I will update the headers for the drivers today.

Dave
update: Headers updated.

2 Likes

Dave,

Just had a thought, I'm wondering if it would be possible to disable polling for certain devices that are currently not used. Such as Christmas lights that are only used at Christmas time, and turn off the comms error notifcation.

Mike,

You can disable any device the Hubitat "Devices" page. In the upper right corner, there is a "X". Select that and a Left column "disable" will be added. Checking the box next to any device will disable it (no polling, no interaction). (PS, you can also do the same with Applications.) Re-enabling is simply turning back on and running a Save Preferences (assures a kick start of refresh and any quick polling).

Dave

4 Likes

Starting last night, I began receiving multiple errors from my HS-300 power strip for all plugs:

errorjava.lang.NullPointerException: Cannot get property 'energy' on null object on line 226 (setEngrToday)

I rebooted the hub, but am still getting the error. The plugs are still controllable via HE and TP link app. Any suggestions?

Thanks

Ouch. A Groovy date call is not working properly. I use the Groovy Date call. I added two log.errors to my code to see what is going on. The code becomes

log.error new Date()
def year = new Date().format("YYYY").toInteger()
log.error year

This should result with the year being 2019 (today at least). It is not working properly and is returning 2020 - which is incorrect and causing the error you are seeing.

dev:43762019-12-29 11:30:26.893 am error2020

dev:43762019-12-29 11:30:26.889 am errorSun Dec 29 11:30:26 CST 2019

I will try to get a work-around out today. Alternatively, you can disable energy monitor functions in the preferences section.

Dave