[DEPRECATED] Kasa Plug, Switch, and Bulb integration

New Version 5.3.0 is available with some major changes:

  • Warning: Quick Polling can have negative impact on the Hubitat Hub and network performance. If you encounter performance "problems, before contacting Hubitat support, turn off quick polling and check your system out.

Update Instructions:

  • Using Hubitat Package Manager
    • After update, run the application or
    • Save Preferences on each device.
  • Manual Update:
    • Requires both Drivers and Application
    • Go to Driver Code page and open the driver
      • Select the Import
      • Select save
    • Go to the Apps Code page and do the same for the Kasa Integration.
      • Note: the link is not always in the Import line. Copy the text from the body of the app to the link line.
    • Run the Kasa Integration app then select done
      • While opening, the app updates each installed device.

Initial Installation:

Changes in 5.3 from 5.2.1:

  • Converted driver communications from UDP to rawSocket
  • Updated Quick Polling to use schedule vice runIn (assuring continuance)
    • Changed pollFreq command to pollInterval for clarity.
    • Poll Interval used drop-down for valid choices.
  • Created a method that updates data from 5.2.1 to 5.3 (mainly pollFreq).
  • Energy today is now updated every 30 minutes when in energy monitor mode.
  • Code cleanup for commonality across the eight drivers.
  • Application update to automatically update device data when the app is run.
2 Likes

As usual, thanks for your awesome work Dave!

I think you've missed updating everything in the Multi Plug driver though. The quick polling preference is still called Set Poll Freq, it doesn't have the dropdown, and it doesn't work setting it either.

I tested the quick polling in the Plug Switch driver and that appears to work (well, it's setting the polling interval at least. I didn't check whether it actually worked or not, but I assume that it does). I use RM to set the quick polling for a couple of my plugs. Am I still free to use any value between 5 and 60 when setting it through RM, or is it now limited to the values I get in the dropdown box? I haven't got RM on the hub where I have just updated the Kasa drivers, so I cannot easily check myself.

I'm currently setting the quick poll to 45 while the dishwasher is running. I guess I'll have to decide whether to set it to 30 or just change the device refresh interval to 1 minute rather than using the quick polling. Having said that, I cannot set the refresh interval from RM, can I? Looks like it's gonna be 30 seconds then :slight_smile:

Quick Poll Rate: Thirty seconds is better. The limit is set for how long the socket is open (~40 seconds) to avoid sending the connect command. It is actually better than the one minute refresh.

Testing quick poll. There is a new command in preferences that will provide a log.trace for 5 minutes of the quick polling. This was designed to provide the user with the assurance.

Multi-plug. RED FACED. You are correct. Fixed (somehow I did not copy over the production version). Instruction.

  1. Open the driver code and select Import. This should draw in the correct. It should look like the below (to the setPollInterval command). If the import does not work, the link is "HubitatActive/KasaDevices/DeviceDrivers/Multi-Plug.groovy at master · DaveGut/HubitatActive · GitHub"
  2. Run Save Preferences for the device.
/*	Kasa Device Driver Series
Copyright Dave Gutheinz
License Information:  https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/License.md
===== 2020 History =====
02.28	New version 5.0.  Deprecated with this version
04.20	5.1.0	Update for Hubitat Program Manager
05,17	5.2.0	UDP Comms Update.  Deprecated with this version.
08.01	5.3.0	Major rewrite of LAN communications using rawSocket.  Other edit improvements.
				a.	implemented rawSocket for communications to address UPD errors and
					the issue that Hubitat UDP not supporting Kasa return lengths > 1024.
				b.	Use encrypted version of refresh / quickPoll commands
====================================================================================================*/
def driverVer() { return "5.3.0" }

