Emoncms Solar Battery Simulator app

With energy prices increasing @glyn.hudson and I have been looking again at battery storage (and in my case solar as well) for our respective house projects. Glyn has a Givenergy battery on order that will connect to his existing solar system + off peak Octopus GO charging. Im yet to make an order but looking through the options and trying to work out if it makes sense - even if we are not going to be in our current house for the number of years that payback may require…

A while ago I made a solar and battery simulator that used the post processing module and also did some seperate simulation’s here GitHub - TrystanLea/solarmodel: Home Solar PV self consumption model but these are all quite difficult to use with existing data in emoncms.

So I thought building off the experience of building the emoncms profiles app that processes an entire year at 15 mins resolution in about a second (depending on internet connection speed more than server or client processing speed), Id have a go at making an emoncms app that simulates a solar and battery system based on existing consumption data and either existing solar data or solar data from a public emoncms.org feed.

Here’s the result:

Simulation parameters:

  • Solar PV capacity and option to specify if the solar is an existing install or new to adjust the savings calculation accordingly.
  • Battery capacity, max charge and discharge rates and round trip efficiency settings.
  • Off-peak charging settings, with different winter and summer time target state of charge (could be improved with day ahead solar forecasting algorithm)
  • Off-peak tariff timing and costs
  • System install costs and lifespan

It would be good to get some better figures on system costs for different solar and battery configurations, I have an idea of the equipment cost of the system Im looking at from midsummer wholesale but not sure yet of the total install cost.

The payback times of battery storage seem to be hugely influenced by off-peak tariff options such as Octopus GO, if you are lucky to be on such a tariff and assuming these tariffs are here to stay.

The simulator cant simulate changed consumption patterns due to having solar and a battery installed, e.g moving more EV charging and heat pump consumption to the day time. So it may not capture all of the potential savings.

Id be interested to hear what those with more experience of living with solar and battery storage think. Are ballpark payback times in the 7-10 year range based on current prices and assuming octopus GO about right?

The above app is available on emoncms.org or in the emoncms core and app’s module latest master branches for anyone keen to test.


Looks potentially very handy… Just thinking about a solar install here and would be nice to crunch the numbers against my building consumption data in Emoncms.

1 Like

Thanks @Peter_Clifton interested to hear what results you get!

Would like to try this. My local emoncms is running locally on an emonpi, is set on the stable branch, and is up-to-date. I tried switching the apps section to the master branch & updating it, but I got errors basically saying

public_userid is not defined (in the app) and
Multiple times in the main program
Undefined index: public_userid in /var/www/emoncms/Modules/app/app_menu.php on line 41

Is it OK to just update app like that, or do I have to update everything to Master. If I update to Master, what are the differences & can I go back?

Sorry if I’m being thick!

Nicely done!

I already have a solar + battery setup*, so I was interested to see how your simulation matched my actual measured performance. Here’s 10 days from the end of July for comparison:

The shapes of the simulation (top) are very simular to what my battery actually filled to (bottom).

(*5.1 kW of solar through a 3.6 kW hybrid inverter to a 9.6 kWh of battery; 90% usable. Basic fixed tariff, not charging from the grid)

I also compare the monthly numbers, and found them to be moderately close, although the Import was under estimated by quite a bit. Table below shows simulation (top) vs. measured.


I don’t have a full year yet, so I’m not sure how the ROI will work out.

Can you add Export tariff to the settings? It would be nice to factor in the (tiny) payback from SEG.


Thanks @Timbones that’s really great to see!

I wonder why solar direct is lower, could it be relating to averaging over half hour intervals?
Did you try 10 min intervals?

Do you get paid the export tariff based on deemed export e.g half total generation? or is it metered? How much do you get for that?

I tried 10 minutes, which turned out to be slightly lower still. I get my consumption and solar totals directly from my inverter (I must write a how-to for it), and so are limited to the granularity that is reported (0.1 kWh). Perhaps that results to inaccuracies in the simulation?

Through *Octopus Outgoing**, they will (eventually) pay me 7.5p per kWh that I export. Given that I try to use as much of what I generate as I can, this is peanuts but still worth adding in.

*This is known more broadly as Smart Export Guarentee (SEG), seperate from main tariff or supplier, requires a smart meter, and is not available to users on TOU tariffs. This replaces the feed-in-tariff payments that older installations benefit from. I think Octopus

