📊 Intelligence & Forecasting — app5.5
Developer CourseModule 5: Intelligence & Forecastingapp5.5
Hands-on20 min

Hands-on: Build a Price-Aware Dispatch Strategy

📊 Module 5: Intelligence & Forecasting

Hands-on: Build a Price-Aware Dispatch Strategy

You will build a simple script that reads grid prices and decides whether to charge or discharge a battery.

Setup

export EAT_KEY="eat_test_YOUR_KEY_HERE"

# Verify pip and SDK
pip3 install energyatit 2>/dev/null
python3 -c "import energyatit; print('SDK ready')"

Exercise 1: Read Current Prices

curl -s -H "Authorization: $EAT_KEY" \
  "https://app.energyatit.com/api/v1/grid/prices?region=UAE" | python3 -m json.tool
curl.exe -H "Authorization: $env:EAT_KEY" "https://app.energyatit.com/api/v1/grid/prices?region=UAE" | ConvertFrom-Json | ConvertTo-Json -Depth 10

Exercise 2: Read Battery State

curl -s -H "Authorization: $EAT_KEY" \
  https://app.energyatit.com/api/v1/grid-connections/1/readings | python3 -m json.tool
curl.exe -H "Authorization: $env:EAT_KEY" "https://app.energyatit.com/api/v1/grid/prices?region=UAE" | ConvertFrom-Json | ConvertTo-Json -Depth 10

Exercise 3: Price-Based Dispatch Decision

Create price_dispatch.py:

import os, json, urllib.request

KEY = os.environ["EAT_KEY"]
BASE = "https://app.energyatit.com/api/v1"

def api_get(path):
    req = urllib.request.Request(f"{BASE}{path}", headers={"Authorization": KEY})
    return json.loads(urllib.request.urlopen(req).read())

# Get price
prices = api_get("/grid/prices?region=UAE")
price = prices["data"]["current_price_mwh"]
print(f"Current price: ${price}/MWh")

# Get battery SOC
readings = api_get("/grid-connections/1/readings")
soc = readings["data"]["readings"].get("soc_pct", 50)
print(f"Battery SOC: {soc}%")

# Decision
if price < 30 and soc < 80:
    print("ACTION: CHARGE (price is low, battery has room)")
elif price > 60 and soc > 30:
    print("ACTION: DISCHARGE (price is high, battery has charge)")
else:
    print("ACTION: HOLD (no clear opportunity)")
python3 price_dispatch.py

Exercise 4: Check Reliability

curl -s -H "Authorization: $EAT_KEY" \
  https://app.energyatit.com/api/v1/intel/asset/1/reliability | python3 -m json.tool
curl.exe -H "Authorization: $env:EAT_KEY" "https://app.energyatit.com/api/v1/intel/asset/1/reliability" | ConvertFrom-Json | ConvertTo-Json -Depth 10

Verification

Lab complete if: you read prices, read battery state, made a dispatch decision, and checked reliability.

Open Hands-on Lab

Complete the exercise in the Developer Hub.

Launch

Log in to track your progress and earn certifications.