Adding Growatt inverters to Home assistant.
A while ago i got two Growatt inverters, however the only way to check the inverters was by using their app, or their website. However their website was not very pretty or optimised, and i’d end up rarely using their app. But i did have Home Assistant, however Home Assistant did not have any integration for it… Yet.
Before i put too much work into creating everything myself i should search if someone may have done it before.
That’s when i found some code connecting to the inverter, and it worked. However not quite as i wanted since i only got combined info, and i wanted the information for the inverter itself.
However it did give me a BIG head start, and an idea of how and where to go further
Getting the data i want
Since the data that was available in the thread wasn’t everything i wanted yet i decided to try to get more data by capturing the requests that the ShinePhone app sends and recieves.
I did this using the NetCapture app. When i started the capture and loaded the inverters in a plant i got a result like this:
Which give me information of the plant, and a list of all inverters connected to the plant.
Creating a Python API class
Now that i knew how to get my data i needed to translate this to Python to actually use this data. So i made a API class for this, so for my applications i’ll only have to import the Growatt Server package and i’ll easily be able to get the data i need.
Getting this working in Python was pretty easy as you can see here.
Get the inverter in Home Assistant
Now that i have this API class running i should easily be able to apply this to Home Assistant.
However it still had a challenge ready for me, which is not trying to spam the Growatt endpoints for data.
Since Home Assistant works in sensors which take care of their own states if i were to make all sensors for every inverter. Growatt would be recieving around 30 requests every 5 minutes, which if i were to guess would get their attention and strain their API if done in big enough numbers.
So i had to create a class that gets between the sensors and the API class to “Cache” the data recieved from the API.
After getting some help from the Home Assistant devs i got this class made and got the integration buit into Home Assistant.