[DEPRECATED] Kasa Plug, Switch, and Bulb integration

I dug into the CT table and there's DEFINITELY something wrong (you can tell by looking at the configuration change at 4000k). And this table explains why the lights are so red and why going above 7000 sends the coolness in the wrong direction:

I am kindof a data nerd and CT obsessed. If you'd like me to take a look at another CT table to see if it's more appropriate, just point me to it and I'll be happy to take a look.

If you noticed, that method has an "xx" in front of it. I created a new one and kept this one by renaming. The new one is algorithmic based and gives very similar results.

That being said, I will create a new command for YOU and ME only. It will be Set RGB and will have separate entries for Red, Green, Blue. Will then convert to the devices HSL format and run the command.

When this is done, you can do a search for White to RGB on the internet. An example of one response is at : White color code - RGB white color

It will take about 30 minutes to code and test.

The test code is located at : https://raw.githubusercontent.com/DaveGut/Hubitat-TP-Link-Integration-DEPRECATED/master/Test%20LightStrip.groovy

New command
setRGB (rgb) - rgb is a string red, green, blue; ex: 244,233,244

You can modify the lookup in method getCtHslValue as you desire. I would concentrate on the 5 Alexa "white" values:
Cool White: CT = 7000
Daylight White: CT = 5500
White: CT = 5000
Soft White: CT = 2700
Warm White: CT = 2200

If you update these in your table, then you can voice command the five colors and get the "translated" effect.

1 Like

That did everything I needed it to do. And because I'm such a CT obsessive nerd, all of my Webcore pistons were already running CT commands that were compatible with the CT table changes I made that align with the Alexa big 5.

As soon as I altered those specific CT lines, everything in my house started working correctly again because I was still running my webcore code. While I was in there, I saved the bulb presets and they call correctly every time. EVERYTHING works now as intended and there's no more red tones.

You've unlocked the full functionality of these lights and I had fun/learned so much in the process. Thanks, Dave.

1 Like

Can you provide a copy of the updated table. I may want to integrate it in the master code. Dave

Animated GIF

And give you all my secrets?!?:crazy_face:

Give me another day to play with/refine it and I'll send it to you. After a full day of real world light cycles, I might do some tweaking.

1 Like

I haven't forgotten about you. I overhauled my webcore code (again) yesterday which revealed some irregularities (blooming) with the morning cycle. That would be my 7000k setting. I'll start looking there and then swap it out for my presets and see if that improves the behavior. The 5500 afternoon and 2700 evening seem to be fine.

I truly wish we could go back to the CT settings that were in the kasa bulb driver but I understand that's pie in the sky because it's not supported by the API. It just worked so well and at the end of the day, I'd rather have the effects suite of functionality.

I'm going to continue to mess with the color this weekend and hopefully get you what I think are the closest settings to the old driver to mimic the 5 basic whites.

Edit: I remembered why I wasn't using the presets now. Webcore won't allow the custom functions to be selected when devices are in a grouping.

So what I've done is ungrouped all the lights on one floor, reconfigured them for the presets vs the CT and everything appears to be stable.

Now I just need to figure out what the best path forward is.
Edit 2: couldn't figure out why the lights weren't triggering. I had only copied the presets to a few bulbs.

1 Like

Hello again,

I discovered another problem along the way but I'm not sure how to show you. I don't think the bulb preset synch button is working. The logs aren't throwing an error (they're confirming that the synch is initiated) but an actual sync to other bulbs is not occurring. I am familiar with how this works from the effects sync and this is not working following the same steps. Let me know if there's something else I can get you besides "it's not working".

