EcoLoop is a hackathon-ready proof of concept for autonomous supervisory HVAC control. EnergyPlus simulates a five-zone office, OpenRouter chooses a bounded operating mode, and Python maps that mode to validated thermostat setpoints. The same building and weather are run twice so energy and comfort can be compared fairly.
The LLM is remote through OpenRouter. No Ollama installation or local model download is required.
- Install Python 3.10 or newer.
- Install EnergyPlus 26.1 at
/Applications/EnergyPlus-26-1-0. - Open Terminal and run:
cd ~/Desktop/ecoloop
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
cp .env.example .env- Open
.envand add your OpenRouter API key:
OPENROUTER_API_KEY=your_key_here
OPENROUTER_MODEL=inclusionai/ling-3.0-flash:freeThe project can run without an API key, but it will use the safe fallback controller instead of OpenRouter.
Each time you open a new Terminal window, run:
cd ~/Desktop/ecoloop
source .venv/bin/activate
python main.pymain.py automatically:
- Prepares the EnergyPlus models.
- Runs the baseline simulation.
- Runs the controlled simulation.
- Generates the energy and comfort comparison.
- Starts the Streamlit dashboard.
Wait for both simulations to finish. When this message appears:
Dashboard: http://localhost:8501
open http://localhost:8501 in your browser. Keep the
Terminal window open while using the dashboard. Press Ctrl+C in the Terminal
to stop EcoLoop.
If valid simulation results already exist, use:
cd ~/Desktop/ecoloop
source .venv/bin/activate
python main.py --reuse-resultsThis rebuilds the comparison and starts the dashboard immediately.
# Run everything without starting the dashboard
python main.py --no-dashboard
# Run unit tests before the complete workflow
python main.py --run-tests
# Show every launcher option
python main.py --help- Live EnergyPlus Python API sensor and actuator loop
- Five safe HVAC modes with deterministic failover
- OpenRouter JSON decision client with timeout handling
- MCP server for state, safe actions, IDF inspection, logs, and summaries
- Baseline/controlled CSVs and a comparison generator
- Streamlit/Plotly results dashboard
- Unit tests and assessment architecture notes
- macOS with EnergyPlus 26.1 installed at
/Applications/EnergyPlus-26-1-0 - Python 3.10 or newer
- An OpenRouter API key (recommended, but optional)
The repository already contains:
models/baseline.idfmodels/controlled.idfweather/chicago.epw
Never commit .env. To use another OpenRouter model, change only
OPENROUTER_MODEL.
These commands are available for testing or troubleshooting:
python -m unittest discover -s tests
python src/test_api.py
python run_baseline.py
python run_controlled.py
python -m src.compare_resultsDuring the controlled run, look for lines like:
CONTROL 07/15 09:00 mode=occupied_eco heat=21.0C cool=25.0C source=openrouter_tool
If OpenRouter is unavailable, source=fallback appears and the run safely
continues. This behavior is deliberate and is logged in decisions.csv.
python -m streamlit run dashboard.pyThe dashboard presents baseline and controlled energy, savings, occupied comfort compliance, cumulative electricity, temperatures, setpoints, and the decision audit trail.
Run the server over standard input/output:
python -m src.mcp_serverTools:
get_building_stateapply_hvac_modeget_recent_simulation_errorsinspect_idfget_simulation_summary
apply_hvac_mode validates and records a request. The live callback remains
the sole owner of EnergyPlus actuators, avoiding unsafe cross-thread writes.
outputs/
├── baseline/simulation.csv
├── controlled/simulation.csv
├── controlled/decisions.csv
└── comparison.json
Energy is converted from EnergyPlus timestep joules to kWh. Comfort compliance is the percentage of occupied timesteps where the average zone temperature is between 20°C and 26°C.
- Show the architecture in
ARCHITECTURE.md. - Show
.envwith the key value hidden. - Run
python run_controlled.pyand point out sensor-driven decisions. - Open
outputs/controlled/decisions.csv. - Run the dashboard and present actual energy and comfort results.
- Demonstrate one MCP call using the MCP inspector of your choice.
Do not claim a saving until both simulations have completed and
outputs/comparison.json has been generated.