Per-device electricity cost explorer for your smart home
Pick any date range and see what each device in your home actually cost to run, not just how many kilowatt-hours it used.
Build me an app for exploring what electricity actually costs me, device by device. I pick a date range at the top, and the main view ranks every energy sensor in my home by what it cost me over that window, showing kilowatt-hours used, the cost in my currency, and the change versus the previous equivalent period, meaning the same number of days immediately before the selected window. Clicking a device row opens a detail view with a usage chart for that device across the window.
Find my energy sensors with Home Assistant List States, keeping entities whose device_class is energy and whose unit is kWh or Wh. Store that list in app settings so I can tick devices on and off, because I have sensors that overlap (a whole-home monitor plus individual smart plugs) and I do not want them double counted in the ranking. Let me give devices friendlier display names than the raw entity ids.
Pull consumption with Home Assistant Get History, always narrowed with filter_entity_id plus start_time and end_time, never unbounded, because my instance runs on a Raspberry Pi and wide history calls will crawl. Timestamps must be ISO 8601 and URL encoded. Here is the detail that matters most: nearly all of these sensors are cumulative totals (state_class total_increasing), so usage for a window is the last reading minus the first reading inside that window, not a sum of the readings. Handle counter resets, so if a reading is lower than the one before it the counter reset and you add the pre-reset accumulation rather than producing a negative number. Skip unavailable and unknown states instead of treating them as zero. If a sensor turns out to be an instantaneous power reading in watts rather than a cumulative energy total, integrate it over time instead. If a device has no readings at all in the window, show it as no data rather than a zero cost.
Pricing lives in a Google Sheets tariff table that I maintain, read with Get Values. Rows define named rate windows (peak, off-peak, shoulder), each with a start time, an end time, and a price per kWh, plus a separate daily standing charge. Cost each device by splitting its usage across the rate windows it actually ran in and applying the matching rate, so a dishwasher that runs at 2am is priced at off-peak. Show the standing charge as its own line in the total, calculated as the daily rate times the number of days in the window, kept clearly separate from device costs because it is not attributable to any single device.
I want to edit those rates without leaving the app. Give me a tariff panel where I can change the windows, the prices, and the standing charge, and saving writes them straight back to the sheet with Update Values, after which the whole breakdown recalculates. Validate before saving: prices must be positive numbers, and the rate windows must cover the full 24 hours with no gaps and no overlaps.
Two more actions in the toolbar. First, export the current breakdown to my costs spreadsheet with Append Values, writing one row per device for the selected window (date range, device name, kWh, cost, change versus previous period), plus a row for the standing charge. Second, publish my month to date total cost back into Home Assistant with Create or Update State, writing to a sensor entity I name in settings, something like sensor.home_energy_cost_mtd, with the currency and a friendly name in the attributes so it can sit on my wall tablet dashboard. Note that Create or Update State writes a state representation only, it does not command any device, and Home Assistant drops these values on restart, so make the publish button easy to hit again.
Add an Explain this spike button on every device row and on any day in the device chart. It starts a background agent, and the app shows that device's explanation as pending while the agent runs, then displays the finished result in the detail view. The agent pulls Get History for that device across the window in question, pulls Get History for the rest of the home's energy sensors over the same window for context, and compares against a baseline period such as the same weekday previously or the previous equivalent window. It works out what was running when the cost jumped: a longer runtime, more cycles than usual, running during a peak rate window instead of off-peak, or another heavy device being on at the same time. Then it writes a plain-language explanation of what happened, in the tone of talking to a housemate rather than an engineer, plus two or three concrete savings suggestions tied to my actual tariff windows, for example shifting a specific appliance to a specific time of night. The explanation lands back in the app and also gets appended to a log tab in my spreadsheet with Append Values, so I build up a history of everything that has been explained.
Keep in app settings: my tariff spreadsheet id and tab name, my costs spreadsheet id and its export and explanation log tabs, my currency symbol, the entity id to publish the running total to, my device selections and display names, and my last used date range so the app reopens where I left it. Give me sensible date range presets: this month, last month, last 7 days, last 30 days, and custom.
To be clear about scope: this app reports costs and publishes derived values. It does not switch anything on or off, and none of its copy should suggest that it can.
What does this prompt do?
- Ranks every energy-monitoring device in your home by what it cost over the date range you pick, with usage, cost, and the change against the previous period.
- Prices that usage against your own peak, off-peak, and shoulder rates plus the daily standing charge, all kept in a spreadsheet you can edit without leaving the app.
- Click any device for a usage chart, or hit Explain this spike to have an assistant work out what was running when your cost jumped and suggest two or three ways to cut it.
- Export the breakdown to your costs spreadsheet, and publish your month to date total back to Home Assistant so it shows on your wall tablet.
What do I need to use this?
- A Home Assistant setup with devices that report energy usage, such as smart plugs, an energy monitor, or an EV charger.
- A Google account with a spreadsheet holding your electricity rates, and a place to log costs (the same file with two tabs is fine).
- Your tariff details: your peak, off-peak, and shoulder prices and your daily standing charge.
How can I customize it?
- Change the rate windows, prices, and standing charge any time from the tariff panel, and the whole breakdown recalculates instantly.
- Choose which devices appear and rename them, so overlapping sensors like a whole-home monitor and individual plugs do not double count.
- Pick which Home Assistant sensor the running total publishes to, so it matches the dashboard on your tablet.
FAQs
Do I need a smart meter for this to work?
Can it handle time of use rates?
Will this turn devices off for me?
Why does my total not match my electricity bill exactly?
Can I use a currency other than dollars?
Related templates
Stage a batch of filings overnight, then approve each completed form from a screenshot before anything is ever submitted.
Review every conversation Fin closed as resolved, judge which ones actually stuck, and see what the gap is worth against your bill.
Work every return, damage and warranty claim in one queue, with the order, the delivery date and a policy-backed recommendation already on screen.
See exactly which ingredients next week needs based on what you actually sold, adjust anything by hand, then build a one-click grocery cart.
See follower growth, posting cadence, format mix and engagement rate for your brand and every competitor you track, side by side on one board.
Open one screen to see how every service in your Jobber price book actually performed: how often it sold, what you charged, and where prices swing.
Stop guessing which device is running up your electricity bill.
Build a cost explorer that prices every device against your real tariff and explains what changed.