christopherpthomas / MMM-OctoMon

Octopus Energy display monitor module for MagicMirror
MIT License
5 stars 3 forks source link

Display cost of energy used rather than, or in addition to, energy used #3

Closed robertybob closed 4 years ago

robertybob commented 4 years ago

Hi Chris,

Like the title says, I was wondering if it was possible to either replace the kWh column with the cost of that energy used (i.e kWh * unit cost specified in config file = £x) or have this in a new column next to it? Could then colour it by £ used like you have for kWh used

robertybob commented 4 years ago

Also, I presume one of the dependancies for the module is a smart meter? Probably obvious, but it’s not stated in the README 😉

christopherpthomas commented 4 years ago

Hi Rob, potentially, yes, if you have a fixed rate, it would be possible to add another column and multiply the energy used by a £ per kwh value to get the amount spent. However, problems with that calculation would occur if you're not on a fixed rate, due to how I'm using the Octopus API to return the total energy used during one 24 hour period (the '?group_by=day' parameter in the URL). I chose to it that way to minimise the amount of data transferred in the API call, and also because I'd have to find a way of implementing the Octopus Go tariff I'm on, which gives me a cheaper overnight rate between 12:30am and 4:30am.

However, since you mention it, and it's something that I did intend to get around to eventually, I will have another look at it again next week!

And yes, you do have to have one of the new SMETS2 electricity meters installed, which sends automatic meter readings back to your energy provider using the mobile phone network. I'll add that to the dependencies! :)

robertybob commented 4 years ago

That’s good to know! I’m switching from Bulb (to the Octopus 12m fixed rate) due to their recent price hike and I remembered there was a MM module to monitor usage on Octopus (I wish every energy supplier allowed the public access to their API!).

My switch isn’t due to take place until October and it may only be myself that benefits from the addition of that £ function, so honestly there’s no rush :)

christopherpthomas commented 4 years ago

Hi Rob! Ok, i've added a few features to allow you to enter a cost per kilowatt hour and a standing charge, though these will only work for fixed price tariffs, not any of the tiered or variable price ones. If you want to only display the cost, and not the energy usage, you can delete the 'strUse' variable from these lines in the main MMM-OctoMon.js file:

from: thiseleclabel.innerHTML = "  <span style=\"" + strCol + "\">" + strUse + " " + strCost + ""; ... and ... thisgaslabel.innerHTML = "  <span style=\"" + strCol + "\">" + strUse + " " + strCost + "";

to: thiseleclabel.innerHTML = "  <span style=\"" + strCol + "\">" + strCost + ""; ... and ... thisgaslabel.innerHTML = "  <span style=\"" + strCol + "\">" + strCost + "";

Hope that helps!

robertybob commented 4 years ago

Wow that looks exactly what I was after, thank you so much! When my switch is complete I’ll look forward to trying this module out 😃