This directory contains scripts for setting up and running the PV Battery Simulator locally without Docker.
# Clone or navigate to the project
cd /home/matze/projects/pv-bat-simulator
# Run setup (creates venv and installs dependencies)
./run_local.sh
# Or use the dev helper
./dev.sh setup# Start the server
./run_local.sh start
# Or use the dev helper
./dev.sh startThe application will be available at: http://localhost:5000
The primary script for setting up and running the application.
Usage:
./run_local.sh # Setup only
./run_local.sh start # Setup and start serverWhat it does:
- Checks for Python 3 installation
- Creates a virtual environment in
./venv/ - Upgrades pip and installs wheel package
- Installs batcontrol:
- First tries local source from
../batcontrol/bc-git-upstream-main(editable mode) - If not found, downloads wheel file from GitHub (version 0.5.5)
- First tries local source from
- Installs all dependencies from
requirements.txt(prefers binary wheels for faster installation) - Optionally starts the Flask development server
Features:
- ✅ Colored output for better readability
- ✅ Error handling (exits on any error)
- ✅ Checks for existing virtual environment
- ✅ Automatically handles batcontrol dependency (local or GitHub)
- ✅ Downloads batcontrol wheel from GitHub if local source not available
- ✅ Supports both
pyproject.tomlandsetup.pyfor local batcontrol - ✅ Falls back to PYTHONPATH if batcontrol has no setup file
- ✅ Works with both wget and curl for downloads
- ✅ Prefers binary wheels for faster installation (avoids compilation)
Convenient wrapper for common development tasks.
Commands:
./dev.sh setup # Set up virtual environment
./dev.sh start # Start the application
./dev.sh test # Run tests
./dev.sh clean # Remove venv and cache files
./dev.sh install # Reinstall dependencies
./dev.sh shell # Show how to activate venv
./dev.sh info # Display environment information
./dev.sh help # Show help messageExamples:
# Clean start
./dev.sh clean
./dev.sh setup
./dev.sh start
# Check environment
./dev.sh info
# Update dependencies
./dev.sh installAfter running the setup, your directory will look like:
pv-bat-simulator/
├── venv/ # Virtual environment (created by script)
│ ├── bin/
│ ├── lib/
│ └── ...
├── app.py # Main Flask application
├── requirements.txt # Python dependencies
├── templates/ # HTML templates
├── run_local.sh # Setup & run script
├── dev.sh # Development helper
└── SCRIPTS_README.md # This file
- Python 3.8+ (Python 3.9+ recommended)
- pip (Python package installer)
- bash (for running the scripts)
The scripts will automatically install:
- flask==3.0.0
- pulp==2.7.0
- numpy==1.26.2
- pytz==2023.3
- cachetools==5.3.2
- requests==2.31.0
Note: All dependencies are installed using --prefer-binary flag, which downloads precompiled binary wheels whenever available. This significantly speeds up installation (especially for numpy) and avoids the need for compilation tools.
If you prefer to manage the virtual environment manually:
# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install batcontrol (if needed)
pip install -e ../bc-git-upstream-main
# Run application
python app.py
# Deactivate when done
deactivateThe script automatically tries two methods:
- Local source (if available at
../batcontrol/bc-git-upstream-main) - GitHub release (downloads version 0.5.5 wheel file)
If both fail, you have these options:
Option 1: Create a symlink to your local batcontrol
ln -s /path/to/batcontrol ../batcontrol/bc-git-upstream-main
./run_local.shOption 2: Edit run_local.sh and change BATCONTROL_DIR
BATCONTROL_DIR="/your/path/to/batcontrol"Option 3: Install batcontrol manually
source venv/bin/activate
# From local source
pip install -e /path/to/batcontrol
# Or from GitHub
wget https://github.com/muexxl/batcontrol/releases/download/0.5.5/batcontrol-0.5.5-py3-none-any.whl
pip install batcontrol-0.5.5-py3-none-any.whlOption 4: Install wget or curl if download fails
# Ubuntu/Debian
sudo apt-get install wget
# or
sudo apt-get install curlInstall Python 3:
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install python3 python3-venv python3-pip
# macOS
brew install python3
# Fedora
sudo dnf install python3 python3-pipMake scripts executable:
chmod +x run_local.sh dev.shThe application runs on port 5000 by default. To change it, edit app.py:
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=False, port=8080) # Changed from 5000Try reinstalling dependencies:
./dev.sh clean
./dev.sh setup-
Initial setup (first time only)
./run_local.sh
-
Start development
./dev.sh start
-
Make changes to code
- Flask will auto-reload on file changes (in debug mode)
- Just refresh your browser
-
Check environment if issues arise
./dev.sh info
-
Clean rebuild if needed
./dev.sh clean ./dev.sh setup
If you're developing batcontrol alongside the simulator:
# After making changes to batcontrol
source venv/bin/activate
cd ../bc-git-upstream-main
pip install -e .
cd -
# Or just restart the server (if installed in editable mode)
./dev.sh startYou can set these before running the scripts:
# Custom Python interpreter
PYTHON=/usr/bin/python3.9 ./run_local.sh
# Skip batcontrol installation
SKIP_BATCONTROL=1 ./run_local.sh
# Enable Flask debug mode (edit app.py)
# Change: app.run(host='0.0.0.0', debug=True, port=5000)After running the setup:
-
Check environment info
./dev.sh info
-
Start the server
./dev.sh start
-
Open in browser
- Navigate to http://localhost:5000
- Try loading aWATTar data
- Run a simulation
-
Check for errors
- Watch terminal output for Python errors
- Check browser console (F12) for JavaScript errors
To completely remove the virtual environment:
./dev.sh cleanThis removes:
venv/directory- All
__pycache__/directories - All
.pycfiles
- Application Documentation: See
IMPLEMENTATION_SUMMARY.md - Quick Start Guide: See
QUICKSTART.md - Design Document: See
fetch-awattar-data.md - Main README: See
README.md
For issues or questions:
- Check this README
- Check
IMPLEMENTATION_SUMMARY.mdfor API details - Inspect terminal output for error messages
- Use
./dev.sh infoto check environment status