/sunpower-1

Unofficial tests of apparent Sunpower API

Primary LanguageRuby

Sunpower

https://codeclimate.com/github/jeffkowalski/sunpower/badges/gpa.svg

API points

w.__envapidom = 'https://elhapi.edp.sunpower.com/';

from envcfg.js:

__env = {
    SP_ELH_VERSION: 'SP_ELH_VERSION_2', // SP_ELH_VERSION must match SP_ELH_VERSION lambda variable in ElhApi cloudformation
    ELH_API_USER: w.__envapidom + 'v1/elh/user/',
    ELH_API_ADDRESS: w.__envapidom + 'v1/elh/address/',
    ELH_API_ADDRESS_V2: w.__envapidom + 'v2/elh/address/',
    ELH_API_ASYNC_RESULT: w.__envapidom + 'v1/elh/asyncResult',
    ELH_API_PASSWORD_RESET: w.__envapidom + 'v1/elh/passwordreset/',
    ELH_API_AUTHENTICATE: w.__envapidom + 'v1/elh/authenticate',
    ELH_API_SESSION: w.__envapidom + 'v1/elh/session',
    ELH_API_AUTHENTICATEKIOSK: w.__envapidom + 'v1/elh/authenticatekiosk',
    ELH_API_FEEDBACK: w.__envapidom + 'v1/elh/processFeedback',
    ELH_API_CHECK_EMAIL: w.__envapidom + 'v1/elh/register/checkEmail',
    ELP_API_VALIDATE_SN: w.__envapidom + 'v1/elh/register/validateSerial/',
    ELH_API_CREATE_ACCOUNT: w.__envapidom + 'v1/elh/register/createAccount',
    ELH_API_SEND_ACCOUNT_NOTIFICATION: w.__envapidom + 'v1/elh/register/sendAccountNotification',
    ELH_API_VALIDATE_EMAIL: w.__envapidom + 'v1/elh/register/validateEmail',
    ELH_API_COLLECTOR: w.__envapidom + 'v1/elh/wifi/collector',
    ELH_API_DEVICE_STATUS: w.__envapidom + 'v1/elh/wifi/status',
    ELH_API_WIFI_NETWORKS: w.__envapidom + 'v1/elh/wifi/networks',
    ELH_API_SET_WIFI_NETWORK: w.__envapidom + 'v1/elh/wifi/setNetwork',
    ELH_API_SET_WIFI_NETWORK_STATUS: w.__envapidom + 'v1/elh/wifi/setNetwork/status',
    ELH_API_TOU: w.__envapidom + 'v1/elh/tou',
    ELH_API_SET_TOU: w.__envapidom + 'v1/elh/setTou',
    ELH_API_REFERRAL: w.__envapidom + 'v1/elh/referral'
};

Real time net display

Helpers

Example credentials file

---
username: "username"
password: "password"
isPersistent: true

get credentials

require 'yaml'
require 'json'
p YAML.load_file(file).to_json

get json value

require 'json'
result = JSON.parse(string)
name.split('.').each { |key| result = result[key] }
p result

pretty-print json

(json-reformat-from-string data)

Authenticate

curl -H "Content-Type:application/json" -X POST -d "$credentials" "$api/authenticate"

Get Address Activity

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/activity?async=false"

Get Address Alerts

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/alerts?async=false"

Get Address Components

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/components"

Get Address Power

Returns the “current” power. The time of the reading is not specified, and I’ve noticed these are often quite stale.

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/power?async=false"

Get Address Energy Hour

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/energy/hour?async=false&startepm=1565805600000"

The payload is an array of string records. Each record has the following comma-separated fields:

timestamp of sampleYYYY-MM-DDTHH:MM:SS
energy producedfloat kWh

Get Address Energy Minute

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/address/$address/energy/minute?endepm=1565827200000&startepm=1565740800000"

The payload is an array of string records. Each record has the following comma-separated fields:

timestamp of sampleYYYY-MM-DDTHH:MM:SS
energy producedfloat kWh

Get WiFi Status (Device Status)

curl --silent --header "Authorization: SP-CUSTOM $token" "$api/wifi/status?cacheBreaker=1565824273640&serialNumber=ZT163185000441C1876"