muppet3000 / homeassistant-grott

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

Add support for MAX/MID/MAC systems #18

Closed pmp02 closed 12 months ago

pmp02 commented 1 year ago

Add support in the Grott integration for MAX/MID/MAC inverter.

Details of my installations (for better correlation with the data) are:

I've tried to match grott message to what the app shows, but I think Growatt app processes slower and it doesn't necessarily show the time when it received the message...?

Grott log message:

For the below values, Growatt App shows the following "interpretation":

This is the PV Current per phase:

Active power; Seems to be "Exported to grid" value; act_power_l1 + act_power_l2 + act_power_l3 = -6242.1 Watt (which is what app shows as exported to grid and same value as PAC - pos_act_power below);

Apparent power (zero the entire day?? don't know what this is)

Reactive power (comming from the smartmeter);

I think hte powerfactors are being used for voltage_l1 current_l1 powerfactor_l1 ???

Power factor (don't know how it's used); I have values ranging from 0.2 -> 1.0;

Growatt_1

muppet3000 commented 1 year ago

Thanks for the info, you seem to have missed the actual grott message that aligned to the message you posted above, so I'm struggling to do some of the mappings.

I've tried to do some of the mappings I need below but can you fill in some of the gaps for me?

FYI The negative values will be positive in HA because 'exported' implied that they are negative.

As you can see, there's a lot of information missing in order for me to implement this. If you can fill in the gaps I can implement something. Right now, all I can do with any level of confidence is the voltage and current for each of the phases but I don't think that's going to be overly helpful for you.

pmp02 commented 1 year ago

Hi @muppet3000 , Thanks for looking into this. I expected not to be easy from the first go :) , I couldn't match the values either.

Here is another log. I've picked up from the grott logs the entry at 7:25 and the values from the website at the exact same hour. I'm a bit in a haste right now and didn't got the time to try to do some matchings, hope it helps. grott_log..txt

pmp02 commented 1 year ago

Comming back to your message:

< NEED GROTT KEY > : Solar (7.4kw from your example) < NEED GROTT KEY > : Imported from Grid < NEED GROTT KEY > : Load Consumption

These are shown in the Growatt Dashboard, I assume calculated from the Grott values. I didn't see any keys directly from Grott with these values.

app_power_l1 : Let's just ignore this shall we? react_power_l1: Let's also ignore this one for now?

Ok

powerfactor_l1: I don't understand what this is for

I think this is used to determine the actual power output based on the solar panels actual production. So if the panels produce let's say 1 kW, and the power factor is 0.9, the actual output from the inverter is 0.9kW (the power factor is taking into account the power loss on the cables and conversion) - this is a pure assumption :). It might be used to calculate the power maybe, from Voltage and Current: Power = Voltage Current PowerFactor (? to be checked)

pos_act_energy : What is this for? rev_act_energy: What is this for?

Didn't figure it out yet.

shampeon commented 1 year ago

pos_act_energy : What is this for? rev_act_energy: What is this for?

Didn't figure it out yet.

My guess: the Growatt Dashboard allows you to calculate how much revenue you are generating from your site, as I think it's also used for commercial solar power generation.

Screen Shot 2023-06-26 at 3 01 00 PM

I have no idea how it calculates these values, fwiw.

pmp02 commented 1 year ago

Hi all,

Didn't had too much time available, but managed to activate the grotcsv extension so that it's easier to get the grott values and comapre with Growatt Website (it would be nice to have export in the Website as well :) ).

@shampeon Indeed, those are calculated from the Inverter and SmartMeter values... we just need to figure it out how :). When I'll get the change, I'll give it a deeper look and try to do some calculations and see if I can get something...

muppet3000 commented 1 year ago

Thanks guys, it'll be difficult for me to contribute the calculations etc myself. However, I've got some time in the evenings this week so I'll try and plumb through some of the values we are confident with and we'll use that as a starting point.

pmp02 commented 1 year ago

So far I have only 2 values identified:

pos_act_energy

rev_act_energy

muppet3000 commented 1 year ago

I've just realised there's some overlap here with #7 as a lot of the values seem to be similar. I'm working on a feature branch to add some of the basic values in (or at least the ones we know people can use), then people can test and feedback on what's missing.

muppet3000 commented 1 year ago

@pmp02 @shampeon - I forgot that there was already some similar discussions around this on #7, I've just made a comment over there (this one) which states what values should now be available. Could you please download the main branch through HACS and give it a test?

As I said over on the other ticket, the biggest one I can't work out is how to provide a sensor for the current PV generation - any ideas?

pmp02 commented 1 year ago

