TP-Link/Kasa Bulbs and Plugs Control

dth_wallswitch
dth_smartbulb
dth_lighting
dth_pocketsocket
dth_outlet

#467

Good deal. Glad to help out anyway I can. I did check my firmware version and it’s 1.2.5.


#468

Wow do I feel dumb. This is why you shouldn’t look at stuff like this so late at night. Didn’t even think to remove three zeros from the portion of the equation inside the parenthesis.


(Dave Gutheinz) #469

I know the feeling.


#470

I’m wondering why Kasa gives me a different value for Total and Daily over 30 days vs the device handler. Current and past 7 day numbers are the same in both.


(Dave Gutheinz) #471

I can check it out on my simulator.

  1. First, what model are you using (HS110(US), HS110(AU), etc).
  2. Second, what are the current reading for each?

Also, on the phone app, go to the preferences page (the gear at top left). Select Save. This will rerun the calculation and may correct a temporary problem.

UPDATE.
Just ran my simulator (basically random values for 31 days) and the results were as expected: Total for 31 days minus todays use. Then this divided by 30.

One other question: when did you put the device into service?? if less than a month ago, that could account for the differences. I use the actual number of days in the return messages as a divisor, which might be less than 30. Perhaps TP-Link uses 30 all the time.


#472

Running US version. Put in service back in December. I tried the save function to rerun. Still shows the same.

30 Day Total per Handler is 290kWh, per Kasa 219. Daily Avg is 6.92 and 7.31 respectively. Odd but it seems like those daily averages would be reversed. I’m going to reload your undated handler. I wonder if when I was trying fix the math round I fat fingered something.


(Dave Gutheinz) #473

If reload does not fix the mis-match, I would like some data.

Open the editor and add the following between lines 279 and 280
log.debug “COPY FOR DAVE ${dayList}”

so the file looks like:

