Energieverwaltung
  • C# 95.5%
  • PLpgSQL 3.4%
  • Dockerfile 1.1%
Find a file
Dietmar Hameister 6cde82b1eb Merge remote-tracking branch 'origin/main'
Resolved conflicts:
- README.md: Kept comprehensive local documentation
2026-03-03 02:56:59 +01:00
docker Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
src Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
tests Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
.dockerignore Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
.env.example Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
.gitignore Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
docker-compose.override.yml Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
docker-compose.yml Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
Dockerfile Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
EnergyControl.slnx Initial commit: EnergyControl project structure 2026-03-03 02:46:33 +01:00
LICENSE Initial commit 2026-03-03 01:53:35 +00:00
README.md Initial commit 2026-03-03 01:53:35 +00:00

EnergyControl - Energy Management System

A comprehensive C# .NET 9 solution for monitoring and analyzing energy consumption from multiple sources including FRITZ!Smart devices and energy supplier APIs.

Features

  • Real-time Energy Monitoring: Collect live energy data from FRITZ!Box Smart Energy devices
  • Historical Data Integration: Sync historical consumption data from energy suppliers (EKD)
  • PostgreSQL + TimescaleDB: Optimized time-series data storage
  • Command Line Interface: Full-featured CLI for device management and data collection
  • Extensible Architecture: Plugin-based system for adding new data sources
  • Docker Support: Complete containerized deployment
  • Future-Ready: Prepared for AI predictions and additional UIs (Blazor, MAUI, React)

Architecture

src/
├── Core/
│   └── EnergyControl.Core/          # Domain models, interfaces
├── Infrastructure/
│   ├── EnergyControl.Data/          # Entity Framework, repositories
│   └── EnergyControl.Integrations/  # FRITZ!Box, EKD API clients
├── Services/
│   ├── EnergyControl.DataCollection/ # Background data collection
│   └── EnergyControl.Api/           # Web API (future)
└── UI/
    ├── EnergyControl.CLI/           # Command line interface
    ├── EnergyControl.Blazor/        # Web dashboard (future)
    └── EnergyControl.Maui/          # Mobile app (future)

Quick Start with Docker

  1. Clone and configure:

    git clone <repository-url>
    cd EnergyControl
    cp .env.example .env
    # Edit .env with your FRITZ!Box and EKD credentials
    
  2. Start the system:

    docker-compose up -d
    
  3. Initialize and discover devices:

    docker-compose exec energycontrol-cli dotnet EnergyControl.CLI.dll device discover
    
  4. Start data collection:

    docker-compose exec energycontrol-cli dotnet EnergyControl.CLI.dll collect start
    

CLI Commands

Device Management

# Discover FRITZ!Box energy devices
dotnet EnergyControl.CLI.dll device discover

# List all devices
dotnet EnergyControl.CLI.dll device list

# Show device status
dotnet EnergyControl.CLI.dll device status <device-name>

# Register device manually
dotnet EnergyControl.CLI.dll device register --name "Kitchen Outlet" --type "FRITZ!DECT 200" --mac "34:31:C4:XX:XX:XX"

Data Collection

# Start real-time collection for all devices
dotnet EnergyControl.CLI.dll collect start

# Collect single reading
dotnet EnergyControl.CLI.dll collect once <device-name>

# Test provider connections
dotnet EnergyControl.CLI.dll collect test-providers

Historical Data

# Sync historical data from EKD
dotnet EnergyControl.CLI.dll history sync --supplier EKD --from 2024-01-01

# Show energy history
dotnet EnergyControl.CLI.dll history show --device <device-name> --from 2024-01-01

# Export data to CSV
dotnet EnergyControl.CLI.dll history export --output energy_data.csv

System Status

# System health check
dotnet EnergyControl.CLI.dll status system

# Device statuses
dotnet EnergyControl.CLI.dll status devices

# Database status
dotnet EnergyControl.CLI.dll status database

Configuration

Configuration is managed through appsettings.json and environment variables:

{
  "EnergyControl": {
    "Database": {
      "ConnectionString": "Host=localhost;Database=EnergyControl;Username=postgres;Password=energia123;"
    },
    "FritzBox": {
      "BaseUrl": "https://fritz.box",
      "Username": "your_username",
      "Password": "your_password",
      "PollingInterval": "00:00:30"
    },
    "Ekd": {
      "ApiBaseUrl": "https://api.ekd.de",
      "ApiToken": "your_token",
      "CustomerNumber": "your_customer_number"
    }
  }
}

Development

Prerequisites

  • .NET 9 SDK
  • Docker and Docker Compose
  • PostgreSQL (for local development)

Local Development

# Restore packages
dotnet restore

# Build solution
dotnet build

# Run CLI locally
cd src/UI/EnergyControl.CLI
dotnet run -- device list

# Run tests
dotnet test

# Create database migration
cd src/Infrastructure/EnergyControl.Data
dotnet ef migrations add <MigrationName>

Development with Docker

# Start development environment
docker-compose -f docker-compose.yml -f docker-compose.override.yml up -d

# View logs
docker-compose logs -f energycontrol-cli

# Access development CLI
docker-compose exec energycontrol-cli bash

Data Sources

FRITZ!Box Smart Energy Devices

  • Supported: FRITZ!Smart Energy 250, FRITZ!DECT 200, FRITZ!DECT 210
  • Data: Real-time power, voltage, current, temperature
  • Authentication: FRITZ!Box challenge-response
  • Discovery: Automatic via Smart Home API

Energy Supplier APIs (EKD)

  • Data: Historical consumption, tariffs, billing
  • Authentication: OAuth 2.0 with API tokens
  • Sync: Configurable intervals (daily/weekly)
  • Format: JSON REST API

Database Schema

Key Tables

  • Devices: Energy monitoring devices
  • EnergyReadings: Time-series energy measurements (hypertable)
  • EnergySuppliers: Energy provider information
  • CustomerAccounts: Supplier account details
  • HistoricalConsumptions: Supplier consumption data (hypertable)
  • Tariffs: Energy pricing information

TimescaleDB Optimizations

  • Hypertables for time-series data
  • Automatic data compression (7+ days)
  • Continuous aggregates (hourly/daily)
  • Retention policies (2 years)

Monitoring & Admin

Included Tools

Access Credentials

  • pgAdmin: admin@energycontrol.local / admin123
  • Grafana: admin / admin123

Extensibility

The system is designed for easy extension:

Adding New Data Sources

  1. Implement IRealtimeEnergyProvider or IHistoricalEnergyProvider
  2. Add configuration to EnergyControlConfiguration
  3. Register in DI container
  4. Create integration tests

Adding New UIs

  1. Create new project in src/UI/
  2. Reference Core and Data projects
  3. Configure authentication and API endpoints
  4. Add to docker-compose for deployment

Future Roadmap

  • Blazor Web Dashboard: Real-time energy monitoring web interface
  • .NET MAUI Mobile App: Cross-platform mobile energy tracking
  • React Frontend: Advanced data visualization and analytics
  • AI/ML Predictions: Consumption forecasting and optimization
  • Weather Integration: Correlate energy usage with weather data
  • Solar Panel Integration: Track solar generation and grid feed-in
  • Smart Home Automation: Energy-based device control
  • Cost Optimization: Automated tariff analysis and recommendations

Contributing

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

License

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

Support

For issues and questions:

  • Create GitHub Issues for bugs and feature requests
  • Check existing documentation and CLI help
  • Review logs in /logs directory or docker-compose logs

EnergyControl - Comprehensive energy management for the modern smart home.