KaufHA / PLF10

Files for the PLF10 Power Monitoring Smart Plug.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sanity check missing on measured data

randyoo opened this issue · comments

I recently observed the following from my PLF10:

Kauf Screenshot 2023-06-29 at 7 27 53 PM

That measurement is over 100x the theoretical power limit of the plug.

Seems like it should be fairly trivial to wrap the power measurement in a sensor.in_range condition to eliminate delivery of erroneous data.

Interesting. Did that just happen once or is it an intermittent issue? I could add some kind of sanity check.

That’s the first I’ve seen such a wildly unrealistic value, thus far. I’ve seen large current spikes for fan motor/compressor startups, but nothing out of the realm of possibility.

Maybe tangential to this issue, but the moving averages mentioned on the sensor page could be helpful for this issue as well as the “noise” from publishing absolute value changes, depending on the sensor sampling frequency.

Happened again--

Screenshot 2023-07-01 at 8 35 49 AM

Is it just the power sensor doing this? Not voltage or current?

Correct--not even the slightest glitch on amps or volts at the moment that erroneous power reading came in. (2.63A and 117.1V)

Scale values are all at default,FYI.

Math error?

I just released an update that will filter out everything over 5000w. Let me know how it works. If you are building the firmware yourself on the dashboard then you might have to delete the .esphome/packages directory to get the update immediately. Otherwise ESPHome only checks for package updates once every 24 hours.

I've installed the update, and will keep an eye on the results. Meanwhile, the screenshots I shared in this issue were actually two different PLF10 units, each monitoring different models of Midea inverter-based AC units. This is from a third device:

Screenshot 2023-07-02 at 8 04 11 AM

You can see regular spikes down to 0W while volts and current are stable. The exception is where the voltage spiked down to 1.7V and the current spiked down to 0.1A. In those cases, the power was measured at 20.3W and 15.7W, respectively.

Assuming this stems from the same underlying issue, it will be much easier to reproduce--but the >5000W filter obviously won't have an impact. I can't say 100% whether the measurements are actually false, but I could try putting another plug in series next time to see if both pick up the same drastic fluctuations.

Another, this time one of the PLF12 plugs monitoring a dishwasher:
Screenshot 2023-07-02 at 9 40 33 AM

That's 1,794.08A reported in that current spike! Power spikes down are all 0W, except when they coincide with voltage down-spikes (and the one current spike up), in which case they range between 7 and 8.5W. Voltage spikes down are all 0.8 volts.

Interesting. I might create a debug firmware that will print out more info so we can figure out what is going on. Let me think about what I need. Are you using the binary files to update or compiling your own through the ESPHome dashboard?

I’ve been compiling. (Kinda frustrating that none of the build files get shared between the dozen plugs, takes all night to update on my puny HA server!)

I wouldn’t be able to assign them unique names from the same binary file, right?

If you provide a debug firmware, I’ll be glad to install it on one unit.

There should be a new switch called * Early Publish. Can you turn that off on a couple of the switches that are having this problem? I wonder if this feature is causing the problem. The switch isn't enabled in Home Assistant by default so you'll have to enable it in HA or go to the web interface.

On another one of the switches, add the following to the yaml. It will incorporate a debug version of the power monitoring component. I want to know whether it fixes the problems and whether the logs say "Power sensor timed out." every time the power sensor goes to 0w. Maybe test this with and without the Early Publish switch enabled.

external_components:
  - source:
      type: git
      url: https://github.com/KaufHA/common
      ref: pm_debug
    refresh: always

There should be a new switch called * Early Publish.

Yes--I noticed that switch before you pointed it out! Indeed, switching it off eliminates masks the issues. Should be obvious which of these had that switch enabled:

signal-2023-07-03-094107_002

I've also collected some logs with snips from relevant periods while that switch was not enabled. Upon enabling it, the glitches went away immediately.

When it spikes down to 0W, it's right after a power sensor timed out message, as you suspected.

But interestingly, there are also erroneous measurements, such as the 0.06888A reading at 9:17:20 (which ought to be closer to 1.3A) that are immediately preceded by "Saving preferences to flash...". As you can see, the immediately following power calculations don't jive with the volts/current in the same batch. (32, 65, and 64W all with 120V and 1.3A of current, at 09:17:20/21)

Probably best to default Early Publish to "Off", at least unless/until this stuff is resolved. Thanks for putting that switch in!

