Skip to content

Litsan69/EcoSense-AI

Β 
Β 

Repository files navigation

EcoSense LG: AI-Powered Energy Management System

Python Streamlit Ollama License

EcoSense LG is an intelligent energy management platform that leverages AI agents and machine learning to monitor, analyze, and optimize building energy consumption. The system provides real-time anomaly detection, proactive recommendations, and automated alerts through Telegram integration.

🌟 Key Features

Core Capabilities

  • Real-time Energy Monitoring: Live simulation of building energy consumption with configurable focus on specific buildings
  • AI-Powered Anomaly Detection: Multi-agent system using Ollama LLM for intelligent energy pattern analysis
  • Proactive Recommendations: Automated generation of energy-saving suggestions based on detected anomalies
  • Interactive Dashboard: Streamlit-based web interface for comprehensive energy operations management

Advanced Features

  • Agent Theater: Watch AI agents collaborate in real-time analysis with generative conversations
  • Telegram Bot Integration: Receive instant alerts and control the system via Telegram
  • Google Sheets Sync: Cloud-based data persistence and reporting
  • Multi-Building Support: Analyze energy patterns across multiple buildings simultaneously
  • Simulation Engine: Realistic energy consumption simulation with fault injection capabilities

Technical Highlights

  • Local LLM Integration: Uses Ollama for privacy-preserving, offline AI capabilities
  • Modular Architecture: Clean separation of concerns with agents, services, and UI components
  • Extensible Pipeline: Pluggable nodes for detection, root cause analysis, action planning, and quality assurance
  • Database Agnostic: Supports SQLite, PostgreSQL, and Google Sheets backends

πŸ—οΈ Architecture

EcoSense LG/
β”œβ”€β”€ dashboard/          # Streamlit web interface
β”‚   β”œβ”€β”€ app.py         # Main application entry point
β”‚   β”œβ”€β”€ ui/            # UI components (charts, theater, etc.)
β”‚   └── pages/         # Admin and data management pages
β”œβ”€β”€ src/               # Core application logic
β”‚   β”œβ”€β”€ agents/        # AI agent implementations
β”‚   β”œβ”€β”€ core/          # Digital twin and analytics
β”‚   β”œβ”€β”€ llm/           # LLM client and fine-tuning
β”‚   β”œβ”€β”€ nodes/         # Workflow pipeline nodes
β”‚   β”œβ”€β”€ rag/           # Retrieval-augmented generation
β”‚   β”œβ”€β”€ services/      # Business logic services
β”‚   └── tools/         # Utility tools
β”œβ”€β”€ data/              # Sample data and configurations
β”œβ”€β”€ scripts/           # Utility scripts
└── tests/             # Test suites

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Ollama (for local LLM capabilities)
  • Git (for cloning the repository)

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/ecosense-lg.git
    cd ecosense-lg
  2. Set up Python environment:

    python -m venv .venv
    .\.venv\Scripts\activate  # On Windows
    # source .venv/bin/activate  # On macOS/Linux
  3. Install dependencies:

    pip install -r requirements.txt
  4. Install and configure Ollama:

    # Download Ollama from https://ollama.ai/
    ollama pull llama3.2:1b
  5. Configure environment variables: Create a .env file in the project root:

    # Telegram Bot (optional)
    TELEGRAM_TOKEN=your_telegram_bot_token
    MY_CHAT_ID=your_telegram_chat_id
    
    # Google Sheets (optional)
    GOOGLE_SHEET_ID=your_google_sheet_id
    GOOGLE_APPLICATION_CREDENTIALS=service_account.json

Running the Application

  1. Start the Streamlit dashboard:

    streamlit run dashboard/app.py
  2. Access the application: Open your browser to http://localhost:8501

  3. Login credentials:

    • Admin: admin / admin123
    • Operator 1: operator1 / op1
    • Operator 2: operator2 / op2

πŸ“– Usage Guide

Dashboard Overview

  1. Login: Use the credentials above to access the system
  2. Building Selection: Choose a specific building or "All Buildings" from the sidebar
  3. Live Demo: Start the simulation to see real-time energy monitoring
  4. Agent Theater: Observe AI agents analyzing energy patterns
  5. Telegram Integration: Receive alerts and control via Telegram bot

Key Workflows

Energy Anomaly Detection

  1. Start live simulation
  2. Agents automatically analyze energy streams
  3. View results in Agent Theater
  4. Receive Telegram alerts for anomalies

Building-Specific Analysis

  1. Select target building from sidebar
  2. Restart simulation for focused analysis
  3. Review building-specific insights

Report Generation

  1. Access admin panel (admin role required)
  2. Generate PDF reports with energy analytics

πŸ”§ Configuration

Environment Variables

Variable Description Required
TELEGRAM_TOKEN Telegram bot API token No
MY_CHAT_ID Telegram chat ID for alerts No
GOOGLE_SHEET_ID Google Sheets document ID No
GOOGLE_APPLICATION_CREDENTIALS Path to service account JSON No

Simulation Settings

Modify src/services/simulator.py to adjust:

  • Simulation speed (seconds per hour)
  • Fault injection frequency
  • Data filtering parameters

πŸ€– AI Agents

EcoSense LG employs a sophisticated multi-agent system:

  • Analyst Agent: Detects energy consumption anomalies
  • Planner Agent: Cross-references anomalies with schedules
  • Recommender Agent: Generates actionable energy-saving recommendations
  • Action Planner: Creates implementation plans
  • Critic Agent: Quality assurance and validation
  • Synthesizer Agent: Final decision synthesis

All agents leverage Ollama's local LLM for intelligent analysis.

πŸ§ͺ Testing

Run the test suite:

python -m pytest tests/

πŸ“Š Data Sources

The system includes sample datasets:

  • data/sample/building_energy_multi.csv: Multi-building energy consumption data
  • data/sample/users.csv: User account management
  • data/sample/building_metadata.csv: Building specifications

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new features
  • Update documentation as needed
  • Ensure compatibility with Python 3.8+

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™‹ Support

For questions, issues, or contributions:

πŸ”„ Changelog

[v1.0.0] - 2026-05-11

  • Initial release with core energy management features
  • Ollama LLM integration
  • Multi-agent analysis system
  • Streamlit dashboard
  • Telegram bot integration

Built with ❀️ for sustainable energy management

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%