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

Enphase Envoy Local API #110

Closed KvDaalen closed 4 years ago

KvDaalen commented 4 years ago

Enphase Envoy Local API output.txt

I have an Enphase micro inverter installation and would like to use the Homey SolarPanels App to integrate data that the Envoy Metered produces into my Homey. The Envoy metered is a type of Envoy that next to production also measures data for import/export and consumption. It does this via measuring devices that need to be installed separately in the fuse box. The current SolarPannels app does not support the Local API of the Enphase Envoy and it does also not deliver the Import/Export data nor consumption data. Because of the usage of the Cloud API, also the polling frequency is very low and on-boarding is cumbersome.

I suggest to enhance the SolarPanels app for enphase by implementing the local Envoy API instead of the Cloud API. This enables the app to:

The local API can be called via the following URL (no authentication is needed)

GET http:///production.json?details=1 or GET http://envoy.local/production.json?details=1

The output can be found in the attachment

I found that in order to get the most current power production you must follow the path $.production[1].wNow (eim). I do not know what $.production[0].wNow (inverters) means, but it is not the most current value. Might be a rolling average.

Retrospected commented 4 years ago

Hmm on 4.1.7 it doesn’t seem to be working on my unmetered envoy anymore

9D07E351-FE9B-4DF5-9810-1616B59BD7A6

Retrospected commented 4 years ago

Hmm on 4.1.7 it doesn’t seem to be working on my unmetered envoy anymore

9D07E351-FE9B-4DF5-9810-1616B59BD7A6

Nevermind, re-adding the device fixed it

DiedB commented 4 years ago

@geurti64 @Retrospected I pushed a new version (4.1.8) that might fix the energy meter staying at zero. If it doesn't work, please remove the inverter and reinstall the app.

@geurti64 That's not possible from the data we have, but maybe on a different endpoint than the production.json one? You will have to do some research.

geurti64 commented 4 years ago

The result is the same. To be honest, i removed the inverter and installed the last version over 4.1.7 Is it really necessary to remove app 4.1.7 first?

{"production":[{"type":"inverters","activeCount":6,"readingTime":1595838877,"wNow":240,"whLifetime":5106638}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

geurti64 commented 4 years ago

@geurti64 That's not possible from the data we have, but maybe on a different endpoint than the production.json one? You will have to do some research.

All research I already did is asking around and found this. Maybe someone else can do something with this information.

https://m.facebook.com/story/graphql_permalink/?graphql_id=UzpfSTc0MjIwODQ4MTpWSzoxOTEzMTY0NDEyMTUwMDI3

The link is from the Enphase users + owners group.

DiedB commented 4 years ago

@geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

geurti64 commented 4 years ago

@geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

I've to find out how to login. The user name and password is different from what I'm used to.

Retrospected commented 4 years ago

@geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

I've to find out how to login. The user name and password is different from what I'm used to.

Read here:https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/

Install the apk that is listed (on your own risk ;-)). It will retrieve the “installer” credentials to access that api. Worked fine for me

JSON:

[
  {
    "serialNumber": "122018001310",
    "lastReportDate": 1595840610,
    "devType": 1,
    "lastReportWatts": 80,
    "maxReportWatts": 308
  },
  {
    "serialNumber": "122017037787",
    "lastReportDate": 1595840615,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 306
  },
  {
    "serialNumber": "122017037789",
    "lastReportDate": 1595840606,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000241",
    "lastReportDate": 1595840612,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037914",
    "lastReportDate": 1595840618,
    "devType": 1,
    "lastReportWatts": 87,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037772",
    "lastReportDate": 1595840620,
    "devType": 1,
    "lastReportWatts": 85,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000891",
    "lastReportDate": 1595840621,
    "devType": 1,
    "lastReportWatts": 89,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018001281",
    "lastReportDate": 1595840607,
    "devType": 1,
    "lastReportWatts": 79,
    "maxReportWatts": 309
  },
  {
    "serialNumber": "122018000625",
    "lastReportDate": 1595840614,
    "devType": 1,
    "lastReportWatts": 91,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037320",
    "lastReportDate": 1595840611,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 305
  },
  {
    "serialNumber": "122018001358",
    "lastReportDate": 1595840616,
    "devType": 1,
    "lastReportWatts": 92,
    "maxReportWatts": 296
  }
]

Other note: the energymeter rounds the production of the current day to a whole number, while the cloud version shows it with 2 decimals. Is this based on the api or did you include a round function?

DiedB commented 4 years ago

The round is not necessary indeed, I pushed a new build to fix that.

geurti64 commented 4 years ago

@geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

I've to find out how to login. The user name and password is different from what I'm used to.

Read here:https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/

Install the apk that is listed (on your own risk ;-)). It will retrieve the “installer” credentials to access that api. Worked fine for me

