[DEPRECATED] Kasa Plug, Switch, and Bulb integration

To be clear, I am not blaming these drivers....
Has anyone else experienced random on/off events? I had 2 different lights today turn on and off 4 or 5 times (not shown in Hubitat, but shows in SmartThings logs (hey, give me a break, still porting over)). Just looking for an overall sense from the community if this is pervasive or isolated.

Thank you and thank you @djgutheinz for creating this integration. Again, my post is general to Kasa, not to this driver implementation.

Thanks for the note. (Not being defensive). My code does not itself contain any method to turn on / off internally. The reason you do not see in Hubitat is that the Kasa Device updates occur only via the quick poll or refresh functions of the device. This is not true of the Kasa App nor Smart Things which use a subscription technique not available in Hubitat.

Some Ideas:

  • Rules: Various rule engines (Hubitat, SmartThings, Amazon Alexa, Google Home) could be causing the commands. Check these.
  • SmartThings. There is no need to have the devices connected to both SmartThings and Hubitat. When you are satisfied with Hubitat, remove the Kasa Integration.
  • Amazon Alexa. If you use this, again, you can delete the Kasa Skill and use the Hubitat Skill to interface the Kasa devices to Alexa.
  • Google Home. Probably the same.

I have been using Dave’s drivers for a couple years now and must say that I have never experienced what you have described. I also only have them integrated through Hubitat to things like Alexa and Homekit and don’t use cloud access.

@Ken_Fraleigh I absolutely believe it had nothing to do with these drivers. I was just attempting to takes advantage of a very focused community of users of Kasa devices to determine if my device issues were Miner alone.

When the lights turn off and on randomly, DW wants to know why and my paranoid mind wonders if my account or TP-Link were compromised. Just trying to get a pulse on anyone else seeing this behavior.

