[DEPRECATED] Kasa Plug, Switch, and Bulb integration

Hi @djgutheinz,

First let me thank you for all your hard work, I have been using your Kasa integration for about 2 years now and it has been extremely useful to me, thanks so much!

As my post history shows I'm a bit of a security freak, I keep my IoT devices in a separate subnet with no access to my internal network and thus since I first installed your integration I had to figure out a way to make it work. Adding the devices manually is an option but instead what I do is that every time I install a new version I do 2 small modifications to the code and everything works just fine, no issues at all for me.

So, based on the latest code this is what I change:

In Line 104 resp does not contain the Device's MAC Address as its on a different subnet, so I get it from cmdResp instead removing the colons.

def dni = cmdResp.mac.replace(/:/, "")

In Line 800 I put the subnet where my devices are located in the networkPrefix variable instead of getting it from the hub's IP:

def networkPrefix = '192.168.25'

Reading the latest posts on this thread I realized I'm not the only one, other people have asked for this (@kbo5000, @alex2 , etc.), it would be really great if you could add a setting to the application to specify a custom subnet, if empty do nothing special, if set to something use the modified code above. Or perhaps if the custom subnet is defined then also check that one after the local one? either way it would greatly help us weirdos every time install / upgrade the app / add new devices :slightly_smiling_face:...

Thanks. On my research list for the next revision.

Since you have security concerns, I assume you are aware of the bind/unbind functions in the APP. This removes Kasa cloud access to the device while still allowing local access via Hubitat and the Kasa App.

Dave

Thank you!

Correct, that was a welcome addition to the app, the subnet I put my IoTs on is considered insecure but still, that is useful.

Actually, now that I play with the tools they did not work for me because all the response functions use the MAC (DNI) from the response lan message to identify the device the response comes from, but for devices that are not local this is always null.

In order to get the tools page you need to open the app and the first thing this does is update all devices and their IPs plus commands are sent to devices using its IP, so I think it is pretty safe to identify the device the response belongs to by IP and not by MAC/DNI.

I did similar small tweaks to all response functions and they are now working fine for me as well but of course this would be a bigger change, are you open to code contribution? I can fork and send a pull request so you can see the changes I did and decide if you want to use them... its all small changes but given the amount I think this will be a lot better...

New Version 5.3.4 available.

Changes:

  • Added KL430 as a color bulb.
  • Added capability to enter segment other than segment Hubit hub is on.

Thanks for adding the setting for a custom subnet!

I just sent you a pull request with all the tweaks necessary for everything to work well when using a custom subnet, nothing mayor, I also tested these changes with local devices as well so it should be safe for regular users.

I will look at it. It will take a while.

@djgutheinz Thanks for this awesome driver! I'm confirming it works great with the KP115. I've been running it for a few hours, outputting to InfluxDB and I can see it measuring power over time in Grafana.
KasaTP115_Grafana

HPM says there's an update but throws an error when I try to update the package. Anything I can do to fix this?

Just tested, no issues. I do not know what may have occurred.

Are you running the Cloud or Local version of app? I currently have KP115 operational on local app (KP115 firmware version 1.0.7, hardware v1.0) unbinded on local app so hopefully will not update via Kasa App.

I installed the cloud version due to Dave's very top comment "There are now a local and cloud version of the Kasa Integration. The cloud version is intended for use when your firmware has been upgraded to the latest version. If that occurs, the local version will not work."

Everything is working great and it's reporting to the Sense Energy monitor and Hubitat(->InfluxDB->Grafana) quite well. It's also reporting fine to the Kasa app which I don't use (only to install the device initially.) My 3 TP115s are all hardware v1.0 and firmware v1.0.10 so there's a chance the "latest version" that Dave refers to is somewhere between yours (1.0.7) and mine (1.0.10.)

However, I'd much prefer the local version so if you end up upgrading your plugs to 1.0.10 and they still work with the local app, please let me know!

Hi Mike,
I plan to leave my KP115 at firmware 1.0.7 since I’m afraid to lose local only access. If they “accidentally” (meaning forced update) get updated, I’ll certainly let everyone know if they still work local only.

I am running 4 HS105 smart plugs and have them running in the cloud. I have the app and driver installed and set up. Everything seems to be running fine howver, I cant create a tile on the dashboard. Although it shoes up in the devices, it does not show up in the "pick a device when setting up a tile.

How do I create a tile to control the HS105??

Did you add the device to the child app in the Hubitat Dashboard app?

i forgot to add it...............thanks

Working on a major update. User added recommendations requested via Private Message.

Reason for Update: The traditional Hubitat integration has been using local wifi integration to control the devices. However, TP-Link is rolling out security updates that if installed will break the local integration. I want a single integration that handles both with a user preference on local or cloud control. This will allow users to rapidly change to the cloud if their device is upgraded with the security updates.

Plans:

  • New app
    • User selected cloud only, local only, cloud/local communications
      • Selecting cloud only will cause the app to check for and bind all unbinded devices to the Kasa Cloud.
    • Discovery using above to guide methods
  • New device driver preferences:
    • Cloud/Local device control selection
      • Automatically bind device to cloud on Cloud Control
    • Bind/Unbind the device with the Kasa Cloud
      • Locked out if device is bound to cloud.
    • Status LED ON/OFF
  • Potential capability changes:
    • Quick Polling. Determine best overall solution to avoid over accessing the Kasa Cloud.
    • Add device health and attribute to existing code

I love your work mate! It sounds awesome to have both cloud and local control available within the one app.

One question/feature request though: Will it be possible to set the cloud/local setting on a per device basis? The reason why I’m wondering is that all my current devices are local and since they haven’t got access to the Internet, they should not get a new firmware version that makes them cloud only. My strong preference is for them to stay local. However, if I buy a new device in the future that already has the newest cloud-only firmware, would I be able to configure only this device for cloud and keep the others local?

The plan is two fold:

  • User has to enable cloud access through the Application.
  • For each device, user can select cloud or local control. This can be changed without removing and reinstalling the device.

From what I gathered from the web, the security patch affected only one model with a specific hardware version. It looks like since then, tp-link released a firmware patch to reinstate the local control.