Gravity Connect API (Virtual Peaker) (2.0.6)

Download OpenAPI specification:

License: BSD

Introduction

This is the documentation for the endpoints implemented by Virtual Power Plants (VPPs) for integrating devices with the Gravity Connect API.

The endpoints that a Device Partner implements are described in the Device Partner Guide.

Changelog

Below are any noteworthy changes to the API spec.

  • 2.0.6 - Revised the explanatory sections of the documentation.
  • 2.0.5 - Added Device Partner Driven Enrollment.
  • 1.2.2 - Added maximum payload size
  • 1.2.1 - Clarifying command status vs device command status reporting
  • 1.2.0 - Clarifying that auth header is Authorization not Authentication
  • 1.1.0 - Adding pairingCode as an optional field for Publish device enrollment
  • 1.0.1 - Fixing the device key in the Publish device enrollment status to refer to the device details rather than just the kind of device

Authentication

Gravity Connect uses the following authentication models:

Requests from the VPP to the Device Partner's endpoints

  • These requests use OAuth 2.0 authentication. Please note that these OAuth credentials are required even if the homeowner enrollment flow is not OAuth-based. If the homeowner enrollment flow is OAuth-based, it can use separate credentials or it can re-use these.
  • The Device Partner provides:
    • clientId: A program-specific ID.
    • clientSecret: A program-specific secret.

Requests from the Device Partner to the VPP's endpoints

  • These requests authenticate using a combination of the following credentials and HMAC authentication. The signature validation allows Gravity Connect endpoints to be called only by authorized parties in possession of the valid PUBLISH_SECRET.
    • The VPP provides:
      • PROGRAM_PUBLISH_KEY: The unique identifier for a utility program, provided when a program is set up.
      • PROGRAM_PUBLISH_SECRET: The secret key used to generate HMAC signatures when publishing program-level data, provided when a program is set up.
      • DEVICE_PUBLISH_SECRET: The secret key used to generate HMAC signatures when publishing device-level data, provided when each device is enrolled.

To authenticate with the VPP's endpoints:

  1. Construct the payload body for the API request.
  2. Generate an HMAC hash on the request body content using the PROGRAM_PUBLISH_SECRET or DEVICE_PUBLISH_SECRET, as specified for that endpoint.
  3. Set the Authorization header with the signature.

Example: Authorization: Publish 12345abcdef

  • Where 12345abcdef is the HMAC hash.
  • See the HMAC generation script below for sample code.

HMAC Script

The below script is an example of how to generate an HMAC for some payload in javascript. Other languages should have standard crypto libraries that work similarly.

const crypto = require('crypto');

const secret = 'your_secret_here';
const body = `{
  "uid": "your_device_uid",
  "kind": "TSTAT",
  "signal": [{
    "key": "mode",
    "value": "HEAT",
    "time": "2021-01-28T15:36:48.586697"
  }],
  "setting": [{
    "key": "max-setpoint",
    "value": 31.0,
    "time": "2020-10-20T22:10:57.101616"
  }]
}`;

const computedHMAC = crypto.createHmac('sha256', secret).update(body).digest('hex');
console.log(`Publish ${computedHMAC}`);

Error Handling

For the following error codes, please retry using exponential backoff:

  • 429
  • 502
  • 503
  • 504

All other requests that receive an error should be discarded.

Publishing

All of the endpoints below allow the Device Partner to publish data to the Virtual Peaker platform, which avoids Virtual Peaker having to constantly poll the data when there haven't been any changes. Part of the Device Partner Implementation does include endpoint to read poll for data, which could be used by Virtual Peaker to gather the first batch of data or for debugging.

Notes:

  • The maximum supported payload size for all requests listed below is 262,144 bytes.

Publish signal/setting value

This endpoint publishes device data to Virtual Peaker. The signal and setting types vary by device type. Please reference the Device Specific Definitions section to see the signals and settings for each device. Also, a required field is required overall for that device although not required every time data is reported for that device.

path Parameters
PROGRAM_PUBLISH_KEY
required
string

The identifier of the program within Virtual Peaker

header Parameters
Authorization
required
string^Publish [a-f\d]+$

Publish, followed by the value of: HMAC(algorithm=`sha256``, key=DEVICE_PUBLISH_SECRET, data=BODY)

Request Body schema: application/json
required
uid
required
string

The partner's unique device identifier

kind
required
string (DeviceKindEnum)
Enum: "HWH" "TSTAT" "BATTERY" "EVSE" "V2G" "STORAGE-HVAC"
required
Array of objects (SignalSetting)
required
Array of objects (SignalSetting)

Responses

Request samples

Content type
application/json
{
  • "uid": "string",
  • "kind": "HWH",
  • "signal": [
    ],
  • "setting": [
    ]
}

Response samples

Content type
application/json
{
  • "message": "string"
}

Publish command status

Used to report back the status of a command. For more details please reference the FAQs

path Parameters
PROGRAM_PUBLISH_KEY
required
string

The identifier of the program within Virtual Peaker

header Parameters
Authorization
required
string^Publish [a-f\d]+$

Publish, followed by the value of: HMAC(algorithm=`sha256``, key=PROGRAM_PUBLISH_SECRET, data=BODY)

