Athom Smart Plug V3 — add Today/Yesterday/Week/Month/Year energy stats (ESPHome + dentra)

The Athom Smart Plug V3 ships with ESPHome and gives you instantaneous power/voltage/current plus a cumulative total_energy_sensor out of the box. That cumulative total is great for the Energy dashboard, but it's not directly usable for the question most of us actually want answered: "how much did this fridge/heater/PC use today vs. yesterday vs. this month?"

dentra/esphome-components has an energy_statistics component that reads any cumulative energy sensor and breaks it into rolling buckets. Layered on top of the official Athom base package, it's ~40 lines of YAML per plug and lights up exactly the cards you want. Sharing the config I flash onto every V3 I own.

What you get

Five new sensors alongside the stock ones:

  • Energy Today — kWh since local midnight
  • Energy Yesterday — previous day's final total, frozen at rollover
  • Energy Week — running total since start of week
  • Energy Month — since the 1st
  • Energy Year — since Jan 1

All reset at their boundaries in your configured timezone and persist across reboots (state lives in NVRAM, so a power blip doesn't zero them). The stock total_energy_sensor stays intact for the Energy dashboard.

The config

Paste as a new device in your ESPHome dashboard, change the four fields at the top, hit Install:

substitutions:
  name: "athom-smart-plug-1a2b3c"
  friendly_name: "Athom Plug V3 1a2b3c"
  current_limit: "16"                  # US (AU would be 10)
  timezone: "Pacific/Honolulu"

packages:
  athom_plug:
    url: https://github.com/athom-tech/esp32-configs
    ref: main
    files: [athom-smart-plug.yaml]
    refresh: 1d

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# --- Today / Yesterday / Week / Month / Year breakdown ---
external_components:
  - source: github://dentra/esphome-components
    components: [energy_statistics]

sensor:
  - platform: energy_statistics
    total: total_energy_sensor         # provided by the Athom base config
    energy_today:
      name: "Energy Today"
      accuracy_decimals: 3
      icon: mdi:hours-24
    energy_yesterday:
      name: "Energy Yesterday"
      accuracy_decimals: 3
      icon: mdi:calendar-today
    energy_week:
      name: "Energy Week"
      accuracy_decimals: 3
      icon: mdi:calendar-week
    energy_month:
      name: "Energy Month"
      accuracy_decimals: 3
      icon: mdi:calendar-month
    energy_year:
      name: "Energy Year"
      accuracy_decimals: 3
      icon: mdi:calendar
Why each block is the way it is
  • packages: pulls the official Athom base config (relay/button GPIOs, CSE7766 power-monitor driver, status LED, OTA/API). refresh: 1d re-downloads it daily so you pick up upstream fixes on the next flash. Pin ref: to a commit SHA if you'd rather never get surprised.
  • external_components + components: [energy_statistics] — the filter matters. The dentra repo has many components; without it ESPHome tries to compile all of them and blows up your image size.
  • total: total_energy_sensor is the ID of the cumulative sensor the Athom base config defines — not a name. If you retarget this to another plug brand, find that brand's equivalent cumulative-energy sensor ID.
  • accuracy_decimals: 3 — Wh-resolution on a kWh reading; the sweet spot for the CSE7766. Icons are cosmetic; drop them if you don't care.
  • current_limit — safety cutoff. 16A for US/EU, 10A for AU/UK. Don't crank it past the plug's relay rating.
  • timezone — IANA string. This is what decides when "midnight" happens for the Today/Yesterday rollover. Get it wrong and Today resets at a weird hour.

Gotchas I hit

  • total_energy_sensor not declared at compile → the Athom package didn't load (typo in url/files/ref, or dashboard offline). The fetch failure is loud in the compile log.
  • energy_statistics not found → missing external_components block or a typo in the component name (case-sensitive).
  • Sensors stuck at 0 → make sure something is actually drawing power; energy_statistics updates on a poll cycle, not every wattage reading. Give it a few minutes.
  • Today resets at the wrong time → timezone mismatch, or the ESPHome host isn't NTP-synced.
  • For the Energy dashboard itself, use the stock cumulative total_energy_sensor as the source — not these resetting buckets. The buckets are for your own dashboards/templates/automations.

Multi-plug tip: copy the file per plug and change only the substitutions: block. I name them by the MAC suffix off the plug's label (athom-smart-plug-1a2b3c, etc.) so they sort together and never collide.

Full write-up with the complete per-block reasoning and a fleet-management section: Athom Smart Plug V3 — Dentra Energy Stats in ESPHome — magikh0e.pl

Happy to answer questions — works great on every V3 I've thrown it at.