Solar Dashboard - The vision: Raspberry Pi, Postgres and Grafana

In the interest of not falling into endless gold-plating and feature creep loop, I had to keep my desires in-check. Compromises were made to keep the project focused and maintainable.

Focused list of improvements

Mainly address my complaints about the old dashboard, as listed in the challenge.

I settled on relaxed requirement around encryption between inverter and the homelab, because the risk is mitigated by my setup:

  • The inverter's messages carry no PII or credentials, only serial numbers and readings. The names, postal address, email, phone number and password were all on the vendor's website, which I no longer need to log in to
  • The relay hands the messages to the forwarder over HTTP too, but every request and response is signed with HMAC, which is fine over HTTP
  • The unencrypted transmission of my own data stays within my network boundary. The copy for the old dashboard still crosses the Internet in plain HTTP, for as long as I decide to keep it fed
  • Risk of impersonation/poisoning is mitigated by IP whitelist on the inverter's side and HMAC signing between the relay and the forwarder

I specified some hardline constraints too:

  • no extra hardware on the inverter's side, the communication module stays as it is and only the URL it reports to changes,
  • no subscription, everything runs on hardware I already own,
  • the old dashboard keeps receiving messages for as long as I need it as a reference

There were other, more specific requirements that I wanted to name.

Use my own platform

I wanted to use my Kubernetes-based homelab to host as much of the solution as possible. Hosting the solution in my homelab allows me to test and improve homelab itself.

Keeping it away from the cloud means I lower the cost and don't expose my services to the Internet. I like to make my solutions recover easily from power-cut which means I can just shut down my homelab without too much stress.

No power therefore no running cost, and no attack surface 🥹

I do admit that I like to run code that crosses hardware boundary collocated with that hardware. There were a few experiments I conducted as part of this project which required the inverter to be talking directly to the homelab, using plaintext. Being local to each other helped with deferring security concerns.

I could use VPN to provide a secure wrapping channel, and for a day I did. Then I chose a simpler way: the relay holds no database credential, and the forwarder pulls from it with every request signed.

Make the data flow survive homelab experiments

Bearing in mind my destructive experiments on the homelab and occasional need to just turn it off, I needed a simple and stable buffer between the inverter and the homelab. Something that would keep the data continuity while the homelab was temporarily unavailable.

A Raspberry Pi does a great job at that. It's a relatively low-powered device that, given stable OS and an external drive, achieves long, bother-free runtimes.

This component is called the relay because, in the early phases of the project it was relaying the requests (and responses) from the inverter to the old solution. All while buffering raw messages from the inverter. It also provides a simple API to fetch the buffered data.

The component that will use that API to pull the buffered data is called the forwarder. It transports messages from the relay (inverter) to the dashboard's database.

Predictable data storage

For the database I picked Postgres as free, powerful and extendable DBMS. I considered architecture using time-series or work queues and Postgres deals with both via extensions.

Visualize it all

The one extra and key feature was about adding visualizations as I clearly wanted dashboard that allows the instant reconnaissance and helps with post-mortem of various power issues.

I want every value to show with a readable label, correct scale and correct unit. A good dashboard should not make user to be guessing the above.

I chose to use Grafana due to having some previous experience. I have made some and seen many more nice and useful Grafana dashboards, so I know it is a great tool for the job.
Grafana reads Postgres natively so it all fits.

Use case

The observability baked into the new system will enable objective and continuous measurement of the installation.

I want to use it to assess the electrical health of my solar setup and optimize its efficiency, if feasible.

Once the metrics are in, the system can alert about anomalies (abnormal voltage level, overheating, communication attempt from unknown client etc.) as well as the normal operating pressures (utility disconnect, low battery, approaching the power ceiling, and so on). I think this will be very useful but the fact it is possible is just a simple consequence of a decision to use Grafana as it is a built-in feature.


Other posts in solar-dash series