JSON:

[
  {
    "serialNumber": "122018001310",
    "lastReportDate": 1595840610,
    "devType": 1,
    "lastReportWatts": 80,
    "maxReportWatts": 308
  },
  {
    "serialNumber": "122017037787",
    "lastReportDate": 1595840615,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 306
  },
  {
    "serialNumber": "122017037789",
    "lastReportDate": 1595840606,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000241",
    "lastReportDate": 1595840612,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037914",
    "lastReportDate": 1595840618,
    "devType": 1,
    "lastReportWatts": 87,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037772",
    "lastReportDate": 1595840620,
    "devType": 1,
    "lastReportWatts": 85,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000891",
    "lastReportDate": 1595840621,
    "devType": 1,
    "lastReportWatts": 89,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018001281",
    "lastReportDate": 1595840607,
    "devType": 1,
    "lastReportWatts": 79,
    "maxReportWatts": 309
  },
  {
    "serialNumber": "122018000625",
    "lastReportDate": 1595840614,
    "devType": 1,
    "lastReportWatts": 91,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037320",
    "lastReportDate": 1595840611,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 305
  },
  {
    "serialNumber": "122018001358",
    "lastReportDate": 1595840616,
    "devType": 1,
    "lastReportWatts": 92,
    "maxReportWatts": 296
  }
]

Other note: the energymeter rounds the production of the current day to a whole number, while the cloud version shows it with 2 decimals. Is this based on the api or did you include a round function?

I got stuck on "911 is an inside job" 🙈 The app is Android only right?

Edit: As I see on your list it must be possible to make a tile for every single panel, right?

@DiedB It's because of this shitty summer that it didn't work. Normally at this time it should be far above one. Good job again, it works now. AD83C353-3940-49D4-BA5E-286E1B58EF77

geurti64 commented 4 years ago

@DiedB Diederik, waar kan ik een paar biertjes voor je achterlaten?

geurti64 commented 4 years ago

Oh guys, I read on the Enphase app that they will do some maintaining July 28. I hope it still works after tomorrow 😅

DiedB commented 4 years ago

Nice, great to see it is working! @KvDaalen I'm curious whether it also works for your metered setup. @geurti64 There is a (subtle) donation link on the Athom App Store page :wink: Don't worry about the Enphase app, it uses a different API from the one we are using here. From the website @Retrospected linked, it seems that the local API has stayed the same for at least 4 years.

geurti64 commented 4 years ago

Done 🍻

KvDaalen commented 4 years ago

Nice, great to see it is working! @KvDaalen I'm curious whether it also works for your metered setup. @geurti64 There is a (subtle) donation link on the Athom App Store page 😉 Don't worry about the Enphase app, it uses a different API from the one we are using here. From the website @Retrospected linked, it seems that the local API has stayed the same for at least 4 years.

It works perfectly fine. Really happy with this. It also updates quite frequently (every 5 seconds i guess). Thanks a lot. You get some coffee .

Are you still on planning to do some functional enhancements to expose some additional info like:

DiedB commented 4 years ago

I could increase the update interval even further, but I'm worried about performance. I think 5 seconds is a good middle ground.

  • Expose detailed data about consumption and import/export.

Will look into that

  • include Envoy Battery state (not installed in my system)

Someone with a battery would have to show up here, might be implemented later

  • Give more detail on this data by including the lines

You mean the individual phases?

KvDaalen commented 4 years ago
  • I could increase the update interval even further, but I'm worried about performance. I think 5 seconds is a good middle ground. Agreed that a 5 second interval is fine.
  • Expose detailed data about consumption and import/export.

Will look into that One could also simply do the calculation themselves but as this data is available within the API my preference would be to simply expose this.

  • include Envoy Battery state (not installed in my system)

Someone with a battery would have to show up here, might be implemented later Makes sence. Sorry I have no plans for this.

  • Give more detail on this data by including the lines

You mean the individual phases? Yes. Do not know if this is of much use. Maybee do some investigation first if there are usecases that can benefit from this.

some other remarks:

In the energy tab the zonnepanelen app reports production. It however does not seem to report import/export as a smart meter would do. Can you see if this can be added? Then i can sell my Smart metering device (plugwise) as it has no additional value and the Envoy Metered has all the data.

DiedB commented 4 years ago

@KvDaalen I will consider implementing that. I will wait for Athom to roll out v5 first, and then release a new Enphase-only app. This app would become too complicated with all sorts of custom capabilities. Give it a few months and it will be done.

As for the Energy tab, I could add two devices, one with the solarpanel class which reports production, and one with a measure_power capability with cumulative set to true. I'll consult with Athom by then, I think it's too much of a workaround.

KvDaalen commented 4 years ago