More pertinent to this forum, I have more moved all devices to unbound (thanks to @djgutheinz's drivers) and considering blocking them from accessing the internet at all.

@djgutheinz, have you had anyone try that and not have any issues with an eventual auth timeout or is there no auth on lan?

1 Like

The LAN implementation does not require an authorization to work.

LAN Integration Version 6.0 Update Available.

The Update for the LAN integration to version 6.0 is available.

Update. Although I checked several times before porting over to GitHub, I did encounter some errors (and will continue to troubleshoot. To update the code, follow the below instructions. There may be errors during the upgrade and we may loose previous quickPoll frequence. Sorry for the Inconvenience.

Note The current version can be accessed in the Archive folder under Drivers and Application folders in GitHub.
1 Update both the driver and application files using your preferred method.
Note If using HPM, verify the drivers all updated. If a driver did not update, use the Import Function.
2 Run the application (Kasa Integration)
2a Select the options for Interface to Kasa Cloud, as desired.
Note This will cause the Login / Update Token option to select. If you login, the token will update every three days. If subsequently deselected, the token will not update.
2b Run Install Kasa Devices / Update Installed Devices
2c Select Next on the Add Kasa Devices to Hubitat page. (no need to add devices)
2d Select Done on the Kasa Local Hubitat Integration page
3 Open each device and verify Preferences
3a Complete a Save Preferences

Changes:

  • Application
    • Added capability to select/deselect Kasa Cloud Access with login / token access pages.
    • Added capability to set the LAN segment to find devices (when different from Hubitat LAN segment)
    • Moved Kasa Tools (bind/unbind device, LED on/off, reboot device) to the individual device drivers.
  • Drivers
    • Merged quick poll command and refresh preference to new Refresh preference.
    • Added preferences for Kasa Tools.
    • Added preference (capability) to use Kasa Cloud or LAN.
    • Limit Refresh to one minute ONLY when Kasa Cloud is used for the device.
    • Added Cloud Communications / Parse methods.
  • REMOVED capability to do a manual (without application) installation. (Note: When using LAN instalation, the APP is not used during operations.)
5 Likes

Thanks for all your do @djgutheinz Love your work.

1 Like

Pretty sure I got updated 6.0.0 correctly, and now I cannot reliably control the HS200 unless the Kasa Cloud option is enabled. I was using the regular app (non-cloud) before and everything was working fine. The only other device I have is a HS105 but it is in my daughters room so I don't want to be messing with it at the moment. I posted it as an issue on GitHub. rawSocketTimeout errors when I try to turn it on/off from the hub using the lan control. Every once and a while it works, but usually get these errors.

Jeff,
I did a hot fix to the code - description below. Update the code using "repair" in HPM or the import function on the driver page. Then make sure you did a save preferences.

Cause: In sendLanCmd, state.lastCommand was saved as encrypted vice plain text. This causes the retries to always fail.

Regression testing. Using my HS200, updated code, did a SavePreferences on the device with all logging on. Ran Refresh 20 times and on/off through 10 cycles.

Dave

Please confirm by marking this post as a Solution.

Seems to be working now, but it almost always gets the rawSocketTimeout on the first attempt and then works instantly on the second. So not sure what is going on there. Every once and a while it goes through on the first one.

Just tested the HS105 as well, that device seems much more responsive so possibly the delays on the HS200 is something hardware related. They are both about the same distance from the router, only one room over in two different directions.

First, it works fine for my HS200 so it is hard to troubleshoot. May be differences in fw or hw for the device or yours may be in a wierd state. Try rebooting the HS200 (in preferences) and see if that helps (warning, use reboot judiciously). The good news is that the error correction is working.

I figured out the issue. I did see the warning come up once saying something about the device name being wrong. I thought it was saying the first 5 should be the model, did not realize it was saying the device name should ONLY be the first 5 of the model. Originally I had the device.name "Kasa HS200" and I switched it to "HS200 Kasa" when I saw the error. It did not come up again that I noticed so I thought it was happy. Today I just discovered in the code it is doing an == check against that looking specifically for the HS200 to do an extra step which was getting missed. On the retry however I can see in the logs it was doing that extra step (attempting to connect...).

image

Might I suggest a more persistent and more clear warning in the log? Or could also change the == to a regex match (no quotes needed): device.name ==~ /.*HS200.*/

Either way I got it fixed and understand it now for myself.

I appreciate the look and that would cause the problem. Error message will change in next release.

I'm still getting below error in my logs continuously. I do have version 6.0.0.1

2021-01-25 08:41:12.940 pm debug Third plug sendLanCmd: Attempting to connect.....
2021-01-25 08:41:12.919 pm debug Third plug sendLanCmd: {"cnCloud":{"get_info":{}}}
2021-01-25 08:41:12.915 pm debug Third plug rawSocketTimeout: attempt = 1
2021-01-25 08:41:10.062 pm errorjava.lang.IllegalArgumentException: null on line 261 (rawSocketTimeout)
2021-01-25 08:41:10.032 pm debugThird plug SendCmd: Unable to connect to device at 192.168.86.134. Error = java.net.NoRouteToHostException: No route to host (Host unreachable)

What type of device?
The software is working as expected. The problem is the device is not found at the IP address (see bottom message the error message comes from the Hub). Possible causes:

  • The device is not powered on.
  • The device's IP address has changed and is not 192.168.86.134.
    • Corrective action for IP address change:
      • Run Application
      • Select Add Device/Update Device Data.
      • Verify device is on list (if not, then the device is either not on same segment as Hub or the device is not powered.)
      • Exit Application and try again.

Never mind. I think I figured out which application you are talking about. Thanks will dig through more

1 Like

I was able to add that device. When I tried to add my other plug I'm getting below error.

2021-01-26 03:39:57.250 pm [warn] (http://192.168.86.41/installedapp/configure/161)6.0.0 Failed to install device. Data = 50C7BF0666B2={ip=null, appServerUrl=https://use1-wap.tplinkcloud.com, plugNo=null, alias=My Smart Plug, model=HS110, type=EM Plug, deviceId=8006CE4A43AD334D6F5670A0CAC5adsads, dni=50C7BF0666B2, plugId=null}

Did you install the Driver for the Kasa EM Plug?

Additionally, This indicates that the plug was not detected at the local LAN level (ip is null) - but was detected in using the cloud connection.

What is the device IP of your Hub? The Device?

I used HPM to install Kasa Integration and it looks like didn't install all the drivers. Once I installed Kasa EM Plug driver from your GitHub I'm able to connect the device fine now.
Thanks for awesome support.

1 Like

Do not worry. Are you still having problems?