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| State | Meaning | What Your App Should Do |
|---|---|---|
| pending | Command created, not yet sent | Show "Queued" |
| dispatched | Sent to device, waiting for ack | Show "Sending..." |
| acknowledged | Device received the command | Show "Received" |
| executed | Device performed the action | Show "Running" |
| completed | Read-back confirmed success | Show "Done" + green |
| failed | Read-back showed mismatch or timeout | Show "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.