metadata {
	definition (name: "Kasa EM Plug",
    			namespace: "davegut",
				author: "Dave Gutheinz",
				importUrl: "https://raw.githubusercontent.com/DaveGut/HubitatActive/master/KasaDevices/DeviceDrivers/EM-Plug.groovy"
			   ) {
		capability "Switch"
		capability "Actuator"
		capability "Refresh"
		command "setPollInterval", [[
			name: "Poll Interval in seconds",
			constraints: ["off", "5", "10", "15", "20", "25", "30"],
			type: "ENUM"]]
2 Likes

Thanks for that. Updated and confirmed working!

2 Likes

I have having some issues with the updated driver, I too am using a multi-plug and have updated the Kasa EM Plug driver per the direction above. The on off commands do work, but here here is what I am seeing...

1 - Hubitat does not have the correct state for my outlets. Even after polling a refreshing. Hubitat always sees these devices on 'swith:on" state.
2 - When I turn on one outlet, both are turned on. They are also both turned off when I turn off a single outlet. They seem to be operating a one outlet.

Happy to provide more information as needed. Thanks in advance for the help!

Prospero

Welcome to Hubitat. I am Dave Gutheinz (Frisco, Tx, USA).

I need to know which Kasa device you are having a problem with and how you installed (initial installation or update to an existing installation?

Assuming that this is an update installation, you have three choices to correct the state you have placed the system (I am working on a fix for future upgrades).

Sorry for the verbose instructions.

Dave

@djgutheinz - Thanks for the verbose reply, exactly what I needed!

This was an upgrade and I am using a KP400. I tried the go forward (was hoping to keep the latest) options you provided to get to 5.3.1, but they did not work. Did not want to remove and reinstall as that would require me to re-create my automations. I was able to roll back the app and driver to 5.2.1 and that got me working again!

Thanks again, I will stay tuned for more updates.

Prospero

PS - Thanks for the welcome! Long time lurker :grinning:

@djgutheinz I was certainly not a very good tester of my devices after having updated to your latest drivers last weekend. It’s not until now that I have realised that there appears to be an issue with my KP303 using the multi plug driver.

For starters, it doesn’t seem to get an updated state even when I operate it from HE. I only turn on and off plug 1 on that board and that’s done daily. Since last weekend the state of that plug has been “on” and hasn’t changed. The automation has still worked everyday so the plug has defiantly turned on and off everyday. It is on for 7 hours per day and off for the rest so there’s plenty of time for the configured 60 minute refresh to update the switch state. Oh, I should also mention that even if I hit the refresh button in the driver, it doesn’t update the state.

Secondly, when plug 1 is told to switch off, the driver turns off all plugs on the board. Turning on works fine. Well, actually, come to think of it, I haven’t actually tested that turning on plug 1 doesn’t turn on all of them since the others should normally be turned on already.

I’m away from home at the moment so I cannot give you much more info than that right now. If you need more, let me know and I can run some more tests later today.

Thanks for an otherwise awesome integration!

Ok, I’m home now and I’ve done some further testing. It doesn’t matter if I ask plug 1 to turn on or off, it will turn on or off all plugs on the board. I’ve also tested it with plugs 2 and 3 and when they are controlled, they also turn on or off all other plugs on the board.

I’ve tested the TP-link Kasa app and that one properly turns off and on the plugs individually and it reports the correct state as well.

Let me know if you need anything further

Hold on. I think I’ve found something. I’ll report back shortly

Ok, sorry about the flurry of posts above which in the end turned out to be an issue with the wrong driver used.

Last weekend when I discovered the issue with the new quick polling for the multi plug driver, you sorted the issue promptly and directed me to the updated driver. In your post, you directed me to the Github repo but you also put the driver code in the post itself. I just copied the code from the post, which was actually the code for the EM plug, not the multi plug. So I've been using the EM Plug driver for my multi plug for the past week :wink: I have used the Github link you referred to last weekend and updated the driver from that instead. It works much better now with the correct driver. :+1:

1 Like

Sorry for my error. Glad you are up and running.
Dave

No problems. I should have opened my eyes!

1 Like

I still see a lot of connection errors: (quick poll is already disabled) on HS110 (other devices seem fine).
when this happens, hubitat can't control them, but I can still control them through Kasa app.
the only way to get back control is to reboot it through your app.

Need data.
Driver Version, App Version, Driver Name.
Turn on Logging when having the problem. Try controlling the device. Then try save preferences.
Attach that information here.
Dave

(all latest version)
I found the issue.
somehow my two HS110 keep changing IP address every day. even though I set static ip address in my fios router. Is there anyway to refresh the IP address periodically in the app?
thanks.

also see the exact same issue here:

Simply running the app will update all IP addresses. No need to run any of the options, just run to first page then exit. Sometime in the next week I will develop a more permanent fix. PS - I have 14 TP-Link devices and have never experienced this problem.

thanks, I have 7 Kasa devices and only the two HS110 have the issue.
I’ve tried again in router to link the MAC address to a fixed IP, will see if that works.

Make sure to reboot the router afterwards.

1 Like

New Version 5.3.1 is available with a minor change impacting both the Application and Drivers:

Update Error Process to check for IPs on comms error. Limited to once ever 15 min.

Update Instructions:

  • Using Hubitat Package Manager
    • After update, run the application or
    • Save Preferences on each device.
  • Manual Update:
    • Requires both Drivers and Application
    • Go to Driver Code page and open the driver
      • Select the Import
      • Select save
    • Go to the Apps Code page and do the same for the Kasa Integration.
      • Note: the link is not always in the Import line. Copy the text from the body of the app to the link line.
    • Run the Kasa Integration app then select done
      • While opening, the app updates each installed device.

Initial Installation:

3 Likes