
Using the Shelly Plug US Gen4 API to automatically calculate real EV charging costs with TOU rates
I've been using a Shelly Plug US Gen4 on my Level 1 EV charger at home and wanted to share how I'm pulling the session data via the Shelly Cloud API to calculate actual cost per mile.
The basic flow: the Shelly captures kWh delivered and timestamps for each charging session. My app pulls that data, applies my utility's time-of-use rate schedule, and calculates exact cost per session — not an estimate based on national averages, but what I actually paid my utility for that specific session at that specific time of day.
The screenshot shows my recent sessions from the dashboard. You can see the per-session cost and kWh varying based on when I charged and which TOU tier applied (sometimes it's in-between because it blends sessions crossing TOU).
A few things I found interesting building this:
- The Shelly data is clean and consistent — session start/end times and energy readings come through reliably
- TOU calculations make a meaningful difference. The same kWh costs noticeably more if you charge during peak vs overnight
- Level 1 on a standard 120V outlet works well for this — well within the Shelly's rated capacity charging overnight at 12A (my vehicle is limited to 8A due to being on a shared circuit)
Curious if anyone else is doing something similar with the Shelly API for energy cost tracking on their EV.