muppet3000 / homeassistant-grott

Home Assistant Integration for Grott - MQTT
MIT License
73 stars 17 forks source link

Sensor missing: Battery Charging Power #19

Closed Benchamoneh closed 1 year ago

Benchamoneh commented 1 year ago

Great work on this integration, it's filled a gap in my HA instance that's been there for far too long.

Anyway, reviewing the sensors created by Grott I see a sensor for "Battery Discharging Power" but not the equivalent "Battery Charging Power". The discharge sensor seems to be created using pdischarge1 from Grott, but I don't see a sensor pulling the data from pcharge1.

Grott output below, and the resulting sensors following that. I've omitted the values Grott retrieved because this post would get really long otherwise, but you can see them in the MQTT json message along with the transmitted pcharge1 value.

For info: HA-GROTT version: 1.0.1 Grott version: 2.8.2 (Beta) Hardware: SPA3000TL ("AcCouple", with ShineWiFi-S logger) I have the "additional sensors from raw MQTT values" option checked.

         - Grott values retrieved:
                 ...[omitted for brevity]...
                 -  pdischarge1          :  510.0
                 -  pcharge1             :  0.0
                 ...[omitted for brevity]...
         - MQTT jsonmsg: 
                         {"device": "WPDACBP067", "time": "2023-06-23T20:06:09", "buffered": "no",
                         "values": {"datalogserial": "JPC8CDH05J", "pvserial": "WPDACBP067",
                         "pvstatus": 6, "uwsysworkmode": 81, "systemfaultword0": 0,
                         "systemfaultword1": 0, "systemfaultword2": 0, "systemfaultword3": 0,
                         "systemfaultword4": 0, "systemfaultword5": 0, "systemfaultword6": 0,
                         "systemfaultword7": 0, "pdischarge1": 5100, "pcharge1": 0, "vbat": 529,
                         "SOC": 84, "pactouserr": 0, "pactousers": 0, "pactousert": 0,
                         "pactousertot": 0, "pactogridr": 0, "pactogrids ": 0, "pactogrid t": 0,
                         "pactogridtot": 0, "plocaloadr": 6800, "plocaloads": 0, "plocaloadt": 0,
                         "plocaloadtot": 6800, "ipm": 0, "battemp ": 261, "spdspstatus": 6,
                         "spbusvolt": 47656, "etouser_tod": 101, "etouser_tot": 25005, "etogrid_tod":
                         13, "etogrid_tot": 5251, "edischarge1_tod": 50, "edischarge1_tot": 13618,
                         "eharge1_tod": 74, "eharge1_tot": 14432, "elocalload_tod": 245,
                         "elocalload_tot": 52932, "dwexportlimitap": 0, "epsfac": 0, "epsvac1": 0,
                         "epsiac1": 0, "epspac1": 0, "epsvac2": 0, "epsiac2": 0, "epspac2": 0,
                         "epsvac3": 0, "epsiac3": 0, "epspac3": 0, "loadpercent": 0, "pf": 1000,
                         "bmsstatusold": 0, "bmsstatus": 99, "bmserrorold": 0, "bmserror": 0,
                         "bmssoc": 84, "bmsbatteryvolt": 5290, "bmsbatterycurr": 64606,
                         "bmsbatterytemp": 25, "bmsmaxcurr": 10420, "bmsgaugerm": 10370,
                         "bmsgaugefcc": 12240, "bmsfw": 34181, "bmsdeltavolt": 4, "bmscyclecnt": 232,
                         "bmssoh": 100, "bmsconstantvolt": 5680, "bmswarninfoold": 0, "bmswarninfo":
                         0, "bmsgaugeiccurr": 0, "bmsmcuversion": 34181, "bmsgaugeversion": 0,
                         "bmswgaugefrversionl": 0, "bmswgaugefrversionh": 0, "bmsbmsinfo": 16720,
                         "bmspackinfo": 16720, "bmsusingcap": 0, "bmscell1volt": 3312,
                         "bmscell2volt": 3308, "bmscell3volt": 1, "bmscell4volt": 3600,
                         "bmscell5volt": 3308, "bmscell6volt": 3309, "bmscell7volt": 3309,
                         "bmscell8volt": 3310, "bmscell9volt": 3310, "bmscell10volt": 3311,
                         "bmscell11volt": 3310, "bmscell12volt": 3311, "bmscell13volt": 3310,
                         "bmscell14volt": 3311, "bmscell15volt": 3310, "bmscell16volt": 3310,
                         "acchargeenergytoday": 81, "acchargeenergytotal": 17084, "acchargepower": 0,
                         "70%_invpoweradjust": 986, "extraacpowertogrid": 1700, "eextratoday": 181,
                         "eextratotal": 33992, "esystemtoday": 169, "esystemtotal": 34781,
                         "inverterstatus": 6, "pacs": 4532, "fac": 5005, "vac1": 2422, "iac1": 19,
                         "pac1": 4599, "eactoday": 47, "eactot": 13371, "timetotal": 59507185,
                         "Temp1": 334, "Temp2": 312, "Temp3": 200, "Temp4": 0, "uwbatvoltdsp": 530,
                         "pbusvoltage": 3946, "nbusvoltage": 3939, "remotectrlen": 0,
                         "remotectrlpower": 0, "eacchargetoday": 81, "eacchargetotal": 17084,
                         "priority": 0, "batterytype": 1, "autoproofreadcmd": 0}}