1 Like

Thanks @Timbones yes, maybe an issue with granularity, I can see a 1-7 kWh difference in my solar direct figures depending on the resolution, you seem to be getting 4-17 kWh difference between actual and simulation, perhaps a portion is resolution based and a portion to do with control algorithm…

I’ve added in an export unit rate option in the latest:

1 Like

Hello @steve-oemon

Yes you do need to update everything to master. On the Admin > Components page you can click on ‘Master’ right at the top and it will work through all the modules for you:

You can switch back to stable at any time if you like.

SEG is 4.1p (Go, Intelligent, most TOU tariff users except Agile importers)
Outgoing Fixed is 7.5p
And then there’s the currently crazy priced Agile Outgoing (peaked at nearly 60p/unit yesterday)

I put a table on the site showing the available tariff combinations.



I already have a 13.5 kwh battery installed. This is the simulation:

following parameters:

The stats of last month:

This is the real statistics of the last year:

Note before I installed the battery, my self consumption was max 35%. By installing the system, I increased that to 74-75%. Giving the experience I have now, I would probably double my battery capacity. The off days (which are quite a few in Belgium) I would be able to run on the spare capacity from the battery, since I push back a lot to the grid and I would probably be able to get 80-85% I have done simulations with the old planner to decide what capacity I should use before buying my battery. This made me conclude that 13.5 kWh would be the best fit for the money. I recently did some new simulations after collecting 1.5 year of data. I should be able to increase my self usage, but I really need to dig into it again. I did some tricks to calculate the real meter usage and used that as combined input suggesting solar for feedback and normal usage when pulling from the grid. The process however is cumbersome, since you have to create a full sweep each time you want to change the battery parameters. So far this new app looks great, I’ll have to play with the parameters some more to see what can be achieved.
Need to add, I’m not charging from the grid. I built some automation in home assistant already to be able to charge between the seasons, but I’m still working on the code, so it’s far from complete. I have a fixed price, no peak or off hours, so I’m not yet obliged to do the charging (yet)

1 Like

I also want to note the calculation is based on the kwh feed instead of the real usage. It might be easier to calculate the kwh on the fly. My kwh feed was in error, since I had some issues with my raspberry pi last week which I didn’t notice.

This causes the total calculation for August to be completely off.

so I fixed my kwh feeds:


Month Use Solar Import Export Solar direct Charge Discharge Import Cost Export Value Ref Cost
September 2021 781 kWh 772 kWh 130 kWh 110 kWh 501 kWh 258 kWh 245 kWh £32.87 £27.61 £95.45
October 2021 589 kWh 434 kWh 227 kWh 58 kWh 297 kWh 265 kWh 248 kWh £56.87 £14.54 £99.82
November 2021 471 kWh 167 kWh 329 kWh 20 kWh 128 kWh 294 kWh 286 kWh £85.33 £5.12 £119.45
December 2021 461 kWh 75 kWh 396 kWh 0 kWh 70 kWh 329 kWh 316 kWh £103.62 £0.00 £137.19
January 2022 436 kWh 129 kWh 336 kWh 10 kWh 102 kWh 288 kWh 265 kWh £88.40 £2.51 £116.81
February 2022 427 kWh 317 kWh 176 kWh 62 kWh 213 kWh 209 kWh 202 kWh £44.42 £15.62 £75.61
March 2022 690 kWh 788 kWh 108 kWh 196 kWh 495 kWh 192 kWh 180 kWh £26.92 £49.08 £66.92
April 2022 766 kWh 971 kWh 27 kWh 226 kWh 619 kWh 154 kWh 145 kWh £7.06 £56.54 £50.28
May 2022 860 kWh 1221 kWh 9 kWh 367 kWh 719 kWh 146 kWh 139 kWh £2.26 £91.69 £47.69
June 2022 918 kWh 1250 kWh 7 kWh 337 kWh 780 kWh 142 kWh 138 kWh £1.78 £84.35 £46.58
July 2022 944 kWh 1327 kWh 12 kWh 387 kWh 825 kWh 126 kWh 116 kWh £2.91 £96.81 £39.84
August 2022 922 kWh 1070 kWh 68 kWh 211 kWh 710 kWh 190 kWh 182 kWh £19.96 £52.70 £71.70
TOTAL 8266 kWh 8520 kWh 1826 kWh 1986 kWh 5458 kWh 2592 kWh 2460 kWh £472.40 £496.57 £967.34

