[DEPRECATED] Kasa Plug, Switch, and Bulb integration

Updated TP-Link Engr Mon Plug and TP-Link Engr Mon Multi-Plug drivers.

The update applies only to the Energy Monitor plugs. The drivers have been updated to correct for a device issue where the device's internal date/time may be incorrect if the device is not bound to the Kasa Cloud.

Update Instructions:

  • Open driver code.
  • Use import function to import the new code. Save
  • Open each affected device's page.
  • Complete a Save Preferences (which will update the device's time if incorrect).

What is new:

  1. Added processing to compare the devices time to internet time at the location.
  2. If the year, month, and date are not the same: Update the device's time to the current time down to the second level.
  3. Changed method of getting time for energy statistic functions.

Issues. None. However, this is a new capability and not tested on the HS110. Error probability is low.

1 Like

Brilliant work! The new driver has now updated the device time (HS110), the error messages in the log are gone and I'm now getting power usage reported in the logs :slight_smile: Thanks for making this change to the driver!

1 Like

My pleasure. I learned a lot doing it.

2 Likes

Back on the question whether or not to have Alexa directly control your TP-Link devices or work via Hubitat--

The biggest reason I disabled the TP-Link skill in Alexa and now expose the devices to Alexa only through through the Alexa - Hubitat integration is to keep the device state in better sync with Hubitat. When I was using the TP-Link skill in Alexa and I'd issue a voice command, Alexa would change the state of a device, but Hubitat wouldn't be aware of the change until it's refresh time rolled around again. Since I don't change the state of these devices by pushing device buttons very often then by always using Hubitat to control the device, the device's state is always correct in Hubitat. As a result I can safely lengthen the times between refreshes or even turn off the periodic refresh for many devices.

1 Like

I totally forgot about that. I set my refresh to 30 minutes as well.

Hey Dave, a couple of ideas as you continue to wrestle with the best way to give users granular insight into moment by moment power consumption while keeping the hub load as low as possible:

I think a dynamic polling rate would be very helpful. When the power consumption is below a certain threshold (the vast majority if the time), it isn't very interesting and a low polling frequency works great. However, once power consumption climbs, some of my automation use cases start looking for changes to the power curve that may be too subtle or too shortly lived for a low polling frequency to reliably detect.

While one could allow setting a threshold in the preferences of the driver and let the driver manage it, a solution that I think would create much less support headaches and be easier and probably be more useful would be to simply create a custom command that could change the polling frequency. A similar command (or could be the same command with different arguments) would disengage "fast polling" and return it to the baseline frequency. Ideally, when adjusting the polling frequency a timeout period could be provided (with a suitable default in its absence) after which the polling frequency would automatically be returned to its baseline.

That would allow one to create a rule that detects the circumstances that make higher frequency polling useful and engage them. While increased power consumption is the hallmark of when it gets interesting to me, there are always additional criteria of which I could, for example, make a rule aware and only trigger the faster polling when needed. The rule engine could then also disengage the faster polling as appropriate. If the rule crashes or one forgets, the timeout wouldn't let the high frequency poll continue forever.

You also mentioned that you were thinking about rounding the energy readings to decrease the impact of energy monitoring and that you were interested in feedback from the user base. I think your idea was that by "bucketizing" power, one would increase the frequency with which a reading was the same as the previous reading, thus decreasing how often it is necessary to announce power changes, each of which the hub has to propagate up through the system?

I think rounding the readings is a great idea and I don't see how it would adversely impact my situation at all. Extending the idea, I think it would be great if instead of say, rounding to the nearest 5, the end user could actually declare ranges of readings that could all be put into the same bucket and registered as the same reading (that might be extending the idea to the point of being ridiculous... But I'd use it!).

Thanks!

2 Likes

I was thinking along the same line (expose a command to turn on and off quick polling with a value. Leaving it blank or setting it to zero would turn off the quick polling.

I also want to impose a 5 second minimum for quick polling. Below that, you can get into conflicts with other activities. Comments?

Dave

Love it. 5 seconds is plenty fast enough for me.

1 Like

VERSION 5.0 Update now available. Major changes:

  • Now have Wiki page that can be accessed as help from the application.
  • Move quick polling to command so users can turn on/off using the rule machine.
  • Various edits and file format improvements

Wiki Page: Home Ā· DaveGut/Hubitat-TP-Link-Integration Wiki Ā· GitHub

Instructions for Update and installation are on the Wiki page. As usual, If it ain't broke don't fix it..
David

5 Likes

This is a great feature which reduces the load on the hub. Iā€™m using this for monitoring my dishwasher, washing machine and dryer. Since they all run for longer than 1 hour I have set the plugs to only report power usage every 30 minutes. If power usage is detected then RM changes the polling to every 45 seconds instead and when power usage has ceased it sets the fast polling to 0 again. Thanks Dave for implementing this feature!

3 Likes

Any chance you can share your rule for this? I am now finally moving my last rule from ST, and this will be very helpful.

I have moved across my plugs, but don't know what settings I should use to make sure the power changes are picked up quickly - without bogging down the system.

The rule I'm using looks like this:

You will need to experiment with the power levels. It all varies from appliance to appliance and how they behave during their cycle. For instance, if the appliance has a period of non-activity somewhere in the middle of the program, you would have to account for that in the rule as well otherwise the rule would potentially declare the cycle finished before it actually has.

1 Like

If I set the poll frequency to 60 seconds, should this then be reflected in the State Variables section for pollFreq ? For me, after I enter a polling frequency and select Save Preferences, it shows 0 as the value, where I thought it would show 60.

image

Thanks for sharing, and the info provided

The state variables do not update on the browser display unless you do a refresh. First guess.

Dave

I have done the refresh and it just keeps showing 0 for the value?? I should have stated that the picture used above was just showing where I entered the value.

Refresh the webpage, not refresh the device.

Works for me.

1 Like

No, that doesn't work for me. Still shows the pollFreq as 0. Not sure what to do??

let me check the code tomorrow. I do not have a HS110 (I tested on the HS300 which I do have).

Thanks @djgutheinz, that would be much appreciated.