Data Science of "On", "Off" and "Standby": II

Sometimes an investigation of an emerging issue forces one to shine a new light on older analyses and offers new insights. A while back, I tried to use Sense exported hourly data from my smartplugs to see how easy or hard it was to automatically determine “On”, “Off” and “Idle” modes of the device on that smartplug by automatically analyzing the hourly usage distributions. At that point in time, I rued not having more fine-grained time-series power data to work with.

A year or two later I have a new reason to revisit that analysis, as I attempt to diagnose different modes of communications failure between Sense and smartplugs. One of the things I have discovered during diagnosis is that there are 3 different visible “states” of a smartplug that all seem to result in no exported data for the time when the smartplug is one or more of those states for the entire hour:

  1. An actual connectivity issue, where Sense doesn’t seem to see a pre-existing smartplug on the network. In that situation the device appears in the “off” part of the device list with an “n/a” on the control button.

  1. When the smartplug is turned off via the Kasa/Sense On/Off button. In that case it is in the “off” part of the device list and the control button says “off”

  1. When the smartplug is using a very small amount of power (less than some critical threshold) and ends up in the “off” part of the list, but still “on” per the control button.

But small fluctuations in power can take that same device into the “on” part of the device list a couple minutes later, in the “Standby” state, where there is visible energy being used.

Pushing deeper, I tried to get a better idea of the threshold between “Off” and “Standby” states for a smartplug or DCM device in Sense. The threshold between “On” and “Standby” is fairly well defined, with a user adjustable power and time threshold. For “Off” and “Standby” not so much.

After setting alerts for all the transitions (“On”, “Off”, and “Standby”) on my Washing Machine HS110 (Washer), I was able to capture a bunch of “Off” to “Standby” and “Standby” to “Off” transitions like this one.

Looking more closely in the Device Power Meter, one can see that the source of the transitions and alerts was a 1W bump.

This time around I have a way of pulling 1 second resolution data from my HS110, so I can do a detailed comparison, though I’m starting with 4 sec resolution data, so I don’t hammer my network too hard. Here’s the a view of that “bump” in the raw 4 second sampling data from the same HS110 is feeding Sense. A detailed view (17:20 = 5:20PM).

And a broader view over time. Hard to see a bump in there.

If I look back over 50k power samples, once every 4 seconds for the past 2 1/3 days, including a Washing Machine washes, I can see some interesting distributions. Looking at the whole range of measurements, it is clear that the Washer spends most of its time in “Off” or “Standby”, but the load can get as large as 1000W or so.

If I push down into the part of the data that is 1W and less, it’s pretty clear that the measurements there are bimodal, either centered around a mode at 0.60W or one at 0.74W

Looking at the distribution above 1W (in histogram below) highlights a bunch of different modes. I’m guessing that the mode on the extreme right is 11 min (165 samples) worth of spin dry cycle.

2 Likes

Kevin, your work is beautiful. I love the detailed explanations and pictures that go with them! You may know the answer to a question in the back of my mind about the Kasa energy monitoring plugs. The question is: does Kasa report the “point in time” value when polled by Sense, or does it somehow report the “area under the curve” since the last time it was polled? This might make a difference in the total kWh energy usage number, especially when talking about values between 0 and 1 watt.

I have two devices that may shed light on this subject. The first is an ink-jet printer on an HS300. I leave the printer turned on 24-7 since it uses very little energy and so that it is ready at a moment’s notice. Using Excel’s FREQUENCY function, I created a poor-man’s histogram (below). I know Excel can also do real histograms, but this was quicker. It is based on 7½ months of Daily Export data.
Sense
I interpret this as follows: Baseline usage is 22 watts per day (smaller numbers are probably artifacts), but when pages are printed or scanned then the measurement becomes 23 or more watts. Since the daily totals are for 24 hours, I calculate actual baseline energy usage as 22w/24hr=0.9w, which is rounded by Sense and displayed as 1w of Always On.

The second device is my living room TV, which is on an HS110. When it is in standby, Sense sometimes displays 1w and other times 0w, but still “on” as Kevin describes above. Sense does not include anything for the TV under Always On. Most days the TV gets used at least once, so I only have 5 data points when it was off the whole day. Four of those say 0.017kWh while the fifth says 0.016kWh. Therefore, the actual usage of my TV in standby averages 17w/24hr=0.7 watt.

This data confirms that Sense is able to sum usage that is less than whole watts. I conclude that Kasa is reporting more detailed data to Sense behind the scenes, and that Sense math is based on the detailed data. Sense must round Kasa values to whole watts only for display purposes.

I have IOS devices so can only see “point in time” data in the Kasa app. Energy usage there is reported to two decimal places of a watt. Somebody said that the Android version of the Kasa app is better as it displays a live value under energy usage.

1 Like

Appreciate your thoughts and feedback @jefflayman ! I like the analysis you are doing on your “Always On” devices given the limited window we have into their behaviors. Sense does a great job simplifying how we look at them and their usage, but sometimes it is fun to peel back the layers.

Your “Poor Man’s Histogram” is great ! Seems like you are getting a very useful view out of yours - baseline plus range of typical power usage. Nice being able to correlate baseline usage with Always On for the printer. The real trick is picking the bin size / number correctly to reveal behaviors. Excel’s histogram capabilities surprised me the other day - I tried the histogram function on some of my data the other day and it auto-selected 7 bins, instead of the 24-30 I had been using (30 is the ggplot2 default, 24 is the hours in a day, but an hour is a very arbitrary unit if a behavior/distritbution isn’t tied tightly to a clock). 7 bins worked much better in telling me what was going on, than 24 or 30.

