Collecting data from a Growatt solar inverter
I own a Growatt solar inverter and I decided it would be nice to collect some of the data it emits. At the moment the goal is to have more charts in Grafana but this also opens up the possibility of integrating this data with weather forecasts and energy prices to optimise usage patterns.
By default Growatt inverters sends data to their own server and data is accessible via a web ui and mobile apps. That's more than enough to monitor and control the system, but we all know that the real reason we do this kind of projects is to have fun.
Fetching data from the Growatt API
Given data is already on a server a way of obtaining it is via API calls. This is the method I originally relied on but it proved to be brittle. Changes in the backend broke the client I was using, which I guess was just pretending to be the web app or a mobile app. I believe there are more official APIs that can be used but when I was looking into it they were are affected by server issues too and I haven’t found any client using them.
Entirely independent data collection via Modbus
The inverter exposes data via Modbus. Growatt sells WiFi dongles that read this data and send it to their servers but nothing prevents to use our own dongle. I found a few options following this approach. As an example have a look at:
- Solar Assistant, which provides its own dashboards and web UI;
- modified firmwares for the Growatt dongles like otti/Growatt_ShineWiFi-S that read data and publish it to MQTT;
This approach works but requires either to buy new hardware or to fiddle with the existing one. Going this way would also mean no data for the web UI/webapps.
What I like the most of this approach is that it offers a great alternative if the official Growatt apps are ever going to stop working, which is sadly always a risk with Internet-connected Io devices.
Intercepting data emitted by the WiFi dongle
The WiFi dongle allows us to configure which server it should talk to.
By pointing it to a server we control we can proxy the communication it has with the Growatt server, decode the messages (encoded in a underdocumented variant of Modbus TCP) and have the data we were looking for.
This is the approach used in johanmeijer/grott and aaronjbrown/PyGrowatt.
grott can operate both in a mode where it forwards data to the Growatt server and in a mode where it acts as a server.
PyGrowatt can only act as a server without doing the forwarding.
These two project did a bunch of work to decode the messages (
PyGrowatt even comes with a Wireshark plugin) and
grott seems to be the more popular, probably because it integrates with Home Assistant and because it can decode messages from many different Growatt inverter models.
What I am using
None of the above!
I originally went the API route using indykoning/PyPi_GrowattServer but the API broke and I then switched to
After looking at the source code of
PyGrowatt I decided that their approach is simple enough and a very good fit to have my own project that follows their footsteps.
Of course I am writing it in Rust.