[09:17:11][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
[09:17:20][D][esp8266.preferences:274]: Saving preferences to flash...
[09:17:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 8.17962 W with 1 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.00847 kWh with 3 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.06888 A with 2 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
[09:17:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 64.84406 W with 1 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.00848 kWh with 3 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.06888 A with 2 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
[09:17:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 32.75060 W with 1 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.00848 kWh with 3 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.31724 A with 2 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
[09:17:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 65.69503 W with 1 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.00848 kWh with 3 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.31724 A with 2 decimals of accuracy
[09:17:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
[09:17:21][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 64.78482 W with 1 decimals of accuracy
[09:17:21][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.00849 kWh with 3 decimals of accuracy
[09:17:21][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.29724 A with 2 decimals of accuracy
[09:17:21][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy

[09:27:11][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.65969 V with 1 decimals of accuracy
[09:27:20][D][esp8266.preferences:274]: Saving preferences to flash...
[09:27:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 7.84281 W with 1 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01497 kWh with 3 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.72012 A with 2 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[09:27:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 86.94456 W with 1 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01497 kWh with 3 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.72012 A with 2 decimals of accuracy
[09:27:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[09:27:21][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 87.83596 W with 1 decimals of accuracy

[09:28:21][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
[09:28:29][D][kauf_hlw8012:123]: Power sensor timed out.
[09:28:29][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:28:29][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:28:29][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[09:28:29][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01562 kWh with 3 decimals of accuracy
[09:28:29][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.60731 A with 2 decimals of accuracy
[09:28:29][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
[09:28:30][D][sensor:093]: 'Bob Kauf Plug Uptime': Sending state 2051.29102 s with 0 decimals of accuracy

[09:32:11][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 66.37480 W with 1 decimals of accuracy
[09:32:11][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01846 kWh with 3 decimals of accuracy
[09:32:11][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.31950 A with 2 decimals of accuracy
[09:32:11][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[09:32:20][D][esp8266.preferences:274]: Saving preferences to flash...
[09:32:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 7.40450 W with 1 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01848 kWh with 3 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.06654 A with 2 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.65969 V with 1 decimals of accuracy
[09:32:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 66.62074 W with 1 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01848 kWh with 3 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.32879 A with 2 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.65969 V with 1 decimals of accuracy
[09:32:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 33.32081 W with 1 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01848 kWh with 3 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.32879 A with 2 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[09:32:20][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 66.47850 W with 1 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.01848 kWh with 3 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.32031 A with 2 decimals of accuracy
[09:32:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[09:32:21][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 66.83351 W with 1 decimals of accuracy

[09:35:01][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 971.47650 W with 1 decimals of accuracy
[09:35:01][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.03636 kWh with 3 decimals of accuracy
[09:35:01][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.38357 A with 2 decimals of accuracy
[09:35:01][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.47974 V with 1 decimals of accuracy
[09:35:05][D][kauf_hlw8012:123]: Power sensor timed out.
[09:35:05][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:35:05][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.03636 kWh with 3 decimals of accuracy
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.40977 A with 2 decimals of accuracy
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[09:35:05][D][kauf_hlw8012:168]: Publishing early based on absolute value.
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 971.47650 W with 1 decimals of accuracy
[09:35:05][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state ON
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.03637 kWh with 3 decimals of accuracy
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.40977 A with 2 decimals of accuracy
[09:35:05][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[09:35:11][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 971.47650 W with 1 decimals of accuracy
[09:35:11][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.03797 kWh with 3 decimals of accuracy
[09:35:11][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.40977 A with 2 decimals of accuracy

[09:36:41][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 970.73767 W with 1 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.05980 kWh with 3 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.38357 A with 2 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[09:36:41][D][kauf_hlw8012:123]: Power sensor timed out.
[09:36:41][D][kauf_hlw8012:158]: Publishing early based on percentage.
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:36:41][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.05980 kWh with 3 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.37705 A with 2 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[09:36:41][D][kauf_hlw8012:168]: Publishing early based on absolute value.
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 974.44287 W with 1 decimals of accuracy
[09:36:41][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state ON
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.05981 kWh with 3 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.38357 A with 2 decimals of accuracy
[09:36:41][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[09:36:51][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 967.79382 W with 1 decimals of accuracy
[09:36:51][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.06232 kWh with 3 decimals of accuracy
[09:36:51][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.37705 A with 2 decimals of accuracy
[09:36:51][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 117.05581 V with 1 decimals of accuracy

Alright, there seems to be at least two different problems. For one, saving preferences locks interrupts and is obviously screwing with the power monitoring function that relies on the timing of interrupts.

Recompile with the same external_components block I pasted above and test it again. I have it pausing the power monitoring module when saving preferences so that it ignores the invalid readings.

It should be printing this in the logs:

[14:15:27][D][esp8266.preferences:277]: Saving preferences to flash...
[14:15:27][D][kauf_hlw8012:241]: HLW8012 Paused
[14:15:27][D][kauf_hlw8012:248]: HLW8012 Unpaused

Not sure what is happening with the power sensor timing out. Doesn't make a lot of sense to me but I'll keep thinking about how it can be debugged.

I just updated the debug components again to notify on current or voltage timeout, so keep an eye out for that.

Got it compiled, installed, and ran a bit. Those paused/unpaused lines are showing up, but unfortunately, log also contains memory errors and many disconnect/reconnects, which appear to be caused by reboots.

I don't understand why many/most of the power calculations are wrong--see the first snippet, and 15:11:23, 33, 43 for example. Later, when the heating element turns on at 17:18:12, the Volts, Amps, and Watts actually obey Ohm's law. I haven't played with the scaling values at all. When I look back at the graphs from yesterday, it's the same story--when the heating element is turned on, value seem correct. When it's switched off, though, the reported watts are circa 100W lower than Volts * Amps.

Full log here.

[16:40:57][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 74.84727 W with 1 decimals of accuracy
[16:40:57][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.74303 kWh with 3 decimals of accuracy
[16:40:57][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.43623 A with 2 decimals of accuracy
[16:40:57][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[16:41:02][I][ota:115]: Boot seems successful, resetting boot loop counter.
[16:41:02][D][esp8266.preferences:277]: Saving preferences to flash...
[16:41:02][D][kauf_hlw8012:241]: HLW8012 Paused
[16:41:02][D][kauf_hlw8012:248]: HLW8012 Unpaused
[16:41:07][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 75.27983 W with 1 decimals of accuracy
[16:41:07][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.74324 kWh with 3 decimals of accuracy
[16:41:07][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.44451 A with 2 decimals of accuracy
[16:41:07][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
<snip>
WARNING bob-kauf-plug-7aaf2e.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for bob-kauf-plug-7aaf2e.local
WARNING Disconnected from API
INFO Successfully connected to bob-kauf-plug-7aaf2e.local
[16:42:04][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 74.73772 W with 1 decimals of accuracy
[16:42:04][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state ON
[16:42:04][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.74316 kWh with 3 decimals of accuracy
[16:42:04][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.43872 A with 2 decimals of accuracy
[16:42:04][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy
[16:42:07][D][esp8266.preferences:277]: Saving preferences to flash...
[16:42:07][D][kauf_hlw8012:241]: HLW8012 Paused
[16:42:07][D][kauf_hlw8012:248]: HLW8012 Unpaused
[16:42:14][D][api:102]: Accepted 192.168.88.36
[16:42:14][D][api.connection:1030]: Home Assistant 2023.6.3 (192.168.88.36): Connected successfully
[16:42:14][D][time:044]: Synchronized time: 2023-07-03 16:42:14
[16:42:14][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 74.88239 W with 1 decimals of accuracy
<snip>
[16:47:20][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy
[16:47:20][E][json:039]: Could not allocate memory for JSON document! Requested 424 bytes, largest free heap block: 424 bytes
[16:47:30][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 74.91755 W with 1 decimals of accuracy
<snip>
[17:11:23][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 69.28572 W with 1 decimals of accuracy
[17:11:23][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.76318 kWh with 3 decimals of accuracy
[17:11:23][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.36450 A with 2 decimals of accuracy
[17:11:23][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[17:11:33][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 69.20308 W with 1 decimals of accuracy
[17:11:33][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.76337 kWh with 3 decimals of accuracy
[17:11:33][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.36208 A with 2 decimals of accuracy
[17:11:33][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[17:11:42][D][sensor:093]: 'Bob Kauf Plug Uptime': Sending state 214.60001 s with 0 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 68.78914 W with 1 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.76356 kWh with 3 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.35710 A with 2 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 119.53882 V with 1 decimals of accuracy
[17:11:43][D][kauf_hlw8012:163]: Publishing early based on percentage.
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 34.48097 W with 1 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.76356 kWh with 3 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.36070 A with 2 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy
[17:11:43][D][kauf_hlw8012:163]: Publishing early based on percentage.
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 69.25189 W with 1 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.76357 kWh with 3 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.36432 A with 2 decimals of accuracy
[17:11:43][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy
WARNING bob-kauf-plug-7aaf2e.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for bob-kauf-plug-7aaf2e.local
WARNING Disconnected from API
INFO Successfully connected to bob-kauf-plug-7aaf2e.local
[17:11:54][D][esp8266.preferences:277]: Saving preferences to flash...
[17:11:54][D][kauf_hlw8012:241]: HLW8012 Paused
[17:11:54][D][kauf_hlw8012:248]: HLW8012 Unpaused
<snip>
[17:24:00][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.83181 kWh with 3 decimals of accuracy
[17:24:00][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.29315 A with 2 decimals of accuracy
[17:24:00][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.47974 V with 1 decimals of accuracy
[17:24:10][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 958.34839 W with 1 decimals of accuracy
[17:24:10][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.83447 kWh with 3 decimals of accuracy
[17:24:10][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.26767 A with 2 decimals of accuracy
[17:24:10][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[17:24:15][D][sensor:093]: 'Bob Kauf Plug Uptime': Sending state 270.35699 s with 0 decimals of accuracy
[17:24:17][D][kauf_hlw8012:128]: Power sensor timed out.
[17:24:17][D][kauf_hlw8012:163]: Publishing early based on percentage.
[17:24:17][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[17:24:17][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[17:24:17][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.83447 kWh with 3 decimals of accuracy
[17:24:17][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.26133 A with 2 decimals of accuracy
[17:24:17][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.47974 V with 1 decimals of accuracy
WARNING bob-kauf-plug-7aaf2e.local: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for bob-kauf-plug-7aaf2e.local
WARNING Disconnected from API
INFO Successfully connected to bob-kauf-plug-7aaf2e.local
[17:24:36][D][esp8266.preferences:277]: Saving preferences to flash...
[17:24:36][D][kauf_hlw8012:241]: HLW8012 Paused
[17:24:36][D][kauf_hlw8012:248]: HLW8012 Unpaused
[17:24:39][D][kauf_hlw8012:128]: Power sensor timed out.
[17:24:39][D][kauf_hlw8012:163]: Publishing early based on percentage.
[17:24:39][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[17:24:39][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[17:24:39][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.81312 kWh with 3 decimals of accuracy
[17:24:39][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 8.28677 A with 2 decimals of accuracy
[17:24:39][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 116.94015 V with 1 decimals of accuracy
[17:24:39][D][kauf_hlw8012:173]: Publishing early based on absolute value.

I see the same behavior on another PLF12 unit with a fridge attached, no debug firmware on this unit.

Looking at the history graph in HA, the reported power was dead-on during a defrost cycle (about 5A/650W), but otherwise off significantly... 136W at 1.37A/120.2V, for example.

18:06:34 | [D] | [sensor:093] | 'Krusty Kauf Plug Total Daily Energy': Sending state 1.47473 kWh with 3 decimals of accuracy
18:06:34 | [D] | [sensor:093] | 'Krusty Kauf Plug Current': Sending state 1.36817 A with 2 decimals of accuracy
18:06:34 | [D] | [sensor:093] | 'Krusty Kauf Plug Voltage': Sending state 121.32193 V with 1 decimals of accuracy
18:06:43 | [D] | [sensor:093] | 'Krusty Kauf Plug Power': Sending state 142.24503 W with 1 decimals of accuracy
18:06:43 | [D] | [sensor:093] | 'Krusty Kauf Plug Total Daily Energy': Sending state 1.47512 kWh with 3 decimals of accuracy
18:06:44 | [D] | [sensor:093] | 'Krusty Kauf Plug Current': Sending state 1.36141 A with 2 decimals of accuracy
18:06:44 | [D] | [sensor:093] | 'Krusty Kauf Plug Voltage': Sending state 120.73808 V with 1 decimals of accuracy
18:06:54 | [D] | [sensor:093] | 'Krusty Kauf Plug Power': Sending state 142.51711 W with 1 decimals of accuracy
18:06:54 | [D] | [sensor:093] | 'Krusty Kauf Plug Total Daily Energy': Sending state 1.47552 kWh with 3 decimals of accuracy
18:06:54 | [D] | [sensor:093] | 'Krusty Kauf Plug Current': Sending state 1.38307 A with 2 decimals of accuracy

edit: a very quick glance seems to show this behavior happening on PLF10 units, 2 weeks ago, w/ older firmware:
1A at 119.5V = 70.7W (wrong!)
2.66A = 320.9W (right!)

edit again: this might actually be legitimate discrepancy due to power factor, disregard for now

I just updated the debug components again to notify on current or voltage timeout, so keep an eye out for that.

I think I must have initiated recompiling right before this comment, so I'm not sure if those changes made it in. I've recompiled/reinstalled, but it may be a day or two before I can report back.

Meanwhile, I spent some time looking at other devices and history charts, and it seems that oftentimes the amps, volts, and power don't agree. I thought it might have been another symptom of the erroneous measurements, but it actually kinda looks like it might be power factor--Watts vs VA. I'll get back to you or open an issue if there's actually a problem.

Thanks. Yea, I think it is a different issue. I'm going to try to fix the glitches first and then look into the values being off.

I'm seeing some timeouts on the power sensor here so I'm going to work on that on my end for a bit.

Yea, I think it is a different issue.

I really think it's just reactive/apparent power, i.e. Volt Amperes, which is actually pretty cool, if true. I bought a Kill-a-watt, despite having a bunch of your plugs, because I needed to measure VA. I'll compare readings to confirm (and let you know), but that's really what it looks like--a feature, not a bug. :)

Meanwhile, even with the debugging stuff, I don't see any new info in the logs. Power sensor timeouts spike down to 0W, but I'm also seeing these spikes down to almost exactly 50%:

Screenshot 2023-07-04 at 1 25 24 PM

[13:17:33][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 70.70958 W with 1 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14279 kWh with 3 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.38951 A with 2 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.51265 V with 1 decimals of accuracy
[13:17:33][D][kauf_hlw8012:155]: Publishing early based on percentage.
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 35.24448 W with 1 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14279 kWh with 3 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.38486 A with 2 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.51265 V with 1 decimals of accuracy
[13:17:33][D][kauf_hlw8012:155]: Publishing early based on percentage.
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 69.95398 W with 1 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14279 kWh with 3 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.37971 A with 2 decimals of accuracy
[13:17:33][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.51265 V with 1 decimals of accuracy
[13:17:43][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 70.65087 W with 1 decimals of accuracy
[13:17:43][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14299 kWh with 3 decimals of accuracy
[13:17:43][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.38646 A with 2 decimals of accuracy
[13:17:43][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
<snip>
[13:20:23][D][kauf_hlw8012:155]: Publishing early based on percentage.
[13:20:23][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 72.03432 W with 1 decimals of accuracy
[13:20:23][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14617 kWh with 3 decimals of accuracy
[13:20:23][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.40272 A with 2 decimals of accuracy
[13:20:23][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
[13:20:32][D][kauf_hlw8012:137]: Power sensor timed out.
[13:20:32][D][kauf_hlw8012:155]: Publishing early based on percentage.
[13:20:32][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 0.00000 W with 1 decimals of accuracy
[13:20:32][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[13:20:32][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14617 kWh with 3 decimals of accuracy
[13:20:32][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.40419 A with 2 decimals of accuracy
[13:20:32][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.63549 V with 1 decimals of accuracy
[13:20:33][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 72.64512 W with 1 decimals of accuracy
[13:20:33][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state ON
[13:20:33][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.14619 kWh with 3 decimals of accuracy
[13:20:33][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.41211 A with 2 decimals of accuracy
[13:20:33][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.51265 V with 1 decimals of accuracy

I'm still not sure what is going on with the timeouts exactly, but I think I think I can filter them out if I require both Current and Power to time out before considering a timeout to have happened. Haven't implemented or tested yet.

For the spikes that go down less, I think it's pretty clear that the ESP8266 is missing an edge of the signal from the power monitoring chip due to the CPU being busy and not handling the interrupt in time or something. That doubles the apparent period of the signal, and thereby halves the reported value.

I'm working on an update that requires two samples within 33% of each other before publishing. That will filter out the 50% jump downward and then the 200% jump upward.

Keep me posted on the VA situation. I believe that Tasmota reports VA and V separately. I should look at the formulas they are using.

Alright give it another shot.

Looks good, tentatively. No spikes. Found this in the logs, guess it's an instance where results weren't reported due to being too different between power samples at 23:29:21.

Rather have no data than false data, but now it's a 20 second gap in publishing. Maybe a retry in case of failure? Or perhaps just wait for two samples that are within a certain tolerance?

I've no experience with Tasmota, but a brief search indicates that it reports power factor (which is just Watts to VA ratio). That's gotta be what it is.

[23:29:01][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 18.83884 W with 1 decimals of accuracy
[23:29:01][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.54543 kWh with 3 decimals of accuracy
[23:29:01][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 1.03435 A with 2 decimals of accuracy
[23:29:01][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.14560 V with 1 decimals of accuracy
[23:29:11][D][kauf_hlw8012:187]: 
[23:29:11][D][kauf_hlw8012:188]:  ---------------------    POWER Period -1: 67802
[23:29:11][D][kauf_hlw8012:189]:  ---------------------    POWER Period  0: 70728
[23:29:11][D][kauf_hlw8012:191]: 
[23:29:11][D][kauf_hlw8012:192]:  ---------------------  CURRENT Period -1: 10647
[23:29:11][D][kauf_hlw8012:193]:  ---------------------  CURRENT Period  0: 13851
[23:29:11][D][kauf_hlw8012:195]: 
[23:29:11][D][kauf_hlw8012:196]:  ---------------------  VOLTAGE Period -1: 986
[23:29:11][D][kauf_hlw8012:197]:  ---------------------  VOLTAGE Period  0: 986
[23:29:11][D][kauf_hlw8012:199]: 
[23:29:11][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 18.04830 W with 1 decimals of accuracy
[23:29:11][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.54548 kWh with 3 decimals of accuracy
[23:29:11][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.77716 A with 2 decimals of accuracy
[23:29:11][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy
[23:29:21][D][kauf_hlw8012:187]: 
[23:29:21][D][kauf_hlw8012:188]:  ---------------------    POWER Period -1: 67788
[23:29:21][D][kauf_hlw8012:189]:  ---------------------    POWER Period  0: 512442
[23:29:21][D][kauf_hlw8012:191]: 
[23:29:21][D][kauf_hlw8012:192]:  ---------------------  CURRENT Period -1: 320441
[23:29:21][D][kauf_hlw8012:193]:  ---------------------  CURRENT Period  0: 373328
[23:29:21][D][kauf_hlw8012:195]: 
[23:29:21][D][kauf_hlw8012:196]:  ---------------------  VOLTAGE Period -1: 982
[23:29:21][D][kauf_hlw8012:197]:  ---------------------  VOLTAGE Period  0: 986
[23:29:21][D][kauf_hlw8012:199]: 
[23:29:31][D][kauf_hlw8012:187]: 
[23:29:31][D][kauf_hlw8012:188]:  ---------------------    POWER Period -1: 877245
[23:29:31][D][kauf_hlw8012:189]:  ---------------------    POWER Period  0: 910059
[23:29:31][D][kauf_hlw8012:191]: 
[23:29:31][D][kauf_hlw8012:192]:  ---------------------  CURRENT Period -1: 368374
[23:29:31][D][kauf_hlw8012:193]:  ---------------------  CURRENT Period  0: 373849
[23:29:31][D][kauf_hlw8012:195]: 
[23:29:31][D][kauf_hlw8012:196]:  ---------------------  VOLTAGE Period -1: 986
[23:29:31][D][kauf_hlw8012:197]:  ---------------------  VOLTAGE Period  0: 986
[23:29:31][D][kauf_hlw8012:199]: 
[23:29:31][D][sensor:093]: 'Bob Kauf Plug Power': Sending state 1.40268 W with 1 decimals of accuracy
[23:29:31][D][binary_sensor:036]: 'Bob Kauf Plug Device In Use': Sending state OFF
[23:29:31][D][sensor:093]: 'Bob Kauf Plug Total Daily Energy': Sending state 0.54549 kWh with 3 decimals of accuracy
[23:29:31][D][sensor:093]: 'Bob Kauf Plug Current': Sending state 0.02879 A with 2 decimals of accuracy
[23:29:31][D][sensor:093]: 'Bob Kauf Plug Voltage': Sending state 120.02376 V with 1 decimals of accuracy