Great, thanks for all your effort and thinking along. When will you release this version?

Op za 29 aug. 2020 17:16 schreef Diederik Bakker notifications@github.com:

@KvDaalen https://github.com/KvDaalen I will consider implementing that. I will wait for Athom to roll out v5 first, and then release a new Enphase-only app. This app would become too complicated with all sorts of custom capabilities. Give it a few months and it will be done.

As for the Energy tab, I could add two devices, one with the solarpanel class which reports production, and one with a measure_power capability with cumulative set to true. I'll consult with Athom by then, I think it's too much of a workaround.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiedB/Homey-SolarPanels/issues/110#issuecomment-683303833, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQHT5D6BYT6H3NK7FMQAFVDSDELUTANCNFSM4OWO7KOA .

DiedB commented 4 years ago

Soon, will probably do it in two weeks.

geurti64 commented 4 years ago

It would be very nice if adding only one single solar panel also is an option. I have one set on my shed and one set on my house, East and West. And only one Envoy...

DiedB commented 4 years ago

@geurti64 Does the Envoy measure those sets independently? What does your production.json look like?

geurti64 commented 4 years ago

@geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

I've to find out how to login. The user name and password is different from what I'm used to.

Read here:https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/

Install the apk that is listed (on your own risk ;-)). It will retrieve the “installer” credentials to access that api. Worked fine for me

JSON:

[
  {
    "serialNumber": "122018001310",
    "lastReportDate": 1595840610,
    "devType": 1,
    "lastReportWatts": 80,
    "maxReportWatts": 308
  },
  {
    "serialNumber": "122017037787",
    "lastReportDate": 1595840615,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 306
  },
  {
    "serialNumber": "122017037789",
    "lastReportDate": 1595840606,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000241",
    "lastReportDate": 1595840612,
    "devType": 1,
    "lastReportWatts": 90,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037914",
    "lastReportDate": 1595840618,
    "devType": 1,
    "lastReportWatts": 87,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037772",
    "lastReportDate": 1595840620,
    "devType": 1,
    "lastReportWatts": 85,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018000891",
    "lastReportDate": 1595840621,
    "devType": 1,
    "lastReportWatts": 89,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122018001281",
    "lastReportDate": 1595840607,
    "devType": 1,
    "lastReportWatts": 79,
    "maxReportWatts": 309
  },
  {
    "serialNumber": "122018000625",
    "lastReportDate": 1595840614,
    "devType": 1,
    "lastReportWatts": 91,
    "maxReportWatts": 296
  },
  {
    "serialNumber": "122017037320",
    "lastReportDate": 1595840611,
    "devType": 1,
    "lastReportWatts": 78,
    "maxReportWatts": 305
  },
  {
    "serialNumber": "122018001358",
    "lastReportDate": 1595840616,
    "devType": 1,
    "lastReportWatts": 92,
    "maxReportWatts": 296
  }
]

Other note: the energymeter rounds the production of the current day to a whole number, while the cloud version shows it with 2 decimals. Is this based on the api or did you include a round function?

@DiedB It's just what shows here in this message. All the details from every single panel. Btw, I'm just a noob with ideas and I've no experience with any kind of programming. Sorry if I misunderstand the possibilities.

DiedB commented 4 years ago

Are those credentials the same for every system? And those entries in the JSON you posted are individual microinverters I suppose? The JSON you posted does not make a distinction between different strings of panels. We could make a device for every microinverter in Homey but I think that would be too much for most users.

KvDaalen commented 4 years ago

Why would you want to automate anything based on details of a single panel? Which use-case do you forsee with that detailed data?

Op zo 30 aug. 2020 12:26 schreef geurti64 notifications@github.com:

@geurti64 https://github.com/geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output?

I've to find out how to login. The user name and password is different from what I'm used to.

Read here: https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/

Install the apk that is listed (on your own risk ;-)). It will retrieve the “installer” credentials to access that api. Worked fine for me

JSON:

