Start Charging

Learn how to initiate a charging session on a connected chargestation

Prerequisites

  1. Have an API token and verified it is working for you. See Token Request
  2. Created and connected your chargestation to eDRV. See Connect a Chargestation
  3. Get Connector and User Id. All charging sessions on eDRV run on a connector on behalf of a user. You will need these two in order to start charging session.
    • Connector Id: You can get this by calling the GET /chargestations endpoint.
    • User Id: You can get this by calling the GET /users endpoint.

Step 1: Start a Session

Start a new charging session by sending a POST /sessions request

πŸ“˜

Creating a new session is equivalent to a Charging Start attempt

eDRV attempts a remote start on the specified connector on each new POST /sessions request.

The session is one of your core data assets. It contains all the instantaneous details about the charging status, calculated costs, energy metrics etc. You will be using sessions extensively, learn more about Sessions.

const request = require('request');

const options = {
  method: 'POST',
  url: 'https://api.edrv.io/v1.1/sessions',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Authorization: 'Bearer eDRV_TOKEN'
  },
  body: {connector: '5fca57b3fbfcc320b3b03f23', 
         user: '5fca57b3fbfcc320b3b03f24'
  },
  json: true
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
  /*Save session Id within your appication*/
  const session_id = body.result._id;
  
});

A successful response from the API will create a new session with the status field as created

πŸ“˜

Under the hood

Successfully creating a new session kicks off a chain of events on eDRV:

  • eDRV attempts a remote start charging start for the specified user and connector
  • The chargestation will wait for the driver to plug in their cable at which time charging can start.
  • If the driver has plugged in their connector, the chargestation will start a charging transaction.
  • If the driver does not plug in their cable within 120 seconds the session is timed out.

Step 1.1: Start a Session with Target

You can pre-configure a session for a specific cost, time, and/or energy target by including a target in the POST /sessions request. This will automatically stop the session when it crosses the defined target in terms of cost, time, and/or energy. See Charging with Session Targets for further details.

const request = require('request');

const options = {
  method: 'POST',
  url: 'https://api.edrv.io/v1.1/sessions',
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Authorization: 'Bearer eDRV_TOKEN'
  },
  body: {connector: '5fca57b3fbfcc320b3b03f23', 
         user: '5fca57b3fbfcc320b3b03f24',
         "target": {
          "cost": 12,
          "time": 60
                }
  },
  json: true
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
  /*Save session Id within your appication*/
  const session_id = body.result._id;
  
});

For the above session target, the system will stop the session when the time goes beyond 60 minutes or the cost goes beyond 12 in the specified currency.

πŸ“˜

Session Targets Accuracy

Please note that the chargestation will send the energy reports every 30 seconds to 1 minute. Because of that, the session may not stop at the exact target values but when it exceeds the target limit. Therefore, consider adding some padding to the values when setting targets for a session.

Step 2: Save the Session Id

You will need the session Id to:

Step 3: Confirm Charging has started via Webhooks

Energy flow in a session can take some to to start. E.g. because a driver needs to insert the charging cable and then charging can start.
Please monitor your application Webhook for the following event that confirms a charging session has stopped:

Webhook Event session.created

A confirmation from eDRV that this session was created and is awaiting a charging start event from the chargestation.

Webhook Event session.started

A confirmation directly from the chargestation that this session has successfully started.

❗️

Please do not poll the sessions endpoint for a change of status

This is an inefficient use of server resources on both sides. Please use Webhooks instead.


What’s Next

Time to learn how to stop this session and report instantaneous metrics to your drivers