HA sensors built: image

Benchamoneh commented 1 year ago

Looking at your code in sensor.py line 35 your example data references pdischarge1 (correct) but p1charge1 (extra 1).

Is this the problem? Might you be looking for p1charge1? Line35 below:

#home-assistant-test | 2023-03-01 21:32:34.535 DEBUG (MainThread) [custom_components.grott.sensor] Payload: {"device": "NWCPA47006", "time": "2023-03-01T21:32:34", "buffered": "no", "values": {"datalogserial": "NAC3915162", "pvserial": "NWCPA47006", "pvstatus": 6, "pvpowerin": 0, "pv1voltage": 123, "pv1current": 0, "pv1watt": 1, "pv2voltage": 0, "pv2current": 0, "pv2watt": 0, "pvpowerout": 0, "pvfrequentie": 5000, "pvgridvoltage": 2464, "pvgridcurrent": 15, "pvgridpower": 0, "pvgridvoltage2": 0, "pvgridcurrent2": 0, "pvgridpower2": 0, "pvgridvoltage3": 0, "pvgridcurrent3": 0, "pvgridpower3": 0, "totworktime": 111688551, "eactoday": 120, "pvenergytoday": 120, "eactotal": 138743, "epvtotal": 107934, "epv1today": 25, "epv1total": 60803, "epv2today": 16, "epv2total": 32732, "pvtemperature": 232, "pvipmtemperature": 223, "pvboosttemp": 213, "bat_dsp": 522, "eacharge_today": 95, "eacharge_total": 46348, "batterytype": 1, "uwsysworkmode": 6, "systemfaultword0": 0, "systemfaultword1": 0, "systemfaultword2": 0, "systemfaultword3": 0, "systemfaultword4": 32, "systemfaultword5": 0, "systemfaultword6": 0, "systemfaultword7": 2048, "pdischarge1": 0, "p1charge1": 0, "vbat": 519, "SOC": 11, "pactouserr": 12707, "pactousertot": 12707, "pactogridr": 0, "pactogridtot": 0, "plocaloadr": 12700, "plocaloadtot": 12700, "spdspstatus": 6, "spbusvolt": 2957, "etouser_tod": 206, "etouser_tot": 115836, "etogrid_tod": 2, "etogrid_tot": 297107, "edischarge1_tod": 101, "edischarge1_tot": 67936, "eharge1_tod": 88, "eharge1_tot": 63816, "elocalload_tod": 260, "elocalload_tot": 4294898079}}

Benchamoneh commented 1 year ago

Sorry I should have just looked properly, that's the issue. submitted PR with the fix.

muppet3000 commented 1 year ago

Hi @Benchamoneh thanks for the bug and the PR.

Your PR was damn close, however that value is used by SPH aka Hybrid systems, what we need to do is add a new lookup to provide the same named value. I'll submit a commit to main with that very shortly so you can re-test.

muppet3000 commented 1 year ago

@Benchamoneh - Could you please pull the main branch of the integration through HACS and let me know if the value now appears?

Benchamoneh commented 1 year ago

Yeah TBH the doubt started to creep in after submitting the PR that maybe it wasn't a typo. Either way, just redownloaded main and I now have the missing sensor.

Thanks for the hard work and rapid bugs fixes!

muppet3000 commented 1 year ago

No problem at all, I'm hoping to do a release over the weekend I'll close it at that point. Glad I could assist with a quick fix.

muppet3000 commented 1 year ago

Released in v1.1.0