[DEPRECATED] Kasa Plug, Switch, and Bulb integration

Sorry for the delay. Out of pocket for several days/week. The dimmer may not display this state in the Kasa Phone App.

ISSUE with binding. There is a relatively new issue with binding. Some of the devices do not allow you to rebind the device through the Kasa Phone App (I experienced this with a light strip). Once unbound, these new devices can not be controlled at all through the Kasa Phone App. You can rebind by entering your credentials into my Kasa Integration App and then bind via the device's page. That is the only way other than re-installing the device.

Cloud Integration Issue.

There is now a confirmed issue that popped-up on my testing of the CLOUD integration. This just started.

Issue: on refreshing the kasaToken, the KasaCloud returns a rate limit exceeded error. The current implementation then sets the token to null and throws a warning. This causes Hubitat control of the devices to fail.

Fixes: I am working on a temporary fix. Until then, make sure you minimize the number of Kasa Integrations on your various controllers (Hubitat, Habitat, Alexa, Google, IFTTT, etc.).

Future: I am working on a fix where the token is not nulled and the request for a new kasaToken is repeated in 5 minutes if there is a failure.

Update: A review in Homey indicates that this is a general problem across multiple platforms using CLOUD integration.

1 Like

Version 6.6.1 Update Available

Issues addressed:

  • App: rate-limit error on attempting to get error due to Kasa imposing rate limits.
  • Drivers: Fixed help link to new Link readme.

Update:

  • Update app and all drivers you use either via HPM on Manually.
  • After code update, run the App and the select DONE (no other actions required). This will:
    • initialize the new processing in the app
    • update the IPs for all LAN discoverable devices
    • run Save Preferences on all devices.

Alright, it's happening now. The air purifier won't turn back on because the plug on the HS300 is off. I can see this in the Kasa app.

All the ones with the square plug icons are on the HS300. Here is the IP information as shown in the router.

In HE, the device seems to know the switch is off

I turned on logging for my rule I posted above and debug logging for the air purifier and waited for an update.

The rule never triggered because the plug is already off.

So thinking about where the problem could lie...The Kasa device seems to be updating properly. So this means the command to turn the plug back on from the rule I posted above probably didn't get received properly by the HS300, and there's no way for us to know this from the HE.

So is there a way to write a rule that checks for IS instead of becomes? So the rule would be Air Purifier IS off instead of TURNS off? This might be outside the scope of this post and warrant a new thread...

The parse logs indicate that the air purifier switch is indeed off in both instances. I do not see any log for trying to turn on the device nor for the detection of the device on.

To verify Kasa Integration functionality: Go to the device's edit page in Hubitat and turn on the device. See if the value of switch changes to "on". If so, then the error is somewhere in your rule, not in the Kasa Integration.

Send me a readable copy of your rule. I am NOT a rule expert, but I may see something.

Screenshot up above in this post. Super simple rule. If the switch turns off, wait 5 seconds and turn it on. It's made in Basic Rules.

Go to the device's edit page in Hubitat and turn on the device. See if the value of switch changes to "on".

Yes, it does so. It also immediately turns off if I click off or a rule turns it off. This mismatch is what I was hoping would make my rule work even if a command gets missed. What could happen is

  1. TV turns on. Sometime in less than 1 minute HE should realize this.
  2. Sends an off command to the Air Purifier. The device in HE should report off at this time. (this part never fails)
  3. The rule triggers and waits 5 seconds; sends an on command. The device in HE should now say on.
  4. For whatever reason, the plug didn't get the on command. When it's polled for its energy usage again, the switch should revert back to off.
  5. This should trigger step 3 and 4 to repeat until the switch is actually on.

So it seems to be an issue unrelated to your app/driver. I think I'm going to make a separate thread about this issue.

EDIT: Thread made

Trying to update but getting this error

“ Be sure the package is not in use with devices.”

Any work around?

Do I install the new driver first? Delete original driver first?
Confused

Another issue I find is that after some time the devices forget their driver….
Error says no driver installed even though there is and it initially installed with it.

