Energy management modules are located in
modules/EnergyManagement/ and include EnergyManager and EnergyNode.Energy Management Architecture
The energy management system uses a tree structure:EnergyManager
Root coordinator for global energy distribution
EnergyNode
Intermediate node for hierarchical power distribution
EvseManager
Leaf node representing individual charging connector
External Limits
Grid, solar, battery, and building constraints
EnergyManager Module
The EnergyManager is the root of the energy tree and coordinates global energy distribution across all charging stations.Key Features
- Load Balancing: Distribute available power optimally across connectors
- Dynamic Limits: Respond to changing grid conditions and energy availability
- Schedule Forecasting: Plan energy distribution with time-based schedules
- 3-Phase/1-Phase Switching: Optimize power delivery per vehicle capability
- Trading Algorithm: Fair energy distribution based on demand and priority
EnergyManager Configuration
Nominal AC voltage for converting Ampere to Watt
Used for power calculations: P = V × I × √3 (three-phase) or P = V × I (single-phase)
Update interval for energy distribution in seconds
Lower values provide faster response to changes but increase CPU usage.
Duration of each schedule interval for forecasting in minutes
Total duration of schedule forecast in hours
Ampere slice for energy trading algorithm
Lower values provide more even distribution but increase processing time.
Watt slice for energy trading algorithm (DC charging)
Show debug output on command line for energy calculations
Phase Switching Configuration
Algorithm for switching between 3-phase and 1-phase during charging:
- Never: Disable switching even if BSP supports it
- Oneway: Only switch from 3ph→1ph, never back
- Both: Switch in both directions based on available power
Limit maximum number of switches per charging session. Set to 0 for no limit.
Prevents excessive switching that could stress vehicle charging electronics.
Behavior when switch limit is reached:
- SinglePhase: Lock to 1-phase mode
- ThreePhase: Lock to 3-phase mode
- DontChange: Stay in current mode
Power hysteresis in Watts to prevent oscillation
For 230V: With 200W hysteresis, switching occurs at 4.2kW→4.4kW range.
Time hysteresis in seconds before switching to 3-phase
Switching to 1-phase is immediate. Switching to 3-phase waits for stable conditions.
EnergyManager Interfaces
main (energy_manager)
main (energy_manager)
Main energy manager interface providing:
- Global energy limit configuration
- Schedule management
- Energy distribution control
- Optimizer status reporting
energy_trunk (energy)
energy_trunk (energy)
Required: Root of the energy treeConnects to EnergyNode or EvseManager instances that form the energy distribution tree.
EnergyNode Module
The EnergyNode is an intermediate node in the energy tree, allowing hierarchical power distribution.Use Cases
- Building Sections: Distribute power between different areas
- Parking Levels: Allocate energy per floor or zone
- Circuit Breakers: Respect electrical installation limits
- Transformer Capacity: Manage transformer loading
EnergyNode Configuration
EnergyNode configuration is similar to EnergyManager but acts as a pass-through node:Energy Distribution Algorithm
The energy manager uses a trading-based algorithm:Collect Requests
Each EvseManager requests power based on:
- Vehicle requirements
- Charging mode (AC/DC)
- Current charging state
- User priority (if configured)
Apply Constraints
EnergyManager considers:
- Total available grid power
- External limits (solar, battery)
- Per-node fuse limits
- Minimum charging currents
Trading Rounds
Distribute power in slices (e.g., 0.5A increments):
- Round-robin allocation
- Respect minimum/maximum limits
- Optimize for fairness
Configuration Examples
Simple Single-Charger Setup
Multi-Charger Load Balancing
Hierarchical Distribution
Phase Switching Enabled
External Energy Limits
Integrate with external systems using theexternal_energy_limits interface:
Grid Limit Example
Solar Integration
Integration with OCPP
OCPP smart charging schedules integrate with energy management:- OCPP limits from CSMS
- Energy Manager allocation
- Hardware capabilities
- Vehicle requirements
Monitoring and Debugging
Enable Debug Output
- Power requests from each node
- Trading algorithm iterations
- Final allocation decisions
- Constraint violations
MQTT Monitoring
EnergyManager publishes telemetry via MQTT:Performance Tuning
update_interval
Trade-off: Response time vs CPU usage
1s: Fast response, higher CPU5s: Slower response, lower CPU- Recommended:
1sfor fewer than 10 chargers,2-5sfor larger installations
slice_ampere
Trade-off: Fairness vs processing time
0.1A: Very even distribution, slow processing1.0A: Faster processing, less granular- Recommended:
0.5Afor most use cases
Best Practices
Tree Structure: Design your energy tree to match your electrical installation hierarchy (mains → sub-panels → circuits).
Fuse Limits: Set appropriate limits on EnergyNode instances to prevent breaker trips.
OCPP Integration: Energy Manager and OCPP smart charging work together. Energy Manager handles local optimization while OCPP provides backend constraints.
Advanced Features
Priority-Based Charging
Configure priority in EvseManager:Reserve Capacity
Reserve power for non-EV loads:Troubleshooting
Charging Not Starting
Charging Not Starting
- Check EnergyManager is providing non-zero allocation
- Verify energy tree connections are correct
- Enable debug output to see power distribution
- Check for conflicting external limits
Uneven Power Distribution
Uneven Power Distribution
- Decrease
slice_amperefor more granular allocation - Check vehicle minimum current requirements
- Verify all EVSEs are requesting power correctly
Phase Switching Not Working
Phase Switching Not Working
- Verify BSP reports
supports_changing_phases_during_charging: true - Check EvseManager is in AC mode
- Ensure
switch_3ph1ph_while_charging_modeis notNever - Verify hysteresis conditions are met
Related Modules
EvseManager
Charging coordination and energy interface
OCPP
Smart charging schedules from CSMS
Hardware Drivers
Power meters for monitoring
Source Code Reference
modules/EnergyManagement/EnergyManager/manifest.yaml- EnergyManager configmodules/EnergyManagement/EnergyNode/- Hierarchical node implementationinterfaces/energy.yaml- Energy interface definitioninterfaces/energy_manager.yaml- Manager interface