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
52 stars 37 forks source link

Growatt omvormer #14

Closed ghost closed 5 years ago

ghost commented 6 years ago

Ik krijg binnenkort een zonnepanelenset met een Growatt omvormer (met wifi). Zijn er plannen en mogelijkheden om deze omvormer toe te voegen aan SolarPanels.

Groet,

Bob

DiedB commented 6 years ago

I'll get back to you this summer, as I'm too busy with other things right now.

ghost commented 6 years ago

The solarpanels have been installed with a trannergy convertor.

DiedB commented 6 years ago

Nice, were you able to connect it to Homey?

I'll keep this one open, as there have been more requests for Growatt support.

ghost commented 6 years ago

Yes, It's conncted to homey.

Thanks, Bob

Op 22 jun. 2018, om 12:37 heeft Diederik Bakker notifications@github.com het volgende geschreven:

Fadoz commented 5 years ago

Hi DiedB,

are there any updates for implementing a Growatt inverter? although this issue is closed?

kind regards, Fadoz

Spijkmans commented 5 years ago

I also have a Growatt inverter (a 1500-S), any chance on support for this inverter?

Greez, Spijkmans

DiedB commented 5 years ago

Possibly, if we can get data from Growatt inverters reliably. How do you currently monitor your inverter?

Fadoz commented 5 years ago

Hi,

i'm currently using the growatt app "ShinePhone" to monitor data.

Roylegr commented 5 years ago

Hi, I've also a Growatt inverter (a 3000-s) with wifi adapter. And i monitor this with the app ShinePhone. Can and do you want to make support this?

pro-sumer commented 5 years ago

Don't have a Homey (yet?), but these links might help:

Fadoz commented 5 years ago

I’ve found a github project that connects to the growatt api as it were the phone app. I did test this and it does return data thats also available in the app. https://github.com/Sjord/growatt_api_client

The creator does mention that if growatt changes something in the app this possibly won’t work anymore. So if this is reliable i don’t really know.

There also is a document from growatt about their api. But i can’t seem to work out how this exactly works because i’m not able to find the login option nor can i find a way to get a api-key

http://www.growatt.pl/dokumenty/Inne/Growatt%20Server%20Open%20API%20protocol%20standards.pdf

pro-sumer commented 5 years ago

Apparently there's already a sensor for Home-Assistant.

That might help as well? (for inspiration)

DiedB commented 5 years ago

@pro-sumer The HAS sensor is polling/scraping the web platform or the mobile API. I do not really fancy going that route, as I doubt it to be reliable. This app has supported (and still supports) some Chinese inverter brands this way and those have not been very reliable. I do not really have time to create new implementations when it breaks.

The other route, setting up a server, might work better (if Homey allows it). It does require technical knowledge though, and it is pretty complicated however and vastly different from how the app works right now.

I think your best bet is installing a meter between the inverter and your electrical panel (or inside the panel) and pushing data to PVOutput. Otherwise, run the Python script on a Raspberry Pi which runs the Growatt server and push the data to PVOutput from there. The app supports reading data from PVOutput.

pro-sumer commented 5 years ago

The HAS sensor is polling/scraping the web platform or the mobile API. I do not really fancy going that route, as I doubt it to be reliable. This app has supported (and still supports) some Chinese inverter brands this way and those have not been very reliable. I do not really have time to create new implementations when it breaks.

Fair enough.

I experimented a bit with their API and you might be right: calls that worked before suddenly started returning 502 errors.

DiedB commented 5 years ago

If someone has the chance/time, it might be a possibility to use the API that is also used by the iOS/Android apps. You would need to trace the requests that are made by those apps. Closing this issue for now as there is no documented/reliable way of connecting to Growatt inverters.

pro-sumer commented 5 years ago

If someone has the chance/time, it might be a possibility to use the API that is also used by the iOS/Android apps.

@DiedB I'm not sure yet, but I might take up this challenge.

I have arranged temporary access to a Homey and I think I have already reverse engineered the essential part of Growatt's ShinePhone iOS App API (to report production data via Siri).

In fact I have created a "Proof of Concept" in a private repo that seems to be able to get the production data from the Growatt website (after entering the username and password of that site during the pairing of the Growatt inverter).

I want to run this for a couple of days to see if it's stable.

Disclaimers:

Don't get your expectations up too high...

DiedB commented 5 years ago

@pro-sumer Cool, sounds great! Feel free to try and fork this repository. Use the Enphase implementation as a starting point, try to get it working and submit a pull request to this repository.

If you come across any problems, just let me know.

pro-sumer commented 5 years ago

I made my "POC" (in a private fork) based on the Tigo implementation, but I guess that does not matter?

