A smart energy management system built with uAgents that optimizes energy distribution based on grid prices, storage capacity, and consumption patterns to help users save money.
- Real-time decision making based on current and forecasted prices
- Smart storage management (store when cheap, use when expensive)
- Grid integration for buying and selling at optimal times
- Proactive buying energy from the grid at lower prices
- Python 3.13+
- uAgents framework
-
Clone the repository:
git clone https://github.com/smypmsa/c4e-hackathon-agent.git cd c4e-hackathon-agent -
Set up environment:
python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt -
Create
.envfile:SEED=your_secret_seed_here
Start the manager agent:
python -m src.agents.manager
The system analyzes:
- Energy production and consumption
- Storage levels
- Grid prices (current and future)
- P2P trading prices
It then decides whether to:
- Store excess energy
- Sell to grid
- Buy from grid
- Use stored energy
hackathon-1/
├── grid_prices.csv - Hourly grid prices
├── src/
│ ├── agents/manager.py - Main agent
│ ├── decisions/trading.py - Decision algorithms
│ └── models/decision_models.py - Data models
- Prioritizes storing energy when:
- Price spikes are approaching
- Battery isn't full
- P2P trading prices aren't competitive
- Sells excess energy to the grid if storage is full or not prioritized
- Uses stored energy when:
- Grid prices are currently high
- No price spikes are expected soon
- Battery is relatively full
- Buys energy from the grid when needed after using available storage
- Special feature that buys extra energy when prices are low
- Stores this energy in anticipation of upcoming price spikes
- Only activates when:
- Current prices are significantly below average
- Price spikes are expected in the next 2-12 hours
- There's enough storage space available
-
Energy Balance Calculation:
- System first calculates if there's surplus or deficit energy
-
For Energy Surplus:
- Decides how much to store based on storage capacity and upcoming price events
- Sells remaining energy to the grid if it can't be stored
-
For Energy Deficit:
- Decides whether to use stored energy based on current prices and future outlook
- Buys from grid to cover remaining needs
-
Proactive Strategy:
- Calculates if buying extra energy now (at low prices) to store for later high-price periods makes sense
- Factors in how soon price spikes will happen and how severe they'll be