I noticed that it doesn't seem to be hesitating when I slide to sync and click save. When you do this on effects, there's a slight delay (because it's doing all the copying). When you synch the presets, the page refreshes way too fast for it to be doing what it's supposed to be doing on the back end.

Just tested on my system and it worked as expected (Using current released code in HPM). I also verified that the code is the same in the test app/driver I provided you for the three methods involved.

Some comments:

  1. Speed is very fast when compared to effect syncing. To sync the LARGE effect state, I had to break it up into individual effects and transfer one at a time - a lot of processing.
  2. Bulb Preset Sync works only on like devices (i.e., light strips only when done from a light strip, color bulbs only when done from a color bulb). The message is a bit confusing (generic) and should state "with all Kasa Light Strips" or "with all Kasa Color Bulbs" (future change).
  3. You must refresh the browser page for the state variables to update on the target devices (the ones getting the new sync data).

Added testing. Turn on debug logging in the App and on the source and target devices and try again. This will confirm where the problem is occurring.

that makes so much sense. I will do that now

I did all the above testing. It seems like the receiving strip is not receiving the info from the logs. Through this exercise, I determined that my previous testing would've had a device page refresh after the synch every time because I was only using 1 device tab at a time (so exiting the parent device and entering the child device after the synch and save).

I took lots of pics on my trip. I compared the driver versions on the devices and everything checks out. it's just not going :no_mouth:




Can not duplicate. Below are my logs showing the data is passing to other devices IAW specification:

That being said, check the code in the Light Switch driver. Below are the two methods I use - make sure they are the same.

def syncBulbPresets() {
	device.updateSetting("syncBulbs", [type:"bool", value: false])
	parent.syncBulbPresets(state.bulbPresets, type())
	return "Synching Bulb Presets with all Kasa Bulbs."
}

def updatePresets(bulbPresets) {
	logDebug("updatePresets: Preset Bulb Data: ${bulbPresets}.")
	state.bulbPresets = bulbPresets
}

Ok, so maybe there's some sort of delay?

Since you replied, I started spot checking my other strips and they have the presets now (I noticed each of them started working under their current webcore settings).

I added a new strip, no presets as expected. Synced the presets and they went to the new light strip fine.

I dont know how to explain this but I went through this several times on multiple strips this morning and they weren't picking up the presets. Maybe it's just because of the volume (41 strips)? We very clearly were not seeing the presets picked up in child device logs.

Now they all seem to have it. I'm sorry to have sent you on a wild goose chase.

Now, back to the matter at hand, re-routing everything to presets in webcore vs the CT which appear to be giving me some blooming.

Edit:
I have done the subsequent testing. Using set presets via webcore appears to be giving me a really smooth, sexy, and stable experience.

The downside is the ungrouping of all my devices in webcore to get this functionality to work. This is a me and webcore problem and I'm SURE there is a workable solution somewhere.

With that said, with the rock solid stability of using presets, I'm probably going to abandon trying to RGB convert my way through the table (because of the blooming effects). I'll tinker a little deeper with the presets until I get them just how I want them (right now they were reviewed/configured in an hour). I know if I take my time with it, I can get a closer match than what I have now.

In the meantime, I'll look to make sure I'm not missing something in webcore because it seems weird that I only get this functionality when the devices are not in an array.

1 Like

I did some more review and here's what I found:

The TP LINK in app definition of Warm White matches navajowhite #FFDEAD rgb(255,222,173). I tuned my preset for Warm White to set level 25 because I can't think of a circumstance where Warm White would need to be greater than that.

The TP Link in app definition of White matches white #FFFFFF rgb(255,255,255). I tuned my preset for White to set level 50 because this is optimal for my house during the hours when the White preset would be used.

The TP Link in app definition of Cool White doesn't match anything in the White color code - RGB white color color chart but I was able to find it with some trial/error. The RGB is 228,250,255. I tuned my preset for Cool White to set level 50 because this is optimal for my house during hours when Cool White would be used.

I couldn't find an exact match for Soft White but I found 250,230,225 gets very close. I tuned my preset for Soft White to set level 25 because that is optimal for my house during hours when soft white will be used.

For Daylight White, I found 231,250,255 is very close. I set this level to 50 percent in my presets. But in reality, the difference is so minimal, I'd just use the 255,255,255 White for daylight instead.

1 Like

I see earlier in 2020 that the EP10 outlet was supported. Did something change? I got a couple of these and they show up in the installer window, but don't show up.

In the log this is what I get:

"failed to install device, Device: E848B8DDA65 alias=Bedroom Fan, model=EP10(, type=Kasa Plug Switch, deviceId=800627274D94936F6FDABA94804F91A01E6E2077, dni=E848B8DDA65F}

All other Kasa work great!

Did you install the plug-switch driver? Also, need the App version you are using (since you truncated the message.

1 Like

I'm an idiot -.- for some reason I thought the HPM auto-installed as it pulled the multi-plug in. Manually installed the driver and it works fine. Jumped the gun here. Thank you!

1 Like

I just wanted to circle back here and give you an update:

I got the variable groupings in Webcore to push the effect set and the preset set functions and I am successfully relying on nothing but presets to drive the daily light cycles and everything looks/works great.

The only thing left unresolved is the CT Table for the big 5 Alexa whites. Do we reconfigure them or leave them as is?
Most of my lighting will be driven through the automations so using alexa to make the lights daylight would be more of a one off (because in theory they'd already be on).

Here is my suggested tweaking:
Cool White: CT = 7000 The RGB is 228,250,255
Daylight White: CT = 5500 The RGB is 231,250,255
White: CT = 5000 The RGB is 255,255,255
Soft White: CT = 2700 The RGB is 250,230,225
Warm White: CT = 2200 The RGB is 255,222,173

I've been running these for a couple days now and the colors are appropriate. At this point, I think I'm going to defer to you on the next steps (whether you want to tweak the CT table or not).

It's been a pleasure working with you here and you've eliminated every problem I had and expanded the horizons of functionality. I'll gladly continue to provide support/logs/validation in the TP Link ecosystem anytime in the future. Thank you.

I enjoyed the challenge and the support. Thanks.
Dave

I just upgraded from a c4 to a c7 yesterday.. The c4 had an older version (6.3.0.1) of the app / drivers installed and it was able to see all my switches.. For some reason when I select "Install devices" on the c7 with v6.4.0... it says zero available.. I only have regular light switches and a couple of dimmers, both "plug" and "dimmer" drivers are installed.. I can see all the switches on the network and in the kasa app, I am not sure were to look to fix it.. Is it possible to manually add a switch based on the IP? it was able to find 26 of the 38 switches I have installed, I have reran the install devices multiple times over and kept getting a few each time, but since it has just stopped. is there anything I can check?