Nothing in my code would cause a device to forget their driver completely. You can reload a "missing" driver on the driver's edit page, "Device Information", "Type". You would scroll down to the driver for the TP Link Device.

I was able to get it to update after “matching”apps in HPM. Not sure if that’s why I’m also experiencing issues with my drivers.
I may have added driver manually but now it’s wanting to update it through HPM

I looked on device page. The Kasa plug switch driver is selected

For some reason even though I’m updated to 6.61 the device still says 6.6.0

Check your Driver Code page/list, you possibly have the driver installed twice, and the device is pointing to the old outdated copy. You may also have the app installed twice now.

Easiest way to fix if you do not have a ton of devices is to switch the driver they are on. You might also have success by deleting the not in use driver and any duplicated app code as well, going to HPM and doing an UNMATCH on all Kasa instances, then Matchup again and make sure it matches up the app and drivers.

Only 1 driver noted
Only 1 app noted.

How do you UNMATCH in HPM?

After you do this, run the MatchUp again, do not tell it everything is updated, then run an update and it should reinstall (update) everything it just matched up. Then I believe the process after that is to go into the Kasa APP and click DONE at the bottom, this should refresh all the devices, etc...

  • Screen Shot 2022-07-25 at 2.04.40 PM
  • Screen Shot 2022-06-12 at 7.47.25 AM

The feature is found in Package Manager Settings, at the very bottom. Click it and you're offered a list of your packages.

Thanks for the in depth explanation. Unfortunately still running into same situation where driver is unknown, n/a

This is second time it happened to me. Previously I just deleted everything and started from scratch but now I have more devices and rules with these switches :confused:

I am getting these errors

errorjava.lang.IllegalArgumentException: null on line 216 (method updated)

errorjava.lang.IllegalArgumentException: null on line 295 (method updated)

dev:2112022-07-28 09:48:52.047 pm debugJosh bathroom light 6.6.1: sendLanCmd: [ip: 192.168.68.65, commsTo: 3, cmd: {"system":{"get_sysinfo":{}}}]

Question: What Kasa Devices?

Note, the page displayed indicated that none of the devices are installed. So you have a mess going on. It looks like you have duplicate versions installed!

You may have duplicates. Things to further check and get back here for next steps:

  • Do the Unmatch in HPM as recommended by @jtp10181.
  • Aps page: Verify there is only ONE Kasa Integration instance installed.
  • Aps Code page: Verify there is only ONE "Kasa Integration". If there are, what are the dates for each.
  • Devices page:
    • Verify there are no duplicate devices by name.
    • Select the column "Type" (this will sort the page on the type value) and look for BLANKS. Any BLANKS?
  • Drivers Code page: Verify there are no duplicate drivers. If there are, what are the dates for each.

Next steps will depend on these answers (what is duplicated). Essentially you will need to determine which devices are duplicate, then which drivers, then which app, then which app code.



unmatched... see pics
no BLANKS

