muppet3000 / homeassistant-grott

Home Assistant Integration for Grott - MQTT
MIT License
65 stars 14 forks source link

Help with controlling inverter directly #89

Open slovely opened 1 week ago

slovely commented 1 week ago

Hi, hoping to pick your wonderful brains again with a query about setting/reading inverter options via a direct request.

I'm using grott and home assistant and it's working brilliantly. I know that GrottServer allows you to control the inverter, but at this point in time I would rather keep with the official growatt site if possibly. I'm wondering if you have any bright ideas on how I can set and read the following item in the inverter settings:

image

I did resort to using Playwright to automate a browser session, which worked for a while but now just times out loading the page. Feels like somehow they are blocking my requests.

I've had a look at the code for grottserver, but my Python isn't up to much unfortunately, so I'm struggling to understand exactly what it is doing.

Is there a way I can fire a request of some kind at the datalogger IP to read/write the setting? Or does it rely on the open connection to Growatt (or grottserver) to send/read the inverter settings?

Thanks for your help.

(PS This is an SPH inverter)

tabascoz commented 1 week ago

Hi there, i think so.

But struggling to get what is this parameter related to. Would it be to get back to grid once the SOC reaches 10%? please confirm and I'll check and revert.

Cheers, Fernando

slovely commented 1 week ago

Hi @tabascoz

Yes, this is the SOC when the batteries will be, in effect, turned off and the load will be supplied by the Grid (or PV if available).

The reason for this is to automatically stop the battery when EV is charging - want that from the grid rather than draining house battery.

muppet3000 commented 1 week ago

The request to the datalogger IP would need to be wrapped in some form of modbus/growatt wrapper that I really don't know enough about to be able to advise on. I've been using grottserver for about a year now and have a series of curl requests to dynamically configure my AC charging etc overnight based on the predicted PV generation for the next day. I'm half way through writing a python library for it which I'll then write a wrapper around so we can use it as a HomeAssistant integration, I just haven't had the time recently. I'll happily share some stuff tomorrow on how my grottserver setup is working (not at my desk currently).

Unrelated, I've been having no end of problems with the datalogger from my system since the weekend after I had a power outage to do some electrical work. I think I'm one of the only people using the older style ShineLanLink box instead of a Wifi stick and I think something is interfering with the RF signal between them. I've got a wifi stick coming in the next couple of days that I'm hoping I can switch over to and it'll solve my problems.

tabascoz commented 1 week ago

Short answer: parameter 37. for ex:

curl -X PUT '192.168.0.xxx:5782/inverter?command=register&register=37&inverter=SERIALNM&value=10'

Would do the trick. However, some considerations. to use % values it's only possible if you have the inverter set to talk to the battery bank BMS (battery type set to lithium). I have it and tried with mine, the parameter in my inverter is exactly at 10% like you want, but I've tried to change it from Grott and it didn't work.To be honest this is the one of the (rare) only parameters i never tried to change using Grott as it is ( from my implementation perspective) it a "fail safe" value. To be used only if the automation, for any given reason, don't kick in.

I have an EV also and i do charge it from batteries. I am almost grid-free and I aim to not spend all the battery with EV charging.For that I have Home Assistant and Nodered doing the automation and I can control the parameters and solar production forecast to orchestrate solar utilization.

So you could do the same by changing the inverter mode from SBU to UTI and it would stop using batteries immediately.

slovely commented 1 week ago

@tabascoz Thanks - that looks like a request to GrottServer though, isn't it? I'm not using grottserver at the moment (only grott), as for now I want to keep using the official website/app. Might change that in the future though!

@muppet3000 Ahh, I had assumed that grottserver needed to do the modbus stuff so thought you had figured it out :) Probably my lack of knowledge on how it all fits together! I just assumed that was how grottserver sent those requests to the inverter.

Thinking about it - if I change a setting on the Growatt website, does that go "through" grott? I wonder if I could put a call into grott to make it send the correct message (not sure if I can figure that out!) when I request it, rather than the website.

muppet3000 commented 1 week ago

When you change the setting via the website yes it flows through grott, I don't understand enough about it's implementation but the grottserver spoofs the logic of the growatt servers. There may be some specific logic that you could extract from that, however it wouldn't surprise me if there's some form of handshake between grott and whatever 'server' it's talking to, and you'd need to complete that as well.

Last time I looked at the grottserver discussion someone was working on a version of grott/grottserver that allowed data to be published to both the growatt servers AND grottserver which would help with the problem, but I have no idea where that has got to.

slovely commented 1 week ago

Yeah - you know I made the classic mistake of thinking it was you that wrote grottserver! 🤦

I probably opened this in the wrong place - appreciate your help and ideas though! The HA bit that you did do is working great!