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

Non-metered Envoys return empty responses from /ivp/meters #11

Open mleppanen opened 9 months ago

mleppanen commented 9 months ago

Hello,

this API seems to be just what I need for my local metering system. However, when setting this up, I did the configuration and was able to connect to the Enphase system. Trying out gateway_console.py I found out that gateway.api_call('/ivp/meters') returns an empy response. This is probably due to my gateway being a non-metered one. The gateway_console.py script was easy to fix by adding next(..., {state: 'enabled'}) structure around the list comprehension on lines180 and 198 but I am wondering if the idea of the API would be return something where this non-meteredeness would be obvious?

Keep up the good work! Best regards, Marko

catsmanac commented 9 months ago

The /production endpoint will be missing eim types if it's a non-metered envoy and will be returning activecount=0 for eim type if it is a metered type without configured meters. It's a bit of a slow endpoint though. And the [] response (or 401 status for older firmware) for ivp/meters is as good an indication.

{
    "production": [{
            "type": "inverters",
            "activeCount": 15,
            "readingTime": 1694549655,
            "wNow": 4085,
            "whLifetime": 943236
        }, {
            "type": "eim",
            "activeCount": 1,
            "measurementType": "production",
            "readingTime": 1694549732,

This one uses the /production page and the eim type to determine if it's metered and if not fallback to using the /api/v1/production endpoint (and /api/v1/production/inverters for the individual inverters)