as a test, i deleted 1 switch (btw they're all hs 200) and this is what i get when trying to re-add it

You will get null for driver version on initial installation. As part of the installation, the updated method runs and this will check and update the Driver Version.

This is also true when you update. You need to assure you follow the instructions since that will cause the updated method to run and update the Driver Version as well as other data.

Next suggestion is to run a Save Preferences on one of the devices. This will assure the updated method is Run on all devices and and all data is up to date. I suggest the following:

  • Open a logging window
  • Run save preferences on one device only.
  • Wait 3 minutes
  • Turn the device on then off on the device's edit page.
  • Send me the log plus your observations.

Below is my log from doing same:

Had a small panic tonight! A restore of last night's backup has fixed me for now, but would like to know how to proceed. I have been running version 6.4.2 of the Kasa integration with no problems for several months now. Lots of dimmers and switches. HPM wanted to update KasaInt to 6.6.1 so I let it go ahead. I then opened the app and clicked "done" to let it reinit. The Kasa dimmers were now malfunctioning (not responding to most commands), but the Kasa switches were fine. I am running platform 2.3.2.141 on a C-7. The log was showing these errors, do they indicate what I did wrong along the way?

app:302022-08-08 06:12:24.655 pm info[KasaInt: 6.6.1]: Kitchen Cans: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2132022-08-08 06:12:23.646 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:12:14.552 pm info[KasaInt: 6.6.1]: Master Toilet: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:222022-08-08 06:12:13.543 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:12:04.451 pm info[KasaInt: 6.6.1]: Kitchen Island: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2152022-08-08 06:12:03.441 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:54.339 pm info[KasaInt: 6.6.1]: Great Room Cans: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2122022-08-08 06:11:53.330 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:44.242 pm info[KasaInt: 6.6.1]: Dining Room Lights: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:232022-08-08 06:11:43.231 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:34.143 pm info[KasaInt: 6.6.1]: Kitchen Countertops : [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2142022-08-08 06:11:33.134 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:24.042 pm info[KasaInt: 6.6.1]: Great Room Fan Lights: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2102022-08-08 06:11:23.033 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:13.937 pm info[KasaInt: 6.6.1]: Owner's Entry: [ipUpdate:complete, driverAppVersion:matched, driverUpdate:noneAvailable]

dev:2112022-08-08 06:11:12.922 pm errorjava.lang.NullPointerException: Cannot invoke method contains() on null object on line 115 (method updated)

app:302022-08-08 06:11:03.812 pm info[KasaInt: 6.6.1]: Garage Lights: null

dev:2092022-08-08 06:11:03.809 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_davegut_Kasa_Plug_Switch_449.childConfigure() is applicable for argument types: (java.util.LinkedHashMap) values: [[currVersion:6.6.1, releaseNotes:Fixed limit-rate-exceeded issue from Kasa Cloud. See: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/Docs/ChangeLog.pdf, ...]] (method childConfigure)

app:302022-08-08 06:10:57.687 pm info[KasaInt: 6.6.1]: Stair Lights: null

dev:242022-08-08 06:10:57.683 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_davegut_Kasa_Plug_Switch_449.childConfigure() is applicable for argument types: (java.util.LinkedHashMap) values: [[currVersion:6.6.1, releaseNotes:Fixed limit-rate-exceeded issue from Kasa Cloud. See: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/Docs/ChangeLog.pdf, ...]] (method childConfigure)

app:302022-08-08 06:10:51.541 pm info[KasaInt: 6.6.1]: Front Covered Entry: null

dev:2082022-08-08 06:10:51.538 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_davegut_Kasa_Plug_Switch_449.childConfigure() is applicable for argument types: (java.util.LinkedHashMap) values: [[currVersion:6.6.1, releaseNotes:Fixed limit-rate-exceeded issue from Kasa Cloud. See: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/Docs/ChangeLog.pdf, ...]] (method childConfigure)

app:302022-08-08 06:10:45.424 pm info[KasaInt: 6.6.1]: Patio Light: null

dev:2072022-08-08 06:10:45.421 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_davegut_Kasa_Plug_Switch_449.childConfigure() is applicable for argument types: (java.util.LinkedHashMap) values: [[currVersion:6.6.1, releaseNotes:Fixed limit-rate-exceeded issue from Kasa Cloud. See: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/Docs/ChangeLog.pdf, ...]] (method childConfigure)

app:302022-08-08 06:10:39.308 pm info[KasaInt: 6.6.1]: Garage Side Door Light: null

dev:2062022-08-08 06:10:39.304 pm errororg.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: user_driver_davegut_Kasa_Plug_Switch_449.childConfigure() is applicable for argument types: (java.util.LinkedHashMap) values: [[currVersion:6.6.1, releaseNotes:Fixed limit-rate-exceeded issue from Kasa Cloud. See: https://github.com/DaveGut/HubitatActive/blob/master/KasaDevices/Docs/ChangeLog.pdf, ...]] (method childConfigure)

app:302022-08-08 06:10:32.942 pm info[KasaInt: 6.6.1]: getManifestData:

app:302022-08-08 06:10:32.799 pm info[KasaInt: 6.6.1]: fixConnection: [segmentArray:[192.168.1], hostArray:[1, 254], portArray:[9999], tokenUpdated:false]Checking and updating all device IPs.