[DEPRECATED] Kasa Plug, Switch, and Bulb integration

Update to Version 6.2.0 Available.

Address Hub version 2.2.6 changes plus other "improvements" (see below).

Upgrade instructions:

  • replace drivers and application

  • run application and Update Device Data

  • Check each device verifying pollInterval and preferences.

  • Changes"

  • App:

    • Added coordinate method to support multi-plug outlet data/state coordination.
    • Cleaned up page displayed documentation.
  • Drivers:

    • General cleanup of installed and updated methods.
    • Updated scheduling to disperse methods better and reduce device collissions.
    • Clean-up of new reboot, setCommsType (LAN/Cloud), bind, and ledOn/Off methods and information.
    • Added attribute for communications error.
    • EM Devices: Update on and off to delay power request to get a valid power attribute.
    • Multi-Plugs:
      • Coordinate methods/attributes for setCommsType, Bind, pollInterval (on/off). Includes new method in driver and app for coordination.
      • Coordinate of polling command so that only one Hubitat device does an on/off poll of the Multi-Plug device. Includes new method in driver and app for coordination.
    • Hubitat 2.2.6:
      • Fixed zero length response in parse method string causing error message.
      • Bulbs: Accommodate changes in Capability Color Temperature
      • Bulbs: Temporary fix for above for when entering data from Device's edit page causing error.

GOOD LUCK.

4 Likes

I do seem to still see the -8 error in the logs. I updated the driver through hpm and have tried clicking save preferences and save device on some of the plugs but the warning still appears. Any ideas or was there something I missed?

Thanks

I too am getting errors. It's not a problem. We love the work you do @djgutheinz.

It's the " Invalid or incomplete return.
error = java.lang.StringIndexOutOfBoundsException: String index out of range: -8"

1 Like

Yeah, only appreciation from me on the efforts by Dave, I have started writing drivers for others myself so can appreciate the efforts that can go into that.

1 Like

What device / driver are you using. Can you give me some logs using:

  • turn on debug logging and save preferences
  • Then open the log page.
  • Do a simple REFRESH. Wait 1 minute and do another REFRESH
  • PM me the log. We may have to do some test code.

Since the error reflects a null return message, the simple solution is in the code change identified below:

def prepResponse(response) {
	def resp
	try {
		resp = parseJson(inputXOR(response))
	} catch (e) {
//	Mark Out This Line
//		resp = ["error": "Invalid or incomplete return. Error = ${e}"]
//
	}
	distResp(resp)
	unschedule(handleCommsError)
}

I am at a loss here. I updated all of mine using HPM at about 2:40 PM my time. Below is a typical past log. It is true for all 21 devices as well which cover 7 of the 8 drivers (no dimming switch).

Below is a typical log (for a bulb here). Same for all. Note that as version go to 6.2, the error stops.

Don't stress Dave, I'll play around with it some more in the next day or two, but am at work now, so will probably be another 10 hours or so before I can look at it again, or if anyone else can take a look and help out....

I have HS110's and am using the EM driver. I think I tried a refresh as well this morning, but not a second, and may be I didn't wait long enough...

I can also play around with the code as well...

1 Like

Update 6.2.1 available. Update procedures:

  • Install update for all drivers
  • Run app
  • Select Update Installed Devices
    • Note that when you do this, the app updates base data plus executes method updated on each child device.
  • Test as you see fit

Intended fixes:

  • HS210 on/off command error
  • null/zero length response processing.
1 Like

Dave, I just updated and still get errors. It's the-8 error.

I had the same, but just realised my device driver code for the em plug doesn't seem to be up to date, still showing 5.3.3 in the comments at the top of the driver, even though hpm said it updated it.

Will try updating the driver manually.

Check top make sure you don’t have two copies of the driver. I’ve seen a couple of instances where the update installed a new copy of the driver/app instead of replacing it.

1 Like

Looks like I only had one copy of the driver, so not sure what was happening with hpm...

Updated it the old-fashioned way by copying the raw code from github and pasting it into the driver code. I think it may be ok now, will continue to monitor the logs, etc.

Needed to Save Preferences on one of the em plug devices that was putting out a bunch of info logs and a NullPointer error, and set the poll interval and power interval to 1 minute. Suspect I may have previously had some logging turned on and it may have just needed to run another method to get an attribute created or updated, plus get the logging settings adjusted....

All the power poll intervals were reset to 30 mins, potentially an update from an earlier change to the driver... I have needed to run the setPowerPoll command and click Save Device to change it on each device. But so far they seem to be working ok.

need to add back state.errorCount = 0 in prepResponse @djgutheinz

or in distResp,

if (state.communicationsError || state.errorCout ) {
resetCommsError()
}

otherwise, the errorCount keep growing.

I seem to now get Info logs for some (maybe all) my plugs on a change in the power reading having changed. Any way to turn these off?

I would turn of information logging in the preferences section. All attribute changes are logged elsewhere - so these are not necessary. (I already require a change of 1 watt or greater before updating the value - to avoid excessive events. Do I need to increase to 2 watts?)

I could not carry over that value in the new interface. I should have stated in the changes. How it now works is similar to previously, but explicitly:

  • Power Poll and On/Off poll are independent.
  • Only one can be 30 sec and below at a time.
  • If you attempt to change, a log entry appears telling you what to do.

I had the same issue with HPM one time. Lost several drivers in my operational hub. (see the release notes on the lastest HPM update). I corrected this by:

  • renamed the manually installed driver(s) (added a TEMP in front of the name in metadata)
  • went to HPM and modified the installation to re-add the driver(s)
  • went into each device and changed the type to the added driver(s)
  • tested
  • deleted the temporary driver(s)

Dave

1 Like

Thanks for the information. Version 6.2.2 is now available with fix.

Version 6.2.2 Available

Fixes state.errorCount to properly reset to zero.

Thanks to @Chen555 for the catch.

1 Like

made some minor change, and now with 5 seconds poll, total cpu is only about 0.1% per device
(one is HS200, and another is HS210)
(

HS200 does not close connection immediately (i have two, and tested many times)

Also with 5 seconds refreshing, the connection is always valid, so skip the handleCommsError,
and socketStatus (which is called automatically by the system)