[

{

"serialNumber": "122018001310",

"lastReportDate": 1595840610,

"devType": 1,

"lastReportWatts": 80,

"maxReportWatts": 308

},

{

"serialNumber": "122017037787",

"lastReportDate": 1595840615,

"devType": 1,

"lastReportWatts": 78,

"maxReportWatts": 306

},

{

"serialNumber": "122017037789",

"lastReportDate": 1595840606,

"devType": 1,

"lastReportWatts": 90,

"maxReportWatts": 296

},

{

"serialNumber": "122018000241",

"lastReportDate": 1595840612,

"devType": 1,

"lastReportWatts": 90,

"maxReportWatts": 296

},

{

"serialNumber": "122017037914",

"lastReportDate": 1595840618,

"devType": 1,

"lastReportWatts": 87,

"maxReportWatts": 296

},

{

"serialNumber": "122017037772",

"lastReportDate": 1595840620,

"devType": 1,

"lastReportWatts": 85,

"maxReportWatts": 296

},

{

"serialNumber": "122018000891",

"lastReportDate": 1595840621,

"devType": 1,

"lastReportWatts": 89,

"maxReportWatts": 296

},

{

"serialNumber": "122018001281",

"lastReportDate": 1595840607,

"devType": 1,

"lastReportWatts": 79,

"maxReportWatts": 309

},

{

"serialNumber": "122018000625",

"lastReportDate": 1595840614,

"devType": 1,

"lastReportWatts": 91,

"maxReportWatts": 296

},

{

"serialNumber": "122017037320",

"lastReportDate": 1595840611,

"devType": 1,

"lastReportWatts": 78,

"maxReportWatts": 305

},

{

"serialNumber": "122018001358",

"lastReportDate": 1595840616,

"devType": 1,

"lastReportWatts": 92,

"maxReportWatts": 296

}

]

Other note: the energymeter rounds the production of the current day to a whole number, while the cloud version shows it with 2 decimals. Is this based on the api or did you include a round function?

@DiedB https://github.com/DiedB It's just what shows here in this message. All the details from every single panel. Btw, I'm just a noob with ideas and I've no experience with any kind of programming. Sorry if I misunderstand the possibilities.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DiedB/Homey-SolarPanels/issues/110#issuecomment-683403066, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQHT5D5RINJOEXKQRUQL3NTSDISMTANCNFSM4OWO7KOA .

geurti64 commented 4 years ago

Why would you want to automate anything based on details of a single panel? Which use-case do you forsee with that detailed data? Op zo 30 aug. 2020 12:26 schreef geurti64 notifications@github.com: @geurti64 https://github.com/geurti64 Can you check whether http://envoy.local/api/v1/production/inverters gives any output? I've to find out how to login. The user name and password is different from what I'm used to. Read here: https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/ Install the apk that is listed (on your own risk ;-)). It will retrieve the “installer” credentials to access that api. Worked fine for me JSON: [ { "serialNumber": "122018001310", "lastReportDate": 1595840610, "devType": 1, "lastReportWatts": 80, "maxReportWatts": 308 }, { "serialNumber": "122017037787", "lastReportDate": 1595840615, "devType": 1, "lastReportWatts": 78, "maxReportWatts": 306 }, { "serialNumber": "122017037789", "lastReportDate": 1595840606, "devType": 1, "lastReportWatts": 90, "maxReportWatts": 296 }, { "serialNumber": "122018000241", "lastReportDate": 1595840612, "devType": 1, "lastReportWatts": 90, "maxReportWatts": 296 }, { "serialNumber": "122017037914", "lastReportDate": 1595840618, "devType": 1, "lastReportWatts": 87, "maxReportWatts": 296 }, { "serialNumber": "122017037772", "lastReportDate": 1595840620, "devType": 1, "lastReportWatts": 85, "maxReportWatts": 296 }, { "serialNumber": "122018000891", "lastReportDate": 1595840621, "devType": 1, "lastReportWatts": 89, "maxReportWatts": 296 }, { "serialNumber": "122018001281", "lastReportDate": 1595840607, "devType": 1, "lastReportWatts": 79, "maxReportWatts": 309 }, { "serialNumber": "122018000625", "lastReportDate": 1595840614, "devType": 1, "lastReportWatts": 91, "maxReportWatts": 296 }, { "serialNumber": "122017037320", "lastReportDate": 1595840611, "devType": 1, "lastReportWatts": 78, "maxReportWatts": 305 }, { "serialNumber": "122018001358", "lastReportDate": 1595840616, "devType": 1, "lastReportWatts": 92, "maxReportWatts": 296 } ] Other note: the energymeter rounds the production of the current day to a whole number, while the cloud version shows it with 2 decimals. Is this based on the api or did you include a round function? @DiedB https://github.com/DiedB It's just what shows here in this message. All the details from every single panel. Btw, I'm just a noob with ideas and I've no experience with any kind of programming. Sorry if I misunderstand the possibilities. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#110 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQHT5D5RINJOEXKQRUQL3NTSDISMTANCNFSM4OWO7KOA . I would like to see the difference between East and West on one single Envoy. Plus, the web API from Enphase is much slower then this API. @DiedB yes, those are the entries from individual micro inverters. Most users don't have to use that option 😉

DiedB commented 4 years ago

The newest version with Envoy support has been released. @KvDaalen your suggestions are good, but I will make them into a separate Enphase app in a few months (including SDKv3 support). The Solar Panels app is becoming too cluttered with custom flows and capabilities. Could you make an issue here about that?

KvDaalen commented 4 years ago

No problem.