Skip to main content

Design

To optimise storage system’s operation based on energy cost:

Once the customer completes the Connect flow, or if you imported their tariff:
  1. Charge from solar (if present) when surplus is available.
  2. Charge from grid when IMPORT tariff is low if solar is not sufficient.
  3. Supply stored energy to premises when IMPORT tariff is high and solar is not sufficient.
  4. Export stored surplus energy to the grid when EXPORT tariff is high.

To calculate the savings provided by the storage system:

  1. Find beriod of high and low electricity cost for grid IMPORT and EXPORT.
  2. Log the cost of energy when charging from the grid using the IMPORT tariff.
  3. Account charging from local generation source (e.g., solar) as “free” energy.
  4. Log the cost of energy when supplying from your system to the customer’s premises, using the IMPORT tariff at the time of supply.
  5. Apply a straightforward calculation to determine savings (details provided below).

Implementation

  • Know how much energy you need?
  • Don't know how much energy you need?
To get your system to charge from the grid at the lowest cost, call the Scheduling API to create an IMPORT schedule that follows a low tariff.The example below shows that your system will require 5.3 kWh between 7 pm and 5 am the following day. The scheduling API will advise you to instruct your system to charge between 1 am and 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": "4000"
    },
    "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": 4000
        },
        "energy": {
          "units": "WH",
          "value": 5300
        }
      }
    ]
  }'
To get your system to supply the energy it previously stored when the grid import tariff is high, call the slots-threshold to obtain a list of high-peak tariff periods. Set relative=0.5 to get slots when the tariff is at the top 50% of the range.
curl --request GET \
  --url 'https://api.flatpeak.com/slots/threshold/loc_65e42ce4d3b813479b252160 \
  ?start_time=2023-06-15T09%3A00%3A00Z \
  &end_time=2023-06-16T09%3A00%3A00Z \
  &direction=IMPORT \
  &segment=HIGH \
  &relative=0.7' \
  --header 'Authorization: Bearer <token>'
If your customer has an export tariff, use the Scheduling API to create an export plan that sends energy to the grid when export tariff is high. You will need to be able to measure the amount of energy that “moves” out of the property and not just from your system into the property.To use Scheduling API to create an export plan, you must know how much energy you will have available for export and when.In the example below, you want to export 10kWh between 6 pm and 6 am the following day. The API suggests that you export between 6 pm and 11 pm exporting 10kWh and earning €9.28:
curl --request POST \
  --url https://api.flatpeak.com/schedules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "location_id": "loc_641b90b758fb8e6293716e40",
    "data": [
      {
        "device_id": "dev_65e6d8334c8d715963d99db3",
        "direction": "EXPORT",
        "start_time": "2024-08-01T15:00:00Z",
        "end_time": "2024-08-02T02:00:00Z",
        "max_power": {
          "units": "W",
          "value": 4000
        },
        "energy": {
          "units": "WH",
          "value": 10000
        }
      }
    ]
  }'
To calculate the energy cost savings provided by your system, you need to record the cost of energy stored.Call Metering API and submit IMPORT metering (at the device level) when your system is importing the energy. Set direction=IMPORT and tariff_rate=IMPORT to determine what it did cost.
Request
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",
  "direction": "IMPORT",
  "tariff_rate": "IMPORT",
  "units": "W",
  "value": 2634
}'
If you need to account for energy produced by a “free” power source, such as a local solar array, set tariff_rate to LOCAL. If you send LOCAL and IMPORT meter readings covering the same period, they will be summarised.
When your system supplies your customer’s premises with previously stored energy, log it as if supplied directly from the grid. Call submit-meter-interval setting direction=EXPORT and tariff_rate=IMPORT to determine what it could have cost.
Request
curl --request POST \
  --url https://api.flatpeak.com/meters/interval \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-01T17:00:00Z",
  "end_time": "2024-08-01T18:00:00Z",
  "device_id": "dev_65e6d8334c8d715963d99db3",
  "location_id": "loc_641b90b758fb8e6293716e40",
  "direction": "EXPORT",
  "tariff_rate": "IMPORT",
  "units": "W",
  "value": 1214
}'
When your system exports energy to the grid, log it using the export tariff. Call submit-meter-interval endpoint setting direction=EXPORT and tariff_rate=EXPORT to determine what it earned from the grid.
Request
curl --request POST \
  --url https://api.flatpeak.com/meters/interval \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-01T18:00:00Z",
  "end_time": "2024-08-01T19:00:00Z",
  "location_id": "loc_641b90b758fb8e6293716e40",
  "direction": "EXPORT",
  "tariff_rate": "EXPORT",
  "units": "W",
  "value": 2144
}'
1. To get the cost of imports: Call calculate-energy-cost-by-interval endpoint to request the cost of imported energy (note the direction=IMPORT) for the period for which you would like to provide the report:
curl --request POST \
  --url 'https://api.flatpeak.com/costs/interval/dev_65e6d8334c8d715963d99db3?direction=IMPORT' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-01T00:00:00Z",
  "end_time": "2024-08-01T23:59:59Z"
}'
2. To get the value of energy that your system supplied to premises: Then, call calculate-energy-cost-by-interval again to request what would be the cost of energy if your device did not supply it from storage (note the direction=EXPORT); for the same period:
curl --request POST \
  --url 'https://api.flatpeak.com/costs/interval/dev_65e6d8334c8d715963d99db3?direction=EXPORT' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-01T00:00:00Z",
  "end_time": "2024-08-01T23:59:59Z"
}'
3. To get the value of exports: If your system is exporting energy to the grid, call calculate-energy-cost-by-interval endpoint for the third time to request the value of exported energy (note use of Location ID and direction=EXPORT):
curl --request POST \
  --url 'https://api.flatpeak.com/costs/interval/loc_641b90b758fb8e6293716e40?direction=EXPORT' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "start_time": "2024-08-01T00:00:00Z",
  "end_time": "2024-08-01T23:59:59Z"
}'
Use the aggregation parameter to get data for a week, month, or year.
  • If your system is not exporting
  • If your system is exporting
The difference between the tariff.value figures in the IMPORT and EXPORT responses will be the savings your system has achieved.The example below covers a day period and works out as follows:
  • Imported 5.5KWh of energy at total cost of €0.64; averaging €0.116/KWh.
  • Supplied 3.2KWh of energy at total cost of €1.18; averaging €0.368/KWh.
  • Calculate savings as €1.18 grid costs avoid minus €0.64 paid, making a saving of €0.54 or 54% savings.
If you’ve logged solar usage by submitting solar generation via the LOCAL tariff_rate (step 4), solar savings will automatically be included in the calculation.
I