diy solar

diy solar

Growatt To MQTT ( Home Assistant ) - Python Server / Script

hotnoob

New Member
Joined
Apr 1, 2020
Messages
21
edit: add intro vid to project
---
Started this last night, because i wasn't able to find a working solution for my inverter. so... i made one.
I started with someone else's random code, and basically rewrote the whole thing. so its a whole new beast... and i thought i'd share it.

This allows you to plug your inverter into a server / computer / device with usb, and have it dish out it's information to Home Assistant via MQTT.
This works for my inverter, Growatt SFP 12000T. so if you have a growatt spf inverter roughly 2020 or newer. this will work right now.
I wrote it in a way that other protocols can also be added easily via csv files. if someone wants to, they can add the older protocols by copying the tables in the documentation, into the csv files.

tl;dr
works for latest model
older / newer models can be added with a bit of data entry
newer growatt inverter + usb cable + computer = fancy dashboard



attached is just a very quick dashboard in home assistant. no where near the limit of what you can view.

https://github.com/HotNoob/growatt2mqtt-hotnoob

installation instructions are in the repo; keep in mind i started this last night.
i'm running this on a vm running linux, but should also work on windows ( might need to find a driver ).
the usb port should show up as a serial port.

enjoy.
 

Attachments

  • home assistant example.png
    home assistant example.png
    105.3 KB · Views: 11
  • growatt mqtt service.png
    growatt mqtt service.png
    56.5 KB · Views: 11
Last edited:
Nice work.

Are you able to send commands to change the inverter's operating mode and other parameters?

Like many, I'm using Solar Assistant as the MQTT link with Home Assistant and it's been doing a good job.

But if I did what you have I'd probably use an RPi or something like that to be the Growatt "server". No way I could write the code though like you have done.
 
pymodbus does the heavy lifting.

haven't tried sending commands, but probably do-able...
however, it's not a good idea, because acording to the documentation... there are a several settings that really shouldn't be writeable, but are.
so you could potentially brick your inverter by having the wrong protocol or "address".
since there isnt much to verify that your writting at the right spot.

forexample:

18​
OutputVoltType​
Output Volt Type​
W​
0: 208VAC 1: 230VAC 2: 240VAC 3:220VAC 4:100VAC 5:110VAC 6:120VAC​
19​
OutputFreqType​
Output Freq Type​
W​
0: 50Hz 1: 60Hz​

31​
FlashStart​
Update firmware​
W​
0x0001: own 0X0100: control broad​

acording to the protocol docs, it's all writeable.
accidentally changing the voltage from 100 to 240 seems like it could be a really bad day for someone :p
heck, just send a 3 instead of a 4. kaboom!

best to avoid it.

---
actually, that's a scary thought; those wifi sticks give full remote access to a chinese company with probably terrible security.
imagine someone hacking into growatt and issuing commands to randomly change the hz and voltages...
yup. no wifi stick for me plz :p
 
Last edited:
haven't tried sending commands, but probably do-able...
I do it all the time using the Solar Assistant MQTT.

I have a range of Home Assistant automations set up. Changes to operating mode between Utility First and SBU, determines when/if supplemental battery charging is needed, if so adjusts the charge rate based on available excess PV output, I even have a "Storm Mode" button.

But yeah, I can imagine the writable registers need to be handled with great care.

Screen Shot 2024-02-21 at 4.46.27 pm.png
Screen Shot 2024-02-21 at 4.46.43 pm.png
 
50hz 230v, something wrong with the grid power over there. 245v is above 10% tolerance. could fry 230v electronics. :p

honestly, the inverters seem to be all the same to me. everyone is stealing or sharing all of the hardware and software designed inbetween them. or rebranding everything. i have signineer inverters in parallel in another setup. but the thing i noticed about the parallel setup is they have high idle usage. so in this new one, i opted for a single inverter; the growatt spf 12000t.

all of them are all low freq; although the growatt one is... pretty loud compared to my older sigineers. i also suspect the idle consumption to be slightly higher than spec. oddly, the inverter itself sits at 30-40*C 24/7 when idle.

i think the worst part of the spf 12000t, is how heavy it is. i used a block of wood between the joists and 3 ratchet straps to hoist it up during installation. but that could be a sign of quality :p
 
oh, i did have an idea last night on how i could write a protocol detection feature; then it would be much safer to write / send commands.

not sure if i'll implement it; i am tight on time... lots todo out here. :p
 
oh... decided to do a rebranding.

InverterModBusToMQTT, since this can easily do any inverter that does modbus over serial ( USB-B Port ) and... i started adding my sigineer inverters.

i think EG4 is big in the states, so i'll do that one after sigineer.
 
245v is above 10% tolerance. could fry 230v electronics
Think you need to check your maths :)

Our single phase grid standard is 230 V AC -6% (216 V) to +10% (253 V).

In reality much of the country still runs at the older 240 V level.

Me, heh I see everything from 215-260 V, which can happen when you are the end of a rural power line.

Good luck with the programming, lots of possibilities.
 
i've just added write support. need more testing and programming but it is working.
currently has strict requirements before writing can be enabled.


i'll be adding a manual verification process in-case of unverifable protocols, later.

tl;dr, write support should be usable in a few weeks.
 
Big rewrite / renaming of the project.

growatt specific instructions :

if you have trouble understanding instructions, please let me know. with the big rewrite i'm not sure how to explain things in a user-friendly way.
 
Back
Top