Americans are so accustomed to reliable electricity that lives often depend on it. People with sleep apnea rely on electricity to keep them breathing through the night. People with diabetes need electricity to keep their insulin cold.

In California, however, the flow of electricity is no longer a sure thing. As the weather gets hotter and drier, utilities have begun shutting off power for days to keep electric lines from starting forest fires. When Pacific Gas & Electric flipped the switch in fire country last fall, food spoiled as freezers thawed and cars crashed as drivers attempted to navigate without traffic lights. [I kept trying to turn light switches on, so used to electricity that some stubborn part of my brain refused to accept that it was unavailable.]

Naturally enough, gas-powered generator sales are booming. But a new, little-noticed report suggests a better option for backup power: solar panels and batteries. It turns out that buying solar panels and batteries can be cheaper than buying a generator — given some patience, or financing.

“The good news is that solar and storage is cost effective, mostly because they provide value every day, not just during outages, cutting utility bills,” said Bentham Paulos, an author of the report commissioned by the nonprofit advocacy group Vote Solar based in Oakland, California.

Grist thanks its sponsors. Become one.

I have to admit, I was skeptical. After all, a residential solar and battery system will set you back at least $27,000 — a lot more than the $3,000-ish needed to set up a portable generator.

So how can this be cheaper? In a word, time. Though it’s more expensive to install solar panels and batteries in the short run, the setup will eventually pay for itself by nearly eliminating electric power bills. Many Californians pay $1,500 a year for electricity. Let that run for 20 years, and you are talking about the price of a new pickup truck. Consider all the subsidies that the federal government pays to people who buy batteries and solar panels, and the renewable system is clearly cheaper.

Grist thanks its sponsors. Become one.

The trick is figuring out the financing so that people can take advantage of the 20-year savings. The report offers a bunch of suggestions: local governments, for instance, could provide the cash, then take a piece of the savings as the money rolls in.

Paulos worked with Spencer Fields from EnergySage, a solar comparison-shopping business based in Boston, and they both got on the phone with me to explain their reasoning. Fields sent a spreadsheet showing their math, so I could tweak the numbers and try out different scenarios. They assumed that electricity bills would immediately leap 40 percent as utilities begin switching customers to a new “time of use” pricing scheme (and then rise a little bit each year), that a homeowner would be able to buy the backup-system without a loan, and that the house would draw 8,000 kilowatt hours a year — average for homes in California’s scorching Central Valley.

With all that, there was still a 20-year savings when I adjusted the formula to include a loan and rule out the dramatic price increase. Solar was only more expensive when I had the homeowner paying less than $500 a year for electricity. After spending a few hours playing with the math, it became clear that solar and batteries can pay for themselves under lots of different scenarios. There are thousands of Californians for whom this would make sense.

This particular study didn’t consider whether it would work anywhere else in the country. The basic logic remains the same everywhere, but California offers more subsidies than other states. Solar and storage would be the cheapest option for many more Californians if utilities start treating those home batteries like a power plant for use during periods of peak demand, said Chris Burgess, who works on making clean energy work for the nonprofit Rocky Mountain Institute. “There are very few places where solar plus storage pencils out, but only because the utilities aren’t correctly valuing it. If a utility just offers peak electricity payments to customers with batteries, rather than building a new peaking gas plant, the economics start to work,” he said.

“Solar and storage gets much more valuable with scale,” Burgess said. “The future is everyone having a big battery in their house, or in their neighborhood, or in their town.”