[DEPRECATED] Kasa Plug, Switch, and Bulb integration

@djgutheinz I am not good. The cloud doesn’t seem to work correctly and I had to revert to the deprecated cloud drivers. This was only for my colored bulbs. All switches worked without issues.

Issues by just changing code:

  • lost all color control
  • lost circadian
  • lost level control

Devices would show ok and no error in logs. Just won’t work like expected. I did not try to delete the devices and re-add them (yet!). But if I go that route I am moving to local execution with your JSon script.

Any thoughts or suggestions?

Thanks for the heads-up. I checked this AM. Color has to be fixed since GitHub added a Color Selector in the device vice manual hue - saturation entry. Good feature. Just need to fix.

All the other are confirmed to work OK. (Hub or cloud should not make a difference.) Will fix driver and post back when done (hours or less, not days).

1 Like

Just did a full check using the Devices from the Devices Tab against my LB-130 with both Hub and Cloud installation. All worked OK. Note that the design sends the same command to the bulb either via the node applet or Kasa cloud.

I did update the color Driver on GitHub to set the default hue to low resolution. You might want to try that one instead - just in case something is weird.

Some items:

Color. When Hubitat implemented the Color selector, they use the LowRezHue mode. Go to preferences and set lowRezHue.

Color. The default display from GitHub showed an invalid hue/saturation. I had to select a color to update to valid(?????).

SetCircadian - it only sets circadian mode. To leave circadian, do any other function (off-on, level, colorTemp).

Color Temp. Range is 2500 to 9000 for the LB130.

What model bulb do you have. Would be nice to see logs - even if they do not show errors. The logs show the state returned from the bulb.

Dave

Very interesting results. After setting the LowRezHue to lowRezHue the color comes out correctly but now I see another bug with "color name." You will see below that the hue selector I used is green but the color name is orange?? Also the Set Level does nothing.

will fix color name when I get back. Assume you have an LB230.

Set level:
100 percetn

50 percent

I am using both LB230 and LB130.

Believe color naming is fixed in the test code sub-directory on GitHub:

TP-Link Color Bulb (TEST).groovy

This also logs some data for Level so I can figure out what is going on. Need you to use live logging and try to set level. Then provide logs in reply message (and if it works). Will allow me to find out what is going on.

Alright...I installed the (Test) version. Color naming still is not working correctly and cannot change level. I am not exactly sure why either. When I set it to blue the color name is yellow. But if I set it to hot pink or red it shows up as Chartreuse.

Updated test code. Instructions

After replacing, go to the devices page and select save preferences (do not have to set any).

Turn on logging again and test the code. Please reply here in any case.

(If you have a problem with setting the level, try setting the Transition Time preference. If this fixes, again, please tell me. I tested on my bulb; however, I already had a transition time set, so I can not replicate the null condition.)

Fixes:

  1. Save Preferences will look for a null transTime. If null, will set default to zero.
  2. Updated the transition time input from milliseconds to seconds (to match Hubitat device page scale).
  3. Added Level to color map settings (again to match Hubitat device page color entry).
  4. Fixed lowRezHue hue calculation to correct color naming problem.

dave

@djgutheinz

Ok so we are making progress? Maybe?

What works:

  • Turn off the bulb
  • Set Color Temp
  • Set Color (after you get the bulb to light up)
  • Color Name is correct
  • Set Circadian

What doesn't work:

  • Can't turn on bulb
  • Can't set level