Kasa readings, and all typical AC power, current and voltage measurements have to be “area under the curve” measurements due to the nature of AC. I’m going borrow some “Theory of Operation” from the MAX71020 spec sheet - that’s the measurement chip inside the HS110.

The energy delivered by a power source into a load can be expressed as :

Screen Shot 2021-02-05 at 10.47.42 AM

That’s the area under the instantaneous Voltage (V) x Current (I) curve. A modern solid-state electricity meter IC such as the MAX71020 functions by emulating the integral operation above, i.e., it processes current and voltage samples through an ADC (Analog Digital Converter) at a constant frequency. As long as the ADC resolution is high enough and the sample frequency is beyond the harmonic range of interest, the current and voltage samples, multiplied with the time period of sampling yield an accurate quantity for the instantaneous energy. Summing the instantaneous energy quantities over time provides very accurate results for accumulated energy.

The following chart highlights why AC measurements use area under the curve. It shows sampled data for a simple resistive load at 50Hz (60Hz period would be 16.66667 ms).

The above figure shows the shapes of V(t), I(t), the instantaneous power and the accumulated energy resulting from 50 samples of the voltage and current signals over a period of 20ms. The application of 240V AC and 100A results in an accumulation of 480Ws (= 0.133Wh) over the 20ms period, as indicated by the accumulated power curve. The described sampling method works reliably, even in the presence of dynamic phase shift and harmonic distortion. After a sufficient number (typically 2520) of multiplexer frames have been collected, the MAX71020 issues an interrupt to the host using the INTZ pin, signalling that new energy values are available.

Basically, in default operation the MAX71020 delivers a new “under-the-curve” accumulated RMS power reading every second (2520 samples / 2520.6 samples per second).

When Sense or Duane’s utility sends out a broadcast asking all the HS110s on the local network for their “emeter” data, all those Kasa’s respond with the ASCII packet below. I emphasize ASCII because that implies that the HS110 does a bunch of stuff in the middle related to calibration, scaling and converting the data from binary to decimal.

{"emeter":{"get_realtime":{"current":0.028915,"voltage":120.798141,
"power":0.527563,"total":18.045000,"err_code":0}}}}

Kevin, I’m glad you like my histogram! I find that using the FREQUENCY function is more flexible than Excel histograms since I can manually choose each bin size. For example, my sump pump usage fits better if I simulate a logarithmic plot by using the following bins: 0, 0.01, 0.1, and 1. For the printer analysis above, the bin size of 0.001 kWh was easy to choose since that is the limit of resolution reported by Sense.

I hoped you might know the answer to my question about area under the curve, and you did! As a bonus to the answer, you gave me a very nice explanation to go along with it. You explained not just what but why! This sure improves my comprehension. Thank you!

Your explanation also confirms that 1-second is the native reporting interval for the chip inside the Kasa monitor. Thus if I see the Kasa app report values which change every second, it is because that is the measurement. They did not have to process smaller measurements to get that value, as the smaller measurements were all handled inside the chip.

I used my daughter’s phone to install the Android version of the Kasa app. I don’t see graphing capabilities in that app, but I created the graph below by typing as fast as I could. The app shows numbers which change every second, and I know my numeric keypad pretty well, although I’m sure I missed a few measurements. This chart is created in Excel based on my furious typing.
Kasa printer
You have obviously discovered some way to download Kasa data without manual typing. I don’t need the details on that, as my urge to see a graph was satisfied by the above image. I noticed two things while creating this. First, I saw variations of 0.01 so the Kasa app has resolution at least as fine as they report. Second, none of the printer values from the Kasa app were so low that they would round down in Sense. None of the TV values during this 1-minute sample were low enough to round down, either, but I believe they may vary over the long term because what I see in Sense for the TV is several hours at 0w followed by several hours at 1w. For the printer, I do see short periods of 2w usage when I zoom way in to the usage plot. Those probably correspond the the measurements above 1.5 watts in the graph above.

1 Like

Great job on the manual Kasa data collection. I don’t have any Android devices in my house except a couple of big screen TVs, so I use the utility described here - self-contained and very easy to use if you have java on a computer..

Just looking at the data coming out of that utility, it looks like it has many places of precision beyond 2. I tried a histogram of the power results between 0.4W and 0.85W, with 1000 bins and there were no binning gaps, so the resolution is greater than 0.00045W.

In another thread, @JustinAtSense explained that the current “Off” vs. “Standby” threshold for smartplugs and DCM devices is 0.5W. I’ve been seeking a way to explain all the “Off” standby “Transitions” I have been seeing in my timeline for my Washer HS110, below.

It’s fairly well explained if you looks at the distribution of of power readings coming from my Was he HS110 when the Washing Machine is not running - between 0W and 0.85W.

An even more revealing look here over time. Dots are power readings one time. Blue line is the threshold. Red line is a 5 reading moving average. gaps are where the Washing Machine went into “On” mode.

Today I noticed that the Kasa app on my Apple device is now displaying a live value under energy usage. Apparently the app developer upgraded their code! I’m not sure how long ago this change was made, but it is welcome. I share the news here since this subject was discussed in earlier posts on this thread.

2 Likes