Building a personalized solar payback calculator with AI

Solar systems have come a long way in recent years, especially with the addition of batteries that enable households to “save up” power generated during the peak of the day and use it later in the evening.

This weekend, I’ve been trying to do some math around the payback period — essentially, whether it makes financial sense to install solar. The problem is that most calculators I find online are generic and, to be honest, a bit thick-headed. They don’t factor in the specific sunlight my house receives and rely on a lot of guestimates to come up with an answer — not the kind of due diligence I want to rely on before dropping tens of thousands of dollars on a system.


Quick conclusion: If you live in your forever home, it is very likely that installing solar is a great idea today financially, because:

  • Solar systems are cheaper than ever; For example Trade Depot has their various systems broken down by specs including installation listed transparently on their website (Trade Depot).
  • All the major banks offer "green loans" at 0% or 1% interest fixed for 3-5 years which offset the cost of installation as a home loan top-up.
  • New Zealand's total power generation isn't increasing anytime soon; therefore, the cost of power is unlikely to reduce.

All this is good to say, but I want some solid data to back this up! So, what do I do? Of-course this is the age of AI, so I spent my Sunday vibe coding a personalized solar payback calculator, that takes into consideration:

  • The exact sunlight a property receives on an hourly and daily basis based on NIWA calculations using the typical meteorological table.
  • The exact half-hourly usage data that I can export from my power provider for the entire year
  • My current and future providers
  • Input fields for the specs of any solar system I'm considering
  • Compare my current provider who I'd stay with, without solar since they offer the best pricing, vs switching to a new "solar friendly" provider who would be way more expensive to switch now but makes sense with solar, so I can truly understand the "savings", as otherwise the payback period and "expected savings" would be artificially more / faster.
The key thing to remember is the hour-by-hour analysis of generation and consumption, this provides a very accurate view of when and how power will be generated and used. Of-course there are issues like unpredictable weather, varying usage patterns, etc, but it's still way better than a generic annual usage by day and night, and at the very least, gives you a clear result on how much you'd save over the last 12 months.

The system simulation worked beautifully and far better than I expected. I'm able to input the relevant fields, import in the solar data and my own personal usage data, and instantly see what my savings and payback period are based on my initial investment using a full system simulation. I could go further and do present value calculations, etc, but I think this is way better than what's available today and "good enough".


As a reminder, NIWA has mapped out the amount of solar any given location in New Zealand will get at any hour and day of the year. This is incredibly useful as it gives a very accurate hour by hour perspective for the simulation my app runs above.


And as per New Zealand regulations, all power companies must display and allow export of consumption data in a standardised format, which is perfect to import into an app, as an example, this is my mercury hourly dashboard (Their csv format has half hourly exported for the entire year!):



Before the age of AI and vibe coding, something like this would have taken me weeks having all but forgotten the intricate details of programming. It's incredible how AI and especially coding agents like Co-pilot with Grok Code, can accelerate development and help answers so fast.

Now, in our own personal context, we are not going with solar. Our current home is unlikely to be our forever home (we're still looking for that, you can read about my data driven journey here), so the 7ish year payback period doesn't make sense for us. But it might make sense for you.

I haven't made my app a public repository (yet), as I don't know if it'll work beyond Mercury. If you're keen to help me expand the features and make this open source, leave me a note!


For extra context, here is how my app works (AI generated)

Assumptions & Logic

CategoryAssumption/Logic
Energy Consumption Priority1. Solar power used first (direct consumption)
2. Battery power used second
3. Grid power used last
Excess Energy Priority1. Charge battery first (if enabled and capacity available)
2. Export remainder to grid at export rate
Solar GenerationBased on NIWA TMY "Tilted Irr." data with 80% performance ratio
Limited by inverter capacity (kW rating)
Battery Efficiency90% round-trip efficiency (95% charge × 95% discharge)
Power limited by inverter capacity
Time-of-Use RatesDay rate: 7:00 AM - 9:00 PM
Night rate: 9:00 PM - 7:00 AM
Applied to both grid purchases and usage calculations
Provider ComparisonBaseline cost uses current provider rates
Solar cost uses future provider rates (allowing provider switch)
Savings = Current provider cost - Future provider cost with solar
Daily Fixed ChargesCurrent provider fixed charge applied to baseline scenario
Future provider fixed charge applied to solar scenario
Both increase annually by inflation rate
Price InflationSame inflation rate applied to both provider rates and fixed charges
Export rate remains constant (no inflation)
Usage Data30-minute intervals summed to hourly consumption
If no usage file: annual estimates divided by time periods
Payback CalculationCumulative savings start at negative installation cost
Payback achieved when cumulative savings become positive
Simulation PeriodHourly simulation over 365 days using TMY weather data
10-year financial projection with compounding inflation