TP-Link/Kasa Bulbs and Plugs Control (Old, Unofficial Integration)

Jymbob,

Is your HS110 still working as expected in SmartThings? One user is having a problem and I need to confirm others are OK.

I have just been having a look at this, and it looks like I might be using different code, as my lines don’t line up with your reference.

The first one, energyMeterRespons is line 176, but line 177 is;

if (cmdResponse[“emeter”].err_code == -1) {
log.error “This DH Only Supports the HS110 plug”
sendEvent(name: “power”, value: powerConsumption, descriptionText: “Bulb is not a HS110”, isStateChange: true)
} else {

The 2nd one, useTodayResponse is line 195, and the 3rd one, currentDateRespons is line 292, but the code there did look like your reference.

I went ahead and injected the code into all 3 places it looked like you wanted.

I then closed the ST app, relaunched it, selected Dryer, Refresh Stats, Refresh. Here are those logs.

OK, I think I know the problem. Will update and get back to you after some testing. Plan on going to GitHub and pulling down a special version

one more quick test. About line 209 is the method useTodayResponse. Change the line that reads

if(engrData.day == state.dayToday)

to

if(engrData.day == state.dayToday**.toInteger()**)

so that it reads:

def useTodayResponse(cmdResponse) {
log.debug cmdResponse
	def engrToday
	def dayList = cmdResponse["smartlife.iot.common.emeter"]["get_daystat"].day_list
	for (int i = 0; i < dayList.size(); i++) {
		def engrData = dayList[i]
		if(engrData.day == state.dayToday**.toInteger()**) {
			engrToday = engrData.energy_wh/1000
		}
	}
	sendEvent(name: "engrToday", value: engrToday)
	log.info "$device.name $device.label: Updated Today's Usage to $engrToday"
}

I tried to make the change but got an error;

noticed that my code is different to yours.

You have;
def dayList = cmdResponse[“smartlife.iot.common.emeter”][“get_daystat”].day_list

I have;
def dayList = cmdResponse[“emeter”][“get_daystat”].day_list

Also, after that line, you have:
engrToday = engrData.energy_wh/1000

I have;
engrToday = Math.round(1000*engrData.energy) / 1000
Here are the new logs;

Take out the two stars in the line. The formatting in this blog added them.

The line should read:

if(engrData.day == state.dayToday.toInteger())

OOOPPPS

Take out the ==. It should only be a single =

Took out the 4 *, saved, then saw to remove the additional =, did that and tried to save, but another error;

STOP ALL WORK. The AU version of the device firmware has a different format for the energy consumption numbers in the baseline version (It may also impact the US Version).

I will correct and upload a special version with (AU) in front of the name. Message you when I do initial fixes.

Dave

Sorry for the hassle, glad you figured out where it is going wrong.

I have to run out for about 2 hours, but anytime after that, I can test whatever you need.

Thanks again for your help
and patience with a noob :slight_smile:

Dude, just wanted to say thanks
 implemented this a few mins ago
 install was smooth


Thanks


1 Like

I have installed in the Device Handler directory of the GitHub site (link at top of thread) the file:

AUS TEST HS110.groovy

This is my first attempt; however, since I do not have a device, it will be a miracle if it works the same.

Testing:
Open live logging.
On the IDE, replace the old file contents with the new (complete), save and publish.
On the phone App - see if it updated.
a. If not, press Refresh Stats and Refresh.
b. If it updated, compare value to those on the Kasa App. I may need to fine-tune.

If failed, send logs. If fixed perfectly, go bet on the lottery. We are lucky today.

What happened: The format of the AUS version data is different from the US Version. They went from watt with decimal values to milliwatts with no decimal. the internal label from the bulb went from “power” to “power_mw”. The problem with integers (the red error) may be transient; however, I used a conservative approach.

My testing: Tested the “.toInteger()” fix on the LB130 device handler and it worked (did not cause an error). However, it was already working OK.

Dave

OK, so I created a new DH, published and then selected it as the DH for the Dryer.
Opened the ST app but couldn’t see that it looked any different.
Started the Dryer, started live logging, pressed Refresh Status and Refresh. Nothing changed/showed in the app, still just blank fields.

Here are the logs;

PS. I can confirm that the ON/OFF function is working with this DH.

Errors I well understand. Fixed and on GitHub at same location, file name.

Had some label errors as I went through the code. After this, I will have to update the code on my next-release to account for the difference in code between AUS and the US/UK versions. At some point, I sort of expect the US/UK versions to change to the way done in your version.

Success! :slight_smile:

Current Power and Usage Today are now populating

I am not entirely sure if it is reporting exactly as the native Kasa App, but it is close. The one below was taken a couple of seconds before the ST one above.

But either way, it should be close enough for the webCoRE piston I have set up which triggers based on power usage being above 50w for 30 seconds, and then below 30w for 30 seconds.

I am more than happy to do whatever testing you want.

Sorry, forgot to include the logs

Remaining errors and a final logging for today are in the updated file on the GitHub server.

Would like another test with log data (if possible). Then I will finalize this version for you.

Thanks for the assist.

The App looks the same, here are the new logs.

On the phone app, run a Refresh Stat. Open the “Recently” tab. What do the top two lines say?

Dryer engr today is 2159
Dryer power is 0