Skip to main content
If you need to account for the solar component of energy that is going into the vehicle or/and are implementing V2H, V2G or VPP, schedule a call with our team for implementation advice.

Design

To optimise charging of the EV by energy cost, we need to:

Once the customer completes the Connect flow, or if you imported their tariff:
  1. When the vehicle connects to a charging station, obtain its SoC & ready-by time.
  2. Call schedules API to calculate a cost-optimised charging schedule.
  3. Send this schedule to the vehicle.

To display charging costs:

  1. Log the transferred energy to the meter records API under the IMPORT tariff.
  2. When you want to display the charging costs, call the API to get them by charging session (including in real-time) or day/month/year.

Implementation

To create a cost-optimised charging schedule, you will need:
  1. Time when charging can start (i.e. when the vehicle was plugged in).
  2. Amount of energy required in KWH.
  3. Expected charging speed (use charger rating or 7KW for AC charging).
  4. Time when charging must be completed (i.e. ready-by or departure time).
Call the Scheduling API to create an IMPORT schedule that follows a low tariff.In the example vehicles require 5,3KWH. Charging can start at 7 pm must be completed by 5 am the following day. The schedule instructs the vehicle to start charging at 1 am and stop at 5 am schedule.start_time and schedule.end_time.
curl --request POST \
  --url https://api.flatpeak.com/schedules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "location_id": "loc_641b90b758fb8e6293716e40",
    "max_power": {
      "units": "W",
      "value": "7000"
    },
    "data": [
      {
        "device_id": "dev_664525107c44d88a37ca1ad7",
        "direction": "IMPORT",
        "start_time": "2024-08-01T19:00:00Z",
        "end_time": "2024-08-02T05:00:00Z",
        "max_power": {
          "units": "W",
          "value": 7000
        },
        "energy": {
          "units": "WH",
          "value": 5300
        }
      }
    ]
  }'
Call Metering API and submit IMPORT metering (at the device level) when the vehicle is charging. Set direction=IMPORT and tariff_rate=IMPORT.
IMPORTANT: In order for you to later display energy cost by charging session, make sure to include session identifier as session_reference_id=SESSION123.
curl --request POST \
  --url https://api.flatpeak.com/meters/interval \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-02T01:00:00Z",
  "end_time": "2024-08-02T02:00:00Z",
  "device_id": "dev_65e6d8334c8d715963d99db3",
  "location_id": "loc_641b90b758fb8e6293716e40",
  "session_reference_id": "SESSION123",
  "direction": "IMPORT",
  "tariff_rate": "IMPORT",
  "units": "W",
  "value": 2034
}'
If you want to display charging cost in real-time, use instant-cost-calculate API
  • By session ID
  • By day/month/year
When you need to display the cost of charging, call calculate-cost-by-interval API endpoint to show the cost of charging aggregated by day/month/year. To display the cost per charging session, call the calculate-cost-by-session endpoint.
curl --request POST \
  --url 'https://api.flatpeak.com/costs/session/SESSION123 \
  ?direction=IMPORT \
  &include_tariff=true' \
  --header 'Authorization: Bearer <token>'