Git Product home page Git Product logo

enphaselocaltoinfluxdb's Introduction

NG Envoy local data extractor

This is very much a word in progress. Right now it sends data to influxdb. Looking to do prometheus metrics, some REST endpoint, etc. It doesn't use the stream API endpoint which I can't seem to auth for.

Authorization flow

The authentication flow for accessing local APIs on a newer Enphase Envoy is counter-intuitive. Thou

When trying to access the local API via https://envoy.lan/home for example, through the browser, one will be redirected to https://envoy.lan/home#auth which asks for a JWT token. This token is obtained by login-in interactively to the https://entrez.enphaseenergy.com with your Enlighten credentials.

Note that you have to disable all certificate verifications on local calls

Obtaining a long-term JWT Token

In order to obtain the token in a back-end process, one has to POST to https://enlighten.enphaseenergy.com/login with your enphase community user[email] and [password].

Armed with the cookies returned by the endpoint you will then hit https://enlighten.enphaseenergy.com/entrez-auth-token?serial_num=SERIAL_NUMBER. SERIAL_NUMBER is the serial number of your envoy.

This will return a JSON object that looks like so:

{
    "generation_time":1657053332,
    "token":"DE34wMDAasdADS1ZC03_LONG_LONG_TRUNCATED_LONG_LONG_bT6enusdwr23DQ",
    "expires_at":1672605332
}

generation_time and expires_at are Unix Timestamps in seconds. token is your JWT token

Typically, once you have a JWT Token, you can use it by passing it in the header of the calls to the local API as a Bearer Token. Not so here. Calls to the Local API do not use the token but rely on a set of cookies to be there for authentication.

However to obtain that cookie, you have to authorize the JWT token with a local call

Obtaining the cookies

By making a call to https://envoy.lan/auth/check_jwt with a "Authorization" token set to "Bearer REPLACE_WITH_JWT_TOKEN" you will receive a cookie that you can store. You will re-use that cookie to make all of your local API calls.

Making local API calls

Once you've obtained the cookie, you can make calls to https://envoy.lan/production.json?details=1 or others providing your HTTP client is configured to include the cookie.

Stream endpoint

Though others have been successful hitting the stream endpoint (https://envoy.lan/stream/meter), it always returns a 401 for me on release D7.0.107 (00f3a9). I tied using the cookies, the JWT token and basic auth with various installer credentials.

Interesting local API endpoints

enphaselocaltoinfluxdb's People

Contributors

dlmcpaul avatar edasque avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.