Savings and payback

Annual import saving £991.51
Simple payback (system cost / import saving) 8.1 years
Annual solar & battery system cost £400.00
Annual solar & battery system + import cost £375.83
Annual averaged unit price 4.55 p/kWh
Note the calculation should be in euro’s here not pounds. I am receiving green power certificates for part of my current installation. For 5 kWh solar, every 1000kWh pushed back to the grid results in a certificate of 300 euro, so I have on average an additional 4.5 * 300 = 1350 euro reduction per year. This reduces my payback time even more. Calculation is done based on prices of a new inverter + battery with this capacity, no solar panels added, since I had those already on my roof. It matches the payback time I was expecting to achieve.

I have a solar and battery system since February, I do not have an EV and thus have been making use of octopus agile outgoing.

Initially I did the payback criteria for the system on the SEG rate of 4.5p per kWh export (and thus did not really design the system for much export)- oh boy have I been proved wrong and for those without an EV a system talored for export can be extremely favourable.

Over the last 122 days I’ve averaged 25.6p per kWh export and 49.6p over the last 14 days whilst not having any grid import.

Also for some week the export rate per kWh in every single agile slot has been more than the import rate, so it doesn’t even make sense to charge a battery with solar at all…


I have currently 9.6 kWh of battery storage (8.64 usable) since February, and I’ve been thinking of buying an extra 2.4 kWh to add to that (up to 10.8 usable). This simulator lets me experiment with the numbers to see if this is a worthwhile upgrade:

  • actual battery discharge since install = 1080 kWh
  • simulated 8.64 kWh battery discharge = 1086 kWh (pretty close!)
  • simulated 10.8 kWh battery discharge = 1127 kWh

This shows just 4% extra power from the battery, for 25% extra cost; which convinces me that buying another battery module wouldn’t be worth it. The payback time would be around 50 years!

Now, this is without any cheap tariff or overnight charging. Running the simulation again with overnight charging enabled gives me 1707 kWh vs. 1882 kWh - this is 60% more battery use than without overnight charging, plus another 10% when adding another battery. Payback period becomes more like 15 years. So maybe I’ll revisit this when I get hold of a TOU tariff… (and when I have a whole year of usage data)

I think I’ll be doing the same as soon as I get my export MPAN.

1 Like

I’ve only just got my export and that took me by surprise. When I set out to get solar panels a year ago, it wasn’t clear that Octopus Agile would beat their fixed 7.5p/unit, but now it also beats some of the old FIT rates!

And yes, it’s thrown the question of adding a battery into doubt.

I’ve recently ordered a GivEnergy battery and have existing solar so am interested in trying this.

I can’t update the App component to master because of some local l changes I have made:

What’s the easiest way of resetting it to the stable branch? I tried manually adding the solarbatterysim folder to /var/www/emoncms/Modules/app/apps/OpenEnergyMonitor/ but it’s not showing up when I try to add a new app.

1 Like

@markb you can use git magic to do this. Just go to your git repo where you made the changes. Here is a simple example for the usefullscripts repo

[email protected]:~/usefulscripts/process# git status
On branch stable
Your branch is up to date with 'origin/stable'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   power_to_kwh_manual.php

no changes added to commit (use "git add" and/or "git commit -a")
[email protected]:~/usefulscripts/process# git stash
Saved working directory and index state WIP on stable: 8750e49 update version
[email protected]:~/usefulscripts/process# git fetch
[email protected]:~/usefulscripts/process# git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
[email protected]:~/usefulscripts/process# git stash pop
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   power_to_kwh_manual.php

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/[email protected]{0} (9a098ea5a1af384725f9064082f9c4e6c9ef9052)

after this you should have your changed merged with master if they didn’t conflict.
If they did, you can see the conflicting files with

git status
1 Like

Thanks! I had to do a bit more fiddling around with git but got there in the end.

One could also consider that pushing excess solar PV into the immersion heater isn’t “free” after all, as this will effectively “cost” whatever the outgoing tariff would have been if it was exported instead.