So far I could not discover where the small and large images are used (though I created them anyway). Can you please explain where, so I can check this?

What would be a good example for the pairing process?

For now I used the Credentials Login template (screen 1: login_credentials, screen 2: list_devices) and hardcoded a name for the inverter (good enough for the POC and even my personal usage). The Homey documentation shows a logo above the username/password fields. How can I achieve that? (Is this where I can use those small/large images? How?)

DiedB commented 5 years ago

I just implemented the credentials login for Omnik inverters, on the alpha branch of this repository. You can have a look. The image is in the pair folder and the app.json contains a direct reference to the image file name.

Is there no way to get the system name from the Growatt API? That way, you won't have to hardcode it. An alternative way would be to use the inverter ID or something like that.

pro-sumer commented 5 years ago

I just implemented the credentials login for Omnik inverters, on the alpha branch of this repository. You can have a look. The image is in the pair folder and the app.json contains a direct reference to the image file name.

That’s very similar to what I have and even more similar to what I planned to change. Good to know! Thanks.

Is there no way to get the system name from the Growatt API? That way, you won't have to hardcode it. An alternative way would be to use the inverter ID or something like that.

Did not even think about that... Will put it on my todo-list.

(Hope to work on this again later this week)

PS: the name is only displayed in Homey; it’s not required to get production data using the API.

Fadoz commented 5 years ago

Hi,

@pro-sumer If you need someone to test I'll be happy to do so.

I've contacted Growatt about their API description mentioned earlier. They have given me an API token so I can use their API now. They also provided me with a newer description of the API.

There is a slight catch as everyone that wants to use the API has to contact Growatt to ask if they can create an API token. There is no way to get this token via the webpage only by mailing them.

So if there is some interest in building the app around their API we could do that but with that catch of getting a token.

Growatt Server Api_EN.pdf

pro-sumer commented 5 years ago

There is no way to get this token via the webpage only by mailing them.

I already tried that, but they refused me a token, because that's only for distributors...

Since the App API only requires the username & password (which each user already has) I think that's the way forward (currently works for me).

pro-sumer commented 5 years ago

@DiedB I did not see any license. Under what license do you distribute this code?

