Matthew1471 / Enphase-API

Enphase-API is an unofficial project providing an API wrapper (including local/LAN Gateway API) and the documentation for Enphase®'s products and services.
GNU General Public License v3.0
76 stars 10 forks source link

Getting inverter-level power, current, voltage and temperature from the local API? #12

Closed PertuyF closed 8 months ago

PertuyF commented 8 months ago

Hi there, It looks like enlighten is able to retrieve quite detailed information at the inverter level, based on this article. I wasn't able to find information about this in the doc from this repo. Would anyone have an idea how to get this data?

Best, Fabien

Matthew1471 commented 8 months ago

Try https://github.com/Matthew1471/Enphase-API/blob/main/Documentation/IQ%20Gateway%20API/IVP/PEB/DevStatus.adoc (look carefully at the example DeviceStatus)

   "pcu": {
        "fields": [
            "serialNumber",
            "devType",
            "communicating",
            "recent",
            "producing",
            "reportDate",
            "temperature",
            "dcVoltageINmV",
            "dcCurrentINmA",
            "acVoltageINmV",
            "acPowerINmW"
        ],
        "values": [
            [
                "123456789101",
                1,
                true,
                true,
                true,
                1687204569,
                29,
                36742,
                677,
                243872,
                26456
            ],
...

..and if you're only after the current wattage panel by panel there's also https://github.com/Matthew1471/Enphase-API/blob/main/Documentation/IQ%20Gateway%20API/V1/Production/Inverters.adoc as used by the Console example.

I thought there was an rpttemp too.. that might be one of the internal API calls I haven't documented yet but found in the code.

Update: Found it, /ivp/peb/rpttemp will also get you IQ Gateway temperature 😄, I will be adding some more of the Internal endpoints as I plan to document all the URLs. There may also be /ivp/pdm/device_data.

PertuyF commented 8 months ago

DeviceStatus is exactly what I have been looking for, and I missed the details in the doc. Thanks a ton for your help, and for your work putting this project together!

Matthew1471 commented 8 months ago

You're welcome, closing the issue 😄

PertuyF commented 8 months ago

@Matthew1471 I'm having troubles with DeviceStatus. I keep getting 401: Unauthorized despite using a valid token and reusing the session cookies from /auth/check_jwt. I may be doing it wrong, any tips welcome :)

Matthew1471 commented 8 months ago

@Matthew1471 I'm having troubles with DeviceStatus. I keep getting 401: Unauthorized despite using a valid token and reusing the session cookies from /auth/check_jwt.

I may be doing it wrong, any tips welcome :)

Requires an Installer level token (technically anything equal or above "Support" which is Level 4) rather than an Owner one.

{
  "anybody" :1,
  "monitor": 2,
  "owner": 2,
  "prov": 3,
  "support": 4,
  "sysadmin": 5,
  "installer": 6,
  "envoy": 7,
  "enphase": 7,
  "factory": 7
}

Enphase recently started locking down the API dependent on what "role" your JWT token has (see https://support.enphase.com/s/question/0D53m00009CewmJCAR/make-streammeter-available-with-owner-token). You can view the info that's inside a JWT via https://jwt.io

Get a token from an email address that Enphase thinks is an installer and that has access to your Enphase System (the owner has granted access by inviting the "installer" to the account - you can have multiple installers so this won't impact your real installer). Installer tokens expire every 12 hours, my code can help with renewing those tokens.

PertuyF commented 8 months ago

Got it to work, thanks a lot for your guidance :)