🚀 Dispatch & Control — app3.3
Developer CourseModule 3: Dispatch & Controlapp3.3
Reading12 min

The Command Lifecycle: 6 States from Pending to Completed

🚀 Module 3: Dispatch & Control

The Command Lifecycle: 6 States from Pending to Completed

Every dispatch command goes through a state machine with 6 possible states. Understanding this lifecycle is critical for building reliable apps.

The 6 States

pending → dispatched → acknowledged → executed → completed
                                                    ↓
                                                  failed
StateMeaningWhat Your App Should Do
pendingCommand created, not yet sentShow "Queued"
dispatchedSent to device, waiting for ackShow "Sending..."
acknowledgedDevice received the commandShow "Received"
executedDevice performed the actionShow "Running"
completedRead-back confirmed successShow "Done" + green
failedRead-back showed mismatch or timeoutShow "Failed" + red

Tracking a Command

# Check dispatch history for an asset
curl -H "Authorization: $EAT_KEY" \
  https://app.energyatit.com/api/v1/dispatch/history/1
# Check dispatch history for an asset
curl.exe -H "Authorization: $env:EAT_KEY" "https://app.energyatit.com/api/v1/dispatch/history/1"

Read-Back Verification

After a command reaches executed, the platform waits 2 seconds, then reads the device register back. If the actual value is within 2% tolerance of the target, it transitions to completed. Otherwise, it retries once, then fails.

This is how EnergyAtIt proves commands actually ran — not just that they were sent.

Why This Matters

In energy trading and grid operations, "I sent the command" is worthless. What matters is "I can prove the device did what I asked." The 6-state lifecycle with read-back verification provides that proof.

Handling Failed Commands

result = client.dispatch.send(asset_id=1, command="charge", target_kw=50)

# Poll for completion
import time
for _ in range(30):
    history = client.dispatch.history(asset_id=1)
    latest = history[0]
    if latest['status'] in ('completed', 'failed'):
        print(f"Final status: {latest['status']}")
        break
    time.sleep(2)

Log in to track your progress and earn certifications.