Logs:

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:59.199 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 10% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:65, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:59.197 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Blue

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:59.193 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.411 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 50% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:65, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.410 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Blue

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.409 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.364 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 50% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:65, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.357 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Blue

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:52.344 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:42.350 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 100% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:65, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:42.349 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Blue

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:42.337 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:35.841 am [error](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Entered hue or saturation out of range!

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.803 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 12% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.797 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Red

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.793 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.297 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 12% / Circadian Mode: normal / Color Temp: 3000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.293 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Soft White

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.291 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.262 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 12% / Circadian Mode: normal / Color Temp: 3000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.254 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Soft White

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:30.252 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.680 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 12% / Circadian Mode: normal / Color Temp: 3000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.678 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Soft White

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.672 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.654 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 12% / Circadian Mode: normal / Color Temp: 3000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.652 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Soft White

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:29.650 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:09.082 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 12% / Circadian Mode: normal / Color Temp: 4000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:09.079 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Moonlight

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:09.075 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:04.186 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 12% / Circadian Mode: normal / Color Temp: 4000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:04.185 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Moonlight

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:04.183 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:03.610 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 12% / Circadian Mode: normal / Color Temp: 4000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:03.604 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Moonlight

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:51:03.585 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:40.120 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 12% / Circadian Mode: normal / Color Temp: 4000K / Color: [hue:0, saturation:0]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:40.116 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Moonlight

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:40.113 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is CT

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:37.658 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left Hue Scale set to lowRez

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:37.652 am [info](http://10.0.2.38/device/edit/272)Light Transition Time for LB230(E26) Fireplace - Left set to 1500 seconds

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:37.650 am [info](http://10.0.2.38/device/edit/272)Light Transition Time for LB230(E26) Fireplace - Left set to 0 seconds

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:37.565 am [info](http://10.0.2.38/device/edit/272)Updating Fireplace - Left...

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:11.635 am [error](http://10.0.2.38/device/edit/272)java.lang.NullPointerException: Cannot invoke method toInteger() on null object on line 119 (on)

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 08:50:08.093 am [error](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Entered hue or saturation out of range!

in preferences, try setting the transition time to 1 second. (I noted in your sequence a transition time of 1500 seconds. That would preclude level and on off (take 25 minutes to complete). I will add to code to look for legacy transition times and convert to nearest second.

Sure enough that was it! It is working accordingly. No issues either. Would be nice to have drop down selection verses entering a number. Example: 1.5 does not work. Causes an error. Let me know when you go gold with this driver and I will update accordingly.

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:40.517 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 50% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:60, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:40.515 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Azure

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:40.514 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:29.069 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 50% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:60, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:29.068 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Azure

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:29.063 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:20.382 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 100% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:60, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:20.379 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Azure

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:20.377 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:09.193 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 100% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:60, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:09.191 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Azure

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:56:09.190 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:52.861 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: on / Brightness: 75% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:95, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:52.858 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Rose

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:52.856 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:49.470 am [info](http://10.0.2.38/device/edit/272)LB230(E26) Fireplace - Left: Power: off / Brightness: 75% / Circadian Mode: normal / Color Temp: 0K / Color: [hue:95, saturation:100]

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:49.469 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left color is Rose

[dev:272](http://10.0.2.38/logs#dev272)2018-11-29 11:55:49.467 am [info](http://10.0.2.38/device/edit/272)Fireplace - Left Color Mode is RGB

Hi,

Just installed this code to work with my HS100 plugs but I seem to have a problem. I installed the app no problem and then added the one plug I had which shows up as a device. I can control this plug no issues.

I have then added another 2 plugs to the Kasa app and they show up fine. When I go in to the App in Hubitat to add the two new plugs, the new plugs show up in the drop down and I can select the plugs. However when I click "Done" a very quick error message (Unexpected Error) appears momentarily and tells me to check the logs. When I check the logs the only events showing are all " [info] TpLinkToken updated to...".

In the Status window for the device I can see the two new plugs/devices in the "devices" metadata.

I don't know where else to look or check and I don't seem to be able to increase the logging level either.

Any ideas?

G

UPDATE:
I decided to delete the App and re-install it. This time all three plugs were available to select and all three added fine (though I did still get the Unexpected Error message). So it seems that you can add the plugs once when you install the app but you can't add additional plugs once it is installed.

Hubitat TP-Link/Kasa Manager it's v3.5 and was updated 24/11 by you (I think!)

Cheers

G

Still have not encountered the problem. I am testing carefully and will get back.

Thanks very much. Anything I can do to help?

I was wondering. When I added the account at the very beginning I only had one plug on it. This worked flawlessly. I then added the other two and couldn't add them through the app. When I deleted the app and re-added it all three plugs were there from the start. I'm wondering if it's a mismatch when you first add the account? i.e. the application can't add plugs unless they're there when you install/add the app.

It might explain why I could only add one plug initially and why it worked for all three when I deleted and reinstalled the app after I'd added all three plugs to Kasa.

G

I have been able to duplicate the momentary error (Unexpected Error). And while trying to find the problem, I started encountering the devices not adding. Do not know why. I am currently trying to capture the problem issues. We may just have to accept the Unexpected Error (if I can find why on the non-installation).

Dave

@djgutheinz

I am having refresh issues with the new parent/child app. Last night the TP-Link had a communication error with one of my outlet devices which resulted in my rule becoming false and the bedroom lights to go on at 2am while we were sleeping.

Any ideas what might be going on?

Inherited from the platform that shall not be named.

I have coded three potential states for plugs/bulbs: on, off, and offline. Offline is attained when a communications error is received from either the Application (Kasa Account) or the node.js applet. This allows the error to report to the android/IoT interface. Let me experiment and see how the dashboard handles this error. If it does nothing, then I will remove the off-line.

Otherwise: Any automation would have to account for all three. If you have a rule that does not account for this, then what you are seeing is possible.

Are you hub or cloud version? What explicit device is having a problem?

Note: When power is removed from a bulb and then restored (power failure or external switch), the bulb will recover in the on state. (This is true for my Zigbee and TP-Link bulbs). I assume this is to allow for a switched bulb to behave as a normal bulb when the switch is activated (off or on).