I’ve been working on automating the solar plant for charging the electric car. There is a lot more nuance than I anticipated.

When I was grid-connected, it was pretty simple. Whenever we parked the car, we plugged it in. The car itself had a simple scheduling system and it would start charging at midnight, when the electric utility gave us a special discounted EV rate for the power. Since we are usually up during the day and would sleep at least six hours every night, we could pretty much count on the car having a full charge when we needed it the next morning.

Charging on solar is much more complicated.

  • The car’s battery, at 85 kWh, is much larger than the solar plant’s battery (20 kWh).
  • When we drive, it’s most often during the day when the sun is shining.

That presents a problem. If we tried to emulate the grid-connected model and charge overnight, we would quickly deplete the house batteries and wake up to a dark, silent, cold home WITH NO COFFEE. There are also difficult-to-characterize inefficiencies in charging one bank of batteries from the sun and then transferring the power to another bank of batteries in the car. Power would go from the panels to the inverter to the battery management system (BMS) for the plant to the plant batteries then back through the inverter to the car’s BMS then to the car battery. The published efficiencies at each of those steps seem… optimistic to me, usually around 95%. Even so, starting with 100 kWh the trip from panel to car would leave us with closer to 75 kWh. Avoiding the round trip through the plant batteries — charging when the sun is shining — seems prudent even if we could afford the massive capital investment in batteries it would take to make overnight charging possible.

Fortunately, we are retired and the car is home a good part of most days, and the weather has cooperated (from a solar energy perspective) by being sunny a for at least a few hours almost every day. Since installing the plant last November, we have only needed to run the backup generator two times beyond the usual 30 minutes per month I run it for testing and maintenance. One of those times, I wasn’t paying attention and managed one morning to drain the house batteries to 12%, at which point the inverter shut down to protect the batteries from excessive discharge. The other time, we wanted to take Joulee the Free Salvage Tesla on a road trip instead of taking Timmy the Titan, and we had drained Joulee’s battery the day before on another long trip. So it was an optional run (we could have just taken Timmy), but it was still the environmentally more sound solution. Running the generator meant that we, ultimately, were driving a gasoline-powered car, but one that is extraordinarily efficient in its own right plus every gallon of gasoline was more-or-less matched with an equal contribution from sunshine.

So what does this have to do with hacking?

The only way that I managed to keep the car charged up was by constantly monitoring the state of the solar plant (thanks, Solar Assistant!) and adjusting the car rate-of-charge manually every few minutes to balance charging the car against the need to keep the plant batteries charged enough to get us through the night. In fact, I think the day we ran out of plant battery was the only morning that I didn’t check the state-of-charge at least once before getting out of bed. All this time, I’ve been trying to work out how to automate it. I’m taking a trip soon, and doing manual, real-time load management is too far outside HA’s bailiwick to expect her to manage it.

I had to figure out how to control charging a Tesla programmatically. I had to assemble hardware and software to monitor the state of the solar plant. Even after I had learned the nuance around Solar Assistant and Tesla’s APIs, I then had to integrate everything. I did that with Home Assistant, but that added a whole new level of challenge: how to code in a declarative language (YAML) instead of more-familiar-to-me procedural languages (such as perl, Python, and glorious forth). Even after I had begun to learn YAML, I found that there were quirks using it and integrating with Home Assistant. And of course I discovered that the solar inverter didn’t have the capacity it claimed to have.

Then there were the failures. Lots and lots of failures. Each one increased my fund of knowledge a little bit.

What I ended up with was something far different than what I originally envisioned. If I had been compelled (as often happens in industry) to come up with a roadmap and milestones for development of this system, we would have ended up spending more time documenting and justifying deviations from the plan than we would have building product. I’ve seen that happen over and over and over again in industry.

I was head of engineering at a company many years ago that actually made a fair number of remarkable, innovative products. I was associated with them long enough to see a pattern to how they achieved this innovation. The company started with a single engineer who worked a few miracles. Financial success ensued, and the company founder became convinced he must be god’s gift and hired marketing and management staff. Said founder and staff then proceeded to micromanage development and no further innovations were forthcoming. That went on until the company was on the verge of bankruptcy (at one point, I was bringing my own pencils into work) and then one or two of the engineers — left alone by the flailing management staff who were too busy trying to keep the ship afloat to micromanage — would effectively create a skunkworks project that addressed a real need, was developed in a timely fashion, and worked really well. Then the company could use its marketing, networking, sales, and production resources to bring the innovation to market. Big bucks were earned, though it seemed the profits got soaked up in the management layers and never trickled down to the innovators. Management again became convinced of their genius and insight and would return to their meddling ways, and the cycle would repeat.

The things I’ve done in my IT career that I’m most proud of and that did the most good in the world were all developed in relative isolation, with a bare minimum of oversight, relying on the vision and dedication of the creators. The most frustrating experiences I’ve had are when companies brought money (or, egad, venture capital) to the game along with the need for “some sort of oversight and accountability.”

My first job in IT was working for a small company where they were willing to let me (or were unaware that I would) come in after hours and just spend oodles of time off-the-clock playing with the machines. It worked for me, as access to computers was difficult to come by in those days and making machines sing was my passion. It worked for them: the founders made literal millions of (1970’s) dollars from the innovations I was able to craft during those long, unstructured overnight hacking binges.

Having the freedom to spend too much time in unstructured pursuit of vague, shifting goals is the essence of hacking. In my experience, it’s where all the innovation has blossomed.

I’m going to publish the charge management code here (it’s refreshingly brief) after I’ve taken more unstructured time to test and tune it.

—2p

← previous|next →