(I added a logo to pairing and am now using the inverter name/ID from the API; I'm getting closer to a Pull Request)

Fadoz commented 5 years ago

@pro-sumer let's follow your way, getting the token was a bit of a hassle indeed. my offer for testing still stands so if there is a working version let me know

DiedB commented 5 years ago

@pro-sumer Cool. License is GNU GPLv3, added it to the alpha branch.

DiedB commented 5 years ago

Is it not possible to get a token at the app-level? The token can be kept secret if necessary, environment variables can be injected via the app store.

pro-sumer commented 5 years ago

Is it not possible to get a token at the app-level?

I did not see a token in the recorded communication.

Instead a session cookie is used. I still need to improve the code for that a bit...

(node-fetch does not have native support for session cookies?)

DiedB commented 5 years ago

I meant the token @Fadoz mentioned. Is that token they sent you account-specific, or is it meant to be used for a specific app (like this one)? In the last case, we could even keep the token secret while bundling it in this app.

pro-sumer commented 5 years ago

@DiedB I don't know, since they even refused to give me a token. Maybe @Fadoz can answer this?

The (undocumented) App API has been working well and I need only 2 calls (login, get energy data).

MP-ICT-Diensten commented 5 years ago

@pro-sumer is your app in alpha? Can I test it? I have a Growatt 2500 unit.

pro-sumer commented 5 years ago

Is your app in alpha?

I don't have a new App; I wrote an additional driver for Growatt inverters for the existing SolarPanels App.

My code is currently only present in my private repo. I'm still the only one who tested it, but I think it's ready for additional testers.

@DiedB What would be the best way forward?

DiedB commented 5 years ago

You can create a pull request, but I'm not sure if it's possible if your repository is private. You can make the repository public if it doesn't work. It is fine to target the alpha branch. Before merging it, I will do some tests, check the code and get it ready for an app store release.

If that's done, I can add the others to the alpha testing group and they can install the app through the Homey app store.

pro-sumer commented 5 years ago

@DiedB Created a new public repo (with only the latest commits from my private repo) and created Pull Request 60.

Can you please add me to your Alpha group so that I can re-test when my code is merged?

DiedB commented 5 years ago

Great job! Everyone who wants to join the alpha can send me their Athom account email address using the contact option in the Athom App Store.

DiedB commented 5 years ago

Never mind, that option seems to have been removed. Use solarpanels@diederik.33mail.com

pro-sumer commented 5 years ago

If I instead side load the Alpha branch, will it automatically be updated if you release a stable version?

Fadoz commented 5 years ago

Wow, I've missed something

@DiedB the token is for app usage indeed (but still coupled to an account of course) as pro-sumer mentioned, its actually for installers so that they can make their own monitoring site or app, so if you were a Growatt installer you could get a token (don't exactly know why they did give it to me, but probably because I had direct contact with one of their employees that fixed it for me.) Growatt allows for installers to add the accounts of the customers to their account so there is an overview for them of all the systems they have installed.

So I think that pro-sumer's idea of using the Growatt app API is better as it is account based. otherwise, the users of this app must connect their Growatt inverter to an installer account for this app.

pro-sumer commented 5 years ago

@DiedB Good review remarks. I will try to do the rework, but don't know yet when I have time for that.

What's the target date for the next release? (if any)

DiedB commented 5 years ago

Doesn't really matter, it is released when it's done.

pro-sumer commented 5 years ago

For those not following the pull request:

Reworked the small things, but need more time to refactor the code to solve the remaining two remarks, which I would like to do before we merge this pull request.

However, while doing this I noticed a weird inconsistency in my code:

  • During pairing the user can select any of her/his Growatt inverters
  • The production data is always retrieved for one (the first?) inverter...

Maybe having more than 1 Growatt inverter is an edge case? Still I want to investigate whether this can be solved using the Growatt App API (if I can figure this out; I only have 1 inverter myself).

pro-sumer commented 5 years ago

Oops, actually we're working with plants, not inverters...

But since the Omnik plugin does the same and I want to apply the KISS principle, I prose we'll keep it like this (most users will have 1 plant, with 1 inverter anyway).

Changed to a different part of the API that should properly support multiple plants.

pro-sumer commented 5 years ago

Fixed all the review comments, but...

Ouch. When testing this on a sunny morning (after developing in the evenings) I noticed that the API I'm using now reports current energy as "W" when < 1 kWh, but as "kW" when larger. Additionally it seems to give less precision above 1 kWh. Need to investigate this before we merge! But first the sun needs to return...

pro-sumer commented 5 years ago

Let's hope third time's the charm...

I have added proper support for multiple plants and multiple inverters (I believe, can't test this myself since I only have 1 plant and 1 inverter) and now use yet another API call to get the production data.

Data are now stored per inverter (based on its serial number, instead of the plant identifier). If anyone side loaded a previous version please note that you will loose data stored so far... Sorry!

@DiedB Can you please check whether the code's ready to merge? (quite a bit has changed)

DiedB commented 5 years ago

Thanks for the effort, I will release it in the alpha channel today!

@pro-sumer Can you send me your e-mail address (on solarpanels@diederik.33mail.com) so I can add you to the alpha?

pro-sumer commented 5 years ago

Can you send me your e-mail address (on solarpanels@diederik.33mail.com) so I can add you to the alpha?

I'm new to Alpha groups on Homey. How does this work?

DiedB commented 5 years ago

I need the Homey account, that will allow me to add you to the alpha group. There is no link-invite system (yet).

Op ma 6 mei 2019 om 16:31 schreef Rob notifications@github.com

Can you send me your e-mail address (on solarpanels@diederik.33mail.com) so I can add you to the alpha?

I'm new to Alpha groups on Homey. How does this work?

  • Will you send me a link and can I thus use a disposable address as well?
  • Or should this really be the email address of my Homey account? (Because you need to type that somewhere?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiedB/Homey-SolarPanels/issues/14#issuecomment-489642300, or mute the thread https://github.com/notifications/unsubscribe-auth/AB2GJYMFJF5BGONHID5AAZTPUA6LBANCNFSM4FBVRJMQ .

pro-sumer commented 5 years ago

Done.

@Fadoz and @MP-ICT-Diensten Please let me know whether the Growatt plugin works for you (as well).

MP-ICT-Diensten commented 5 years ago

Sorry, was not paying attention, just configured the app and added my convertor succesfull. I now see 2 graphs, one of current production of Power and one of total power today.

Seems to work fine!

In details, the used dutch name for stroomopwekking is energie in Homey apps.

Met vriendelijke groet,

Marco Pietersma T: +31 6 14143710 E: info@mp-ictdiensten.eu W: MP-ICTdiensten.eu

Op ma 6 mei 2019 om 16:40 schreef Rob notifications@github.com:

Done.

@Fadoz https://github.com/Fadoz and @MP-ICT-Diensten https://github.com/MP-ICT-Diensten Please let me know whether the Growatt plugin works for you (as well).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiedB/Homey-SolarPanels/issues/14#issuecomment-489645612, or mute the thread https://github.com/notifications/unsubscribe-auth/AG2AMNJOP33HYUOSMDJ66X3PUA7NRANCNFSM4FBVRJMQ .