Request Body schema: application/json
required
state
required
string
Enum: "PENDING" "IN_PROGRESS" "FAILED" "OPT_OUT" "CANCELLED" "COMPLETED"

State of the command:

  • PENDING - scheduled but not started
  • IN_PROGRESS - when pending command hits start time
  • FAILED - something has prevented the command from being scheduled or started
  • OPT_OUT - device owner has specified that they don’t want to participate in an event
  • CANCELLED - utility has said they don’t want the event to happen
  • COMPLETED - end time of event has been reached without becoming CANCELLED or OPT_OUT
description
string

human readable status

time
required
string <date-time>

For more see, RFC 3339, section 5.6. As an example, '2017-07-21T17:32:28Z'. The timezone is always zero UTC offset.

refId
required
string

Command Reference ID

Responses

Request samples

Content type
application/json
{
  • "state": "PENDING",
  • "description": "string",
  • "time": "2019-08-24T14:15:22Z",
  • "refId": "string"
}

Response samples

Content type
application/json
{
  • "message": "string"
}

Publish device command status

Only used if grouping is being used. For more details please reference the FAQs

path Parameters
PROGRAM_PUBLISH_KEY
required
string

The identifier of the program within Virtual Peaker

header Parameters
Authorization
required
string^Publish [a-f\d]+$

Publish, followed by the value of: HMAC(algorithm=`sha256``, key=PROGRAM_PUBLISH_SECRET, data=BODY)

Request Body schema: application/json
required
state
required
string
Enum: "PENDING" "IN_PROGRESS" "FAILED" "OPT_OUT" "CANCELLED" "COMPLETED"

State of the command:

  • PENDING - scheduled but not started
  • IN_PROGRESS - when pending command hits start time
  • FAILED - something has prevented the command from being scheduled or started
  • OPT_OUT - device owner has specified that they don’t want to participate in an event
  • CANCELLED - utility has said they don’t want the event to happen
  • COMPLETED - end time of event has been reached without becoming CANCELLED or OPT_OUT
description
string

human readable status

time
required
string <date-time>

For more see, RFC 3339, section 5.6. As an example, '2017-07-21T17:32:28Z'. The timezone is always zero UTC offset.

refId
required
string

Command Reference ID

uid
required
string

DEVICE UID

Responses

Request samples

Content type
application/json
{
  • "state": "PENDING",
  • "description": "string",
  • "time": "2019-08-24T14:15:22Z",
  • "refId": "string",
  • "uid": "string"
}

Response samples

Content type
application/json
{
  • "message": "string"
}

Publish device enrollment status

If using OAuth Device Onboarding, devices are assumed to be enrolled when initially discovered.

path Parameters
PROGRAM_PUBLISH_KEY
required
string

The identifier of the program within Virtual Peaker

header Parameters
Authorization
required
string^Publish [a-f\d]+$

Publish, followed by the value of: HMAC(algorithm=`sha256``, key=PROGRAM_PUBLISH_SECRET, data=BODY)

Request Body schema: application/json
required
state
required
string
Enum: "enrolled" "unenrolled"
required
object (DeviceDetails)
time
required
string <date-time>
pairingCode
string

Only passed if using Pairing Code Device Discovery. The current format is:

  • 2 alphanumeric characters to denote the pairing code prefix representing the program
  • 5 random numeric characters that VP uses to link the user to an existing device
  • 1 check digit. This check digit will be generated following the Luhn algorithm to ensure the 5 digit number is valid. This validation can be performed on the device partner side to provide immediate feedback, but will also be done within our API.

Responses

Request samples

Content type
application/json
{
  • "state": "enrolled",
  • "device": {
    },
  • "time": "2019-08-24T14:15:22Z",
  • "pairingCode": "string"
}

Response samples

Content type
application/json
{
  • "message": "string"
}

Publish device partner driven enrollment

Used for publishing device and site information for in-app enrollment, pre-enrollment from OEM-owned marketplaces, and bulk device enrollment.

path Parameters
PROGRAM_PUBLISH_KEY
required
string

The identifier of the program within Virtual Peaker

header Parameters
Authorization
required
string^Publish [a-f\d]+$

Publish, followed by the value of: HMAC(algorithm=`sha256``, key=PROGRAM_PUBLISH_SECRET, data=BODY)

Request Body schema: application/json
required
time
required
string <date-time>

For more see, RFC 3339, section 5.6. As an example, '2017-07-21T17:32:28Z'. The timezone is always zero UTC offset.

required
Array of objects (DeviceDetails)
required
object (UserDetails)

Responses

Request samples

Content type
application/json
{
  • "time": "2019-08-24T14:15:22Z",
  • "devices": [
    ],
  • "site": {
    }
}

Response samples

Content type
application/json
{
  • "message": "string"
}