DiedB / Homey-SolarPanels

Connects production statistics of a wide range of PV inverters to Homey
https://apps.athom.com/app/it.diederik.solar
GNU General Public License v3.0
54 stars 37 forks source link

Growatt integration not working #105

Closed EricBorland closed 1 year ago

EricBorland commented 4 years ago

Hi there,

I just got a Growatt Inverter and successfully setup the WIFI module so I can review all data in server.growatt.com. I also could successfully login and pair my inverter into Homey. However, the power indicators are always "-" without showing any result. There is no error, just no metrics shown (see attached picture).

I have tried to do the requests your library does using postman and both the login and the getPlant work great (even in this last one I'm already able to get the data I'd like Homey to show) but the getInverter shows "{ msg: "501", success: "false" }"...

I am doing something wrong? could it be that the API has changed? I have reviewed the API used by the website server.growatt.com and it's slightly different... If that's the case and many users are like me, I'd be happy to contribute to integrate with the new Growatt API.

Let me know your thoughts and thank you very much for the app!

IMG_3099

Didiervu91 commented 4 years ago

@pro-sumer the updated API is working perfect here! Is it possible to add more to this? For example: todayProfitStr

DiedB commented 4 years ago

Does the new API work with old inverters as well? Or do we need to create a separate driver for the newer Growatt API?

pro-sumer commented 4 years ago

Does the new API work with old inverters as well? Or do we need to create a separate driver for the newer Growatt API?

Yes; I verified with a REST client (Paw) that this new API works for my own ("old") inverter, before I updated the api.js file.

I'm not sure about @Frastabyte's more advanced inverter though... That's why there's currently this explicit check in the code:

const inverters = deviceList.filter(device => ["inverter", "tlx"].includes(device.deviceType))

Should I submit a Pull Request from my fork to update api.js in your repository?

DiedB commented 4 years ago

Sure! We can release it as a test version and let everyone here check whether it still works.

pro-sumer commented 4 years ago

Created PR #122.

DiedB commented 4 years ago

Thanks! Could you all try this build?

https://homey.app/nl-nl/app/it.diederik.solar/Zonnepanelen/test/

pro-sumer commented 4 years ago

Sorry, have been busy and forgot about this...

Does installing a test build wipe all historic data?

(I more than once lost data in the past, but not sure what I did wrong - want to prevent that this time)

DiedB commented 4 years ago

It shouldn't, but I'm not sure how Homey deals with transitions from stable to beta versions. Maybe someone else can confirm?

jekyc commented 3 years ago

Hi,

I'm having the same issue as described by the OP - I also have an invert and battery.

I just checked the response of the https://server-api.growatt.com/newTwoPlantAPI.do for my setup, and it seems that I have yet another deviceType: 'mix':

{'plantMoneyText': '0.00/D.Kr', 'optimizerType': 0, 'ammeterType': '0', 'storagePgrid': '-1110', 'todayEnergy': '1.4', 'storageTodayPpv': '0', 'invTodayPpv': '0', 'totalEnergy': '768.6', 'nominalPower': 0, 'todayDischarge': '0', 'Co2Reduction': '307.44', 'isHaveOptimizer': 0, 'storagePuser': '1110', 'useEnergy': '0', 'totalMoneyText': '0', 'nominal_Power': 4480, 'deviceList': [{'pCharge': '0', 'lost': False, 'location': '', 'deviceAilas': 'XXXX', 'deviceType': 'mix', 'datalogSn': 'XXXX', 'eChargeToday': '0.1', 'deviceSn': 'XXXX', 'capacity': '16%', 'deviceStatus': '6', 'energy': '768.6'}]}

And also, there is no 'eToday' key in the 'deviceList' items.

Do you think it would be possible to add support for this device type?

pro-sumer commented 3 years ago

Does todayEnergy have the correct value for your production today?

Or does eChargeToday need to be included in the calculation somehow?

jekyc commented 3 years ago

todayEnergy has the same value as reported in ShinePhone app, so I don't think it is necessary to use the eChargeToday key/value for this purpose.

I toke a look at the web interface at server.growatt.com and data sent from the server, and in that response I have the eToday key/value. It seems that the python api implemented in https://github.com/Sjord/growatt_api_client/ also uses server.growatt.com instead of the server-api.growatt.com. If I'm not mistaken this is the api used by Home Assistant. Maybe that endpoint is more stable/robust regarding different deviceTypes?

pro-sumer commented 3 years ago

We used server.growatt.com before migrating to server-api.growatt.com to support the newTwo API.

Unfortunately I can't find any documentation on Growatt's API, so we need to reverse engineer (by trial & error).

Would be great if we could find a set of domains & endpoints that support all Growatt devices, but I'm not sure we can...

Frastabyte commented 3 years ago

@DiedB Sorry for being silent for so long, was very busy. The new 4.3.3 version works now for me. Thanks a lot!