def engrStatsResponse(cmdResponse) {
	def dayList = cmdResponse["emeter"]["get_daystat"].day_list
        log.debug log.debug "COPY FOR DAVE ${dayList}"
	if (!dayList[0]) {
		log.info "$device.name $device.label: Month has no energy data."
		return
	}
	def monTotEnergy = state.monTotEnergy

Then open live logging and capture the two lines of data from the debug and paste to a reply.


#475

Sorry. Kinda new to this. How will I know what lines you want? Nothing came across live logging immediately.

The only thing I see with a debug header is"getChildDevices(false), children=1" and “getChildDevices(false), children=0”


(Dave Gutheinz) #476

Sorry, after loading live logging, go to the phone app, open the device, and then open preferences (the gear)… Select save. That will cause the energy monitor statistics to re-run and the debug statements will log two messages coming from your device (So I can manually total.).

I will also need the displayed numbers for energy stats from SmartThings and from Kasa. I will be manually adding the numbers to try to figure what is going on.

Dave


#477

Hope I did this right :slight_smile:

4:22:38 PM: error java.lang.NullPointerException: Cannot get property ‘COPY FOR DAVE [[month:2, year:2018, day:1, energy:9.511000], [month:2, year:2018, day:2, energy:9.292000], [month:2, year:2018, day:3, energy:10.375000], [month:2, year:2018, day:4, energy:3.080000], [month:2, year:2018, day:5, energy:3.021000], [month:2, year:2018, day:6, energy:8.607000], [month:2, year:2018, day:7, energy:3.700000], [month:2, year:2018, day:8, energy:9.815000], [month:2, year:2018, day:9, energy:10.600000], [month:2, year:2018, day:10, energy:12.757000], [month:2, year:2018, day:11, energy:12.856000], [month:2, year:2018, day:12, energy:13.695000], [month:2, year:2018, day:13, energy:9.331000]]’ on null object @line 280 (engrStatsResponse)
4:22:38 PM: debug physicalgraph.device.DeviceTypeExecutorBase$_closure2@45dfb1f8
4:22:37 PM: info HS110(US) Dehumidifier: Updated Usage Today to 9.3
4:22:32 PM: info HS110(US) Dehumidifier: Power: on
4:22:30 PM: info HS110(US) Dehumidifier: Date set to [min:22, err_code:0, wday:2, sec:30, mday:13, month:2, year:2018, hour:16]
4:22:30 PM: info Refresh Scheduled for every 5 minutes


(Dave Gutheinz) #478

There was an error. The second line should read

   log.debug "COPY FOR DAVE ${dayList}"

I think you followed what I said and put it in twice. Also, it is case sensitive (especially “dayList”)

I need the month 1 and 2 data.


#479

7:55:40 PM: info HS110(US) Dehumidifier: Update 7 and 30 day energy consumption statistics
7:55:40 PM: debug COPY FOR DAVE [[month:1, year:2018, day:1, energy:2.906000], [month:1, year:2018, day:2, energy:12.168000], [month:1, year:2018, day:3, energy:8.199000], [month:1, year:2018, day:4, energy:10.840000], [month:1, year:2018, day:5, energy:9.476000], [month:1, year:2018, day:6, energy:8.361000], [month:1, year:2018, day:7, energy:5.350000], [month:1, year:2018, day:8, energy:10.619000], [month:1, year:2018, day:9, energy:3.366000], [month:1, year:2018, day:10, energy:0.023000], [month:1, year:2018, day:11, energy:0.024000], [month:1, year:2018, day:12, energy:0.024000], [month:1, year:2018, day:13, energy:0.023000], [month:1, year:2018, day:14, energy:5.836000], [month:1, year:2018, day:15, energy:9.494000], [month:1, year:2018, day:16, energy:0.023000], [month:1, year:2018, day:17, energy:6.562000], [month:1, year:2018, day:18, energy:11.374000], [month:1, year:2018, day:19, energy:0.344000], [month:1, year:2018, day:20, energy:12.940000], [month:1, year:2018, day:21, energy:12.423000], [month:1, year:2018, day:22, energy:12.810000], [month:1, year:2018, day:23, energy:12.900000], [month:1, year:2018, day:24, energy:12.123000], [month:1, year:2018, day:25, energy:1.827000], [month:1, year:2018, day:26, energy:5.138000], [month:1, year:2018, day:27, energy:0.464000], [month:1, year:2018, day:28, energy:6.943000], [month:1, year:2018, day:29, energy:0.021000], [month:1, year:2018, day:30, energy:9.733000], [month:1, year:2018, day:31, energy:4.598000]]
7:55:36 PM: info HS110(US) Dehumidifier: Update 7 and 30 day energy consumption statistics
7:55:36 PM: debug COPY FOR DAVE [[month:2, year:2018, day:1, energy:9.511000], [month:2, year:2018, day:2, energy:9.292000], [month:2, year:2018, day:3, energy:10.375000], [month:2, year:2018, day:4, energy:3.080000], [month:2, year:2018, day:5, energy:3.021000], [month:2, year:2018, day:6, energy:8.607000], [month:2, year:2018, day:7, energy:3.700000], [month:2, year:2018, day:8, energy:9.815000], [month:2, year:2018, day:9, energy:10.600000], [month:2, year:2018, day:10, energy:12.757000], [month:2, year:2018, day:11, energy:12.856000], [month:2, year:2018, day:12, energy:13.695000], [month:2, year:2018, day:13, energy:11.339000]]
7:55:35 PM: info HS110(US) Dehumidifier: Updated Usage Today to 11.3
7:55:32 PM: info HS110(US) Dehumidifier: Updated CurrentPower to 560.65
38b86d19-0ac0-4abe-ab67-93ec2b19e0ad 7:55:30 PM: info HS110(US) Dehumidifier: Power: on
7:55:28 PM: info HS110(US) Dehumidifier: Date set to [min:55, err_code:0, wday:2, sec:28, mday:13, month:2, year:2018, hour:19]
7:55:28 PM: info Refresh Scheduled for every 5 minutes

Handler Stats:30 Day Total 304.24kWh 30 Day Avg 7.08kWh 7 Day Total 72.03kWh 7 Day Avg 10.29
Kaza Stats:30 Day Total 233kWh 30 Day Avg 7.76kWh 7 Day Total 72kWh 7 Day Avg 10.3


(Dave Gutheinz) #480

Will check today sometime. Thanks for the input.

Will fix algorithm. I believe that they changed the number of days for the previous month. Previous month message was a total of 31 days for both months (same as for bulbs). Now the previous month is fully populated (every day) (no longer the same as bulbs).

Fix today or tomorrow.


(Jon) #481

Hi @Gutheinz, I’m looking for GitHub Repository Integration details (ie owner/name/branch). Have I missed it or is this not available for your DH/App?

Thanks :slight_smile:


(Dave Gutheinz) #482

I do not typically do this. Just the link at the top.


(Jon) #483

Ah no problem, I guess it’s just a one click update for me when you change stuff with Github access (being lazy!) Thanks for replying though!!


(Sandy) #484

Hello!

I had to reinstall a tp bulb.Now i am getting an error_code:-20571 after i try to add the devices in ST.

Please help


(Dave Gutheinz) #485

Sandy,

The error is coming from the TP-Link site. There are two main causes:

  1. The device is turned off. Kind of obvious, so probably not your error.

  2. The device is not on the local WiFi. Check - can you control the device via the Kasa App? If not, correct this and try again.

If neither of the above is true, are you able to control other devices (or is this your only device)?


(Dave Gutheinz) #486

I have updated the calculations to handle the case where the device maintains more than 31 days of stats. The calculations match for the Bulbs, so that will be the baseline.

What is calculated:
30 day total is total of the previous (up to) 30 days of statistics (does not include today which is changing)
30 day average is above divided by number of records total (up to 30).
7 day total is previous (up to) 7 days…


#487

That did the trick. Thanks so much for you time and effort.