{"id":824,"date":"2025-12-20T10:09:29","date_gmt":"2025-12-20T10:09:29","guid":{"rendered":"https:\/\/anthonyparkes.co.uk\/?p=824"},"modified":"2025-12-20T10:10:00","modified_gmt":"2025-12-20T10:10:00","slug":"mastering-the-grid-why-i-built-my-own-energy-cost-tracker","status":"publish","type":"post","link":"https:\/\/anthonyparkes.co.uk\/?p=824","title":{"rendered":"Mastering the Grid: Why I Built My Own Energy Cost Tracker"},"content":{"rendered":"\n<p>In the world of smart homes, few things are as satisfying as watching your electricity bill drop. Recently, I built a custom &#8220;single source of truth&#8221; for my home\u2019s energy costs, integrating the <strong>Octopus Agile<\/strong> tariff with my <strong>Sigenergy solar and battery system<\/strong> via <strong>Home Assistant<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Problem: When &#8220;Smart&#8221; Meters Aren&#8217;t Smart Enough<\/h3>\n\n\n\n<p>If you are on a dynamic tariff like Octopus Agile, you\u2019ve likely noticed a major flaw with the standard In-Home Display (IHD) provided by energy suppliers. These devices are usually designed for static tariffs. Mine only seems to understand a single, fixed price per hour.<\/p>\n\n\n\n<p>Because Agile prices change every 30 minutes\u2014sometimes dropping into &#8220;plunge&#8221; pricing where you are paid to use electricity\u2014the standard display was giving me massively over-inflated figures. It could track my <em>usage<\/em> (kWh) just fine, but the <em>cost<\/em> data was completely useless. I needed a way to monitor what I was actually spending, not what a basic display guessed I was spending.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Solution: A Triple-Step Integration<\/h3>\n\n\n\n<p>My system relies on three main pillars to bridge the gap between &#8220;energy used&#8221; and &#8220;actual cost&#8221;:<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Octopus API:<\/strong> To pull the precise 30-minute unit rates.<\/li>\n\n\n\n<li><strong>Home Assistant &amp; Sigenergy:<\/strong> To provide real-time data on solar generation, battery status, and grid import\/export.<\/li>\n\n\n\n<li><strong>MySQL &amp; Docker:<\/strong> To store every price point for long-term tracking and historical analysis.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">The Technical Setup<\/h3>\n\n\n\n<p>To keep the system lightweight and reliable, I built a streamlined <strong>Bash and Docker<\/strong> setup:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Persistence with Docker:<\/strong> I used a <code>docker-compose<\/code> setup to run a MySQL instance. By mounting the data folder locally, the data survives even if the container is updated.<\/li>\n\n\n\n<li><strong>Automated Price Polling:<\/strong> A simple Bash script runs every 30 minutes via a cron job. It uses <code>curl<\/code> to talk to the Octopus API and <code>jq<\/code> to parse the JSON response, injecting the true cost into the database.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Summary: Taking Back Control<\/h3>\n\n\n\n<p>By bypassing the limited hardware provided by the supplier and going straight to the API, I\u2019ve finally achieved cost transparency. I can now see exactly how my Sigenergy battery is performing\u2014charging when rates are low and discharging when the grid is expensive\u2014with penny-accurate data.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What\u2019s Next?<\/h3>\n\n\n\n<p>This database is just the first step. Now that I have a reliable stream of real-time pricing data, my next goal is to build a <strong>custom In-Home Display using an ESP32<\/strong>. Instead of a &#8220;dumb&#8221; display showing static prices, this new device will sit on my desk and show me the <em>true<\/em> live cost of my energy, pulled directly from my own tracker.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"957\" src=\"https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09-1024x957.png\" alt=\"\" class=\"wp-image-826\" srcset=\"https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09-1024x957.png 1024w, https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09-300x280.png 300w, https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09-768x718.png 768w, https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09-1536x1435.png 1536w, https:\/\/anthonyparkes.co.uk\/wp-content\/uploads\/2025\/12\/Screenshot-2025-12-20-at-10.06.09.png 1984w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In the world of smart homes, few things are as satisfying as watching your electricity bill drop. Recently, I built a custom &#8220;single source of<\/p>\n","protected":false},"author":2,"featured_media":825,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"template-fullwidth.php","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=824"}],"version-history":[{"count":1,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/824\/revisions"}],"predecessor-version":[{"id":827,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/824\/revisions\/827"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/media\/825"}],"wp:attachment":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}