Where is the smart plug energy data stored and how long is this retained?

I have a 'Local Bytes Power Monitoring Smart Plug flashed with ESP Home.
I’d like to know where the energy data is stored, is iton the device or within HA.
Also how long is historical data retained?

Normally without flashing the current, voltage, wattage, power factor are in the plug. That is then sent to the cloud where the calculation and summing is done. But when you flash a device those same items are still there, what is missing is the calculation and summing which now has to be done in HA.

Look at these: How to calculate energy based on time?
Integrating individual device energy usage - Home Assistant
you can also do some searching of the web using Home Assistant and different energy items.

Storage of data is based on the size of the database on what where that is placed on the HA instance. I’ve got data going into a second year.

In ha, in the same database as all other data is stored.

1 Like

What?

Localbytes aren’t cloudy. And obviously total energy is calculated/integrated directly on the plug.

Just asking for a friend: You didn’t use AI or AS for your post?

I gave you info based on other smart plugs on the market. Now the ESPHome plug with that sensor will accumulate the Wattage but from the examples of code used for home data systems (which ever you use). The key is " state_class: total_increasing" so it keeps that value an increases over time till it is a certain period of time. That part is not mentioned so does it keep increase forever and at 23:59:29 local time at the clock triggers a new day that value is time stamped and stored somewhere? Kind of leaves you hanging out there on your own. Does it reset back to 0.00 kWh?
The conversion is there also from W to kHw, although I see no reference to time with conversion, so is the W really Hw instead? Not a whole lot there in that doc from ESPHome about it.

About the database, again everybody has different hardware with different OS’s, with on told amounts of configurations from flat installs, to containers, VMs. So then all the different db’s that can be used. The db size grows based on the number of devices, automations, scenes, helpers, integrations, add-ons used. How often you poll for data that you want to graph later. It just depends on how much you want to dig into building from the ground up or choose a appliance device like a PI or Noid, etc that taken most of that into account for you.

I went with a PI 4 by Nuba Casa called the Yellow (Had to wait nearly a year for it to pass testing/certification/shipping). Works like a dream. 14 months of use, and keep adding slowly to it with new integrations/add-ons. No PoE, The WiFi is off till I need a Z (ZHA, Zigbee) solution. Using the Ethernet hardwired, a 2TB SSD (Yellow allows for data to be moved off from the eMMC where the OS resides) besides what came with the Yellow eMMC and RAM, one of two USB ports is hooked to a UPS for grace shutdown if a power out hits hard or long enough.

Again I want to get integrating my home, and not rethink every device from the ground up. You may have a lot of experimenting, testing and coding to support that device and get the correct data you really need.

Everybody gets into this for a reason. Just be ready for some pot holes on your journey.

The community responses are a combination of the worst of Facebook & Twitter combined.

If anybody actualy wants the definitive answer, here it is:
The ‘Local Bytes Power Monitoring Smart Plug’ itself only stores:

  • Today
    
  • Yesterday
    
  • Total Counters
    

Data stored on HA is defined on the HA configuration, which by default is 10 days and automatically purged every night at 04:12 local time.
If data needs to be kept longer, then action needs to be taken to set-up a database appropriately.

I can confirm this is correct ^

Assuming you’re using HomeAssistant, the granular data is handled by the recorder

Source: I’m the guy behind LocalBytes

1 Like