Hi @muppet3000 , thanks a lot, I'll give it a try and come back with feedback. Regarding the current PV generation, I've tried a lot of formulas and combinations of values and I didn't managed to obtain the value from the Growatt UI by no means. I don't know how they determine that.

The only formula that was able to "determine" and get close to some values (although it doesn't make too much sense to me), it was: (react_power_l1 + react_power_l2 + react_power_l3)/3 * powerfactor

But once we get all values inside HA, I can define several calculated sensors from the values and match them against growatt web site.

pmp02 commented 1 year ago

@muppet3000 I've downloaded the latest update from "main", restarted HA, but still no new entities appear for the device (still the only 2 serial entities). Is there a specific step I should do? Thanks.

muppet3000 commented 1 year ago

That's weird, in HACS can you please take a look at what version you're using: image

Main sure it's a SHA rather than a version number.

pmp02 commented 1 year ago

Yes, indeed, it still shows v1.0.1. I did all the steps again and how it shows the same SHA as in your screenshot and now I see the sensors! 🥳

Thanks a lot! Now I'll start monitoring :-).

image

muppet3000 commented 1 year ago

Awesome, keep me posted, let me know if anything is wrong - I can already see that I got some of the logos incorrect because I copied them from somewhere else! I'll fix those later. I saw your suggestion over on #7 about adding all of the MAX/MID/MAC values even though we don't know what they're for and just given them their grott names - I'll try and do that later today so that it's all plumbed through for some 'play time'

mriksman commented 1 year ago

In the first post, the attributes that are listed are for the Smart Meter SDM, not for the inverter. You don't need to do any calculations. In HA, he should have TWO devices - one for the Smart Meter, and one for the Inverter. I feel there might be some confusion?

I'd like to see @pmp02 's logs from Grott. Mine look like this; there is clearly two different messages being recieved - one from the MIN solar inverter and one from the SDM Smart Meter.

SDM Smart Meter

     - MQTT jsonmsg: 
             {"device": "XGD6CAxxxx", "time": "2023-07-06T12:41:14", "buffered": "no",
             "values": {"datalogserial": "XGD6CAxxxx", "pvserial": "HMG9Cxxxx",
             "voltage_l1": 2426, "voltage_l2": 0, "voltage_l3": 0, "Current_l1": 20,
             "Current_l2": 0, "Current_l3": 0, "act_power_l1": -2508, "act_power_l2": 0,
             "act_power_l3": 0, "app_power_l1": 3419, "app_power_l2": 0, "app_power_l3":
             0, "react_power_l1": 2354, "react_power_l2": 0, "react_power_l3": 0,
             "powerfactor_l1": -727, "powerfactor_l2": 0, "powerfactor_l3": 0,
             "pos_rev_act_power": -2508, "pos_act_power": -2508, "rev_act_power": -2508,
             "app_power": 3419, "react_power": 2354, "powerfactor": -727, "frequency":
             500, "L1-2_voltage": 0, "L2-3_voltage": 0, "L3-1_voltage": 0,
             "pos_act_energy": 11255, "rev_act_energy": 3995}}

MIN Solar Inverter

     - MQTT jsonmsg: 
             {"device": "HMG9CAxxx", "time": "2023-07-06T12:41:06", "buffered": "no",
             "values": {"datalogserial": "XGD6Cxxx", "pvserial": "HMG9CAxxx",
             "pvstatus": 1, "pvpowerin": 14507, "pv1voltage": 3192, "pv1current": 22,
             "pv1watt": 7099, "pv2voltage": 3400, "pv2current": 22, "pv2watt": 7408,
             "pvpowerout": 14219, "pvfrequentie": 5000, "pvgridvoltage": 2430,
             "pvgridcurrent": 69, "pvgridpower": 16879, "pvgridvoltage2": 0,
             "pvgridcurrent2": 0, "pvgridpower2": 0, "pvgridvoltage3": 0,
             "pvgridcurrent3": 0, "pvgridpower3": 0, "totworktime": 3961072,
             "pvenergytoday": 77, "pvenergytotal": 8340, "epvtotal": 8476, "epv1today":
             41, "epv1total": 4375, "epv2today": 38, "epv2total": 4101, "pvtemperature":
             327, "pvipmtemperature": 344}}
pmp02 commented 1 year ago

Hi @mriksman. I only get one device in HA, and also only one from Grott from what I've seen. Indeed most of the values seem to come from the meter, but I thought that these are combined with the ones from the Inverter.

I've attached some logs from Grott as well as a .csv export with the values from the grotcsv extension (easier to read values).

As you will see from the logs, I've also enabled the export to pvoutput.org just to see if Grott is pushing all the right data and how PVOutput website interprets it... but data seems to be missing, as I only get this kind of output:

image

I suspect Grott is not reading all values coming from the inverter, but not sure exactly what to do.

20230705.csv grott.log

mriksman commented 1 year ago

Yup, your inverter isn't being decoded.

grott  |     - Grott automatic protocol detection
grott  |     - Grott data record length 585
grott  |     - layout   :  T060104XMAX
grott  |     - no matching record layout found, try generic
grott  |     - no matching record layout found, standard processing performed
grott  |     - Record layout used :  none
grott  |     - Growatt data decrypted V2
grott  |     - Grott Growatt data decrypted
grott  |     - Growatt plain data:
grott  |         00250006024101045847443643475732314200000000000000000000000000000000000000005
grott  |         24b4838434341303147000000000000000000000000000000000000000017061e08202f020000
grott  |         007c0001000048c5105c0016000023fd0ffe0017000024c800000000000000000000000000000
grott  |         00000000000000000000000000000000000000000000000000000000000000000000000481313
grott  |         86096b001a0000187c0960001a000018600962001a00001865104c104910370000000e0000ac5
grott  |         800971de900000006000055740000000600005725000000000000000000000000000000000000
grott  |         0000000000000000000000000000000000000000000000000000000000000000ac990251016f0
grott  |         15a0000016b0c7c0c864e2000000001b206000000000000000000000000000000000000001000
grott  |         1e0000000000000000000000000000000000000000007d00f9000000000000000000000000000
grott  |         00000000000000000000000000000000000000000000000000000000000000000000000000000
grott  |         00000000000000000000000000000000000000000000000000000000000000000000000000000
grott  |         0000000000000000000000000000000000000000000000000000000000000000000045749b600
grott  |         00000000170006001d00170006001e0000000000001c0a000d001300050000000000000000000
grott  |         00000000000000000000000000000000000000000000000000000000000000000000000000000
grott  |         000000000000485b0000000000000000000000000000000000000000000000000000000000000
grott  |         00000000000c41f
grott  |     - Grott data ack record or data record not defined no processing done

You need to head over to the grott page and raise an issue there. https://github.com/johanmeijer/grott

mriksman commented 1 year ago

@muppet3000 This issue can be closed as it is not related to your plugin. Issue #7 deals with the SDM meter, which is now working.

pmp02 commented 1 year ago

Thanks @mriksman , I came to same conclusion... I was looking though existing grott issues to see if anyone else reported this so far... Thanks again.

pmp02 commented 1 year ago

Well... apparently I had Grott configured wrongly! 🤦 According to https://github.com/johanmeijer/grott/issues/352 the invtype should have been tl3... I was using max :-| Just switched to the new type and now I have also inverter values!

I'll post updates about the values I get.

pmp02 commented 1 year ago

These are the two messages, one from the Inverter and one from the SmartMeter:

grott | - Grott data record date/time processing started grott | - date-time: 2023-07-06T09:46:34 grott | - Grott values retrieved: grott | - datalogserial : XGD6CGW21B grott | - pvserial : RKH8CCA01G grott | - voltage_l1 : 240.3 grott | - voltage_l2 : 240.4 grott | - voltage_l3 : 240.9 grott | - Current_l1 : 4.0 grott | - Current_l2 : 3.8 grott | - Current_l3 : 4.3 grott | - act_power_l1 : -892.3 grott | - act_power_l2 : -898.4 grott | - act_power_l3 : -1023.6 grott | - app_power_l1 : 0.0 grott | - app_power_l2 : 0.0 grott | - app_power_l3 : 0.0 grott | - react_power_l1 : -343.3 grott | - react_power_l2 : -199.5 grott | - react_power_l3 : -156.9 grott | - powerfactor_l1 : -0.9 grott | - powerfactor_l2 : -1.0 grott | - powerfactor_l3 : -1.0 grott | - pos_rev_act_power : -2814.5 grott | - pos_act_power : -2814.5 grott | - rev_act_power : -2814.5 grott | - app_power : 0.0 grott | - react_power : -699.8 grott | - powerfactor : -1.0 grott | - frequency : 50.0 grott | - L1-2_voltage : 416.2 grott | - L2-3_voltage : 416.8 grott | - L3-1_voltage : 416.7 grott | - pos_act_energy : 1144.9 grott | - rev_act_energy : 3817.9 grott | - MQTT jsonmsg: grott | {"device": "XGD6CGW21B", "time": "2023-07-06T09:46:34", "buffered": "no", grott | "values": {"datalogserial": "XGD6CGW21B", "pvserial": "RKH8CCA01G", grott | "voltage_l1": 2403, "voltage_l2": 2404, "voltage_l3": 2409, "Current_l1": grott | 40, "Current_l2": 38, "Current_l3": 43, "act_power_l1": -8923, grott | "act_power_l2": -8984, "act_power_l3": -10236, "app_power_l1": 0, grott | "app_power_l2": 0, "app_power_l3": 0, "react_power_l1": -3433, grott | "react_power_l2": -1995, "react_power_l3": -1569, "powerfactor_l1": -916, grott | "powerfactor_l2": -971, "powerfactor_l3": -985, "pos_rev_act_power": -28145, grott | "pos_act_power": -28145, "rev_act_power": -28145, "app_power": 0, grott | "react_power": -6998, "powerfactor": -958, "frequency": 500, "L1-2_voltage": grott | 4162, "L2-3_voltage": 4168, "L3-1_voltage": 4167, "pos_act_energy": 11449, grott | "rev_act_energy": 38179}}

grott | - Growatt new layout processing grott | - decrypt : True grott | - offset : 6 grott | - record layout : T06NNNNXTL3 grott | grott | - Grott data record date/time processing started grott | - date-time: 2023-07-06T09:45:53 grott | - Grott values retrieved: grott | - datalogserial : XGD6CGW21B grott | - pvserial : RKH8CCA01G grott | - pvstatus : 1 grott | - pvpowerin : 3167.5 grott | - pv1voltage : 400.7 grott | - pv1current : 3.9 grott | - pv1watt : 1562.7 grott | - pv2voltage : 401.2 grott | - pv2current : 4.0 grott | - pv2watt : 1604.8 grott | - pvpowerout : 3106.9 grott | - pvfrequentie : 50.0 grott | - pvgridvoltage : 241.6 grott | - pvgridcurrent : 4.3 grott | - pvgridpower : 1038.8 grott | - pvgridvoltage2 : 240.6 grott | - pvgridcurrent2 : 4.3 grott | - pvgridpower2 : 1034.5 grott | - pvgridvoltage3 : 241.0 grott | - pvgridcurrent3 : 4.3 grott | - pvgridpower3 : 1036.3 grott | - Vac_RS : 418.1 grott | - Vac_ST : 418.1 grott | - Vac_TR : 416.2 grott | - pvenergytoday : 3.0 grott | - pvenergytotal : 4799.7 grott | - totworktime : 1467.7 grott | - epv1today : 1.4 grott | - epv1total : 2383.7 grott | - epv2today : 1.5 grott | - epv2total : 2431.4 grott | - epvtotal : 4815.1 grott | - pvtemperature : 60.3 grott | - pvipmtemperature : 38.0 grott | - pvboottemperature : 36.0 grott | - uwBatVolt_DSP : 37.5 grott | - pbusvolt : 3232 grott | - nbusvolt : 3182 grott | - MQTT jsonmsg: grott | {"device": "RKH8CCA01G", "time": "2023-07-06T09:45:53", "buffered": "yes", grott | "values": {"datalogserial": "XGD6CGW21B", "pvserial": "RKH8CCA01G", grott | "pvstatus": 1, "pvpowerin": 31675, "pv1voltage": 4007, "pv1current": 39, grott | "pv1watt": 15627, "pv2voltage": 4012, "pv2current": 40, "pv2watt": 16048, grott | "pvpowerout": 31069, "pvfrequentie": 4998, "pvgridvoltage": 2416, grott | "pvgridcurrent": 43, "pvgridpower": 10388, "pvgridvoltage2": 2406, grott | "pvgridcurrent2": 43, "pvgridpower2": 10345, "pvgridvoltage3": 2410, grott | "pvgridcurrent3": 43, "pvgridpower3": 10363, "Vac_RS": 4181, "Vac_ST": 4181, grott | "Vac_TR": 4162, "pvenergytoday": 30, "pvenergytotal": 47997, "totworktime": grott | 10567143, "epv1today": 14, "epv1total": 23837, "epv2today": 15, "epv2total": grott | 24314, "epvtotal": 48151, "pvtemperature": 603, "pvipmtemperature": 380, grott | "pvboottemperature": 360, "uwBatVolt_DSP": 375, "pbusvolt": 3232, grott | "nbusvolt": 3182}} grott | - Grott MQTT topic used : energy/growatt

pmp02 commented 1 year ago

I can confirm that now I have 2 devices with entities in HA. Thanks a lot for the help @muppet3000 @mriksman and for pointing in the right direction!

muppet3000 commented 1 year ago

@mriksman has turned into a real hero for me this morning, helping me squash bugs everywhere!!!!

I'm going to try and have a look through all the bugs this evening and close things off where it makes sense and try and get a formal 'release' out as well.

muppet3000 commented 12 months ago

Released in v1.1.0