Overview
The optimization engine uses theLoadConfig dataclass to define the configuration for each controllable load. Energy Control Pro supports up to 3 load slots, each with independent configuration.
LoadConfig Dataclass
Defined inoptimization/engine.py, the LoadConfig dataclass represents the static configuration for a single controllable load:
Fields
The Home Assistant entity ID of the switch or input_boolean to control.Must be a valid Home Assistant entity from the
switch or input_boolean domain.Example: "switch.water_heater" or "input_boolean.pool_pump"Minimum solar surplus power in watts required to turn on this load.The optimization engine will only turn on this load when the grid export (surplus solar) exceeds this threshold for the configured duration.Default:
Range: 0-20000WExample: For a 1500W water heater, set to
DEFAULT_LOAD_MIN_SURPLUS_W = 1200Range: 0-20000WExample: For a 1500W water heater, set to
1500 or slightly higher to ensure sufficient surplus.Minimum time in minutes the load must remain on once turned on.This prevents the optimization engine from rapidly cycling loads on and off. Once a load is turned on, it will not be turned off until this duration has elapsed, even if solar surplus drops.Default:
Range: 0-180 minutesExample: Set to
DEFAULT_LOAD_MIN_ON_TIME_MIN = 10Range: 0-180 minutesExample: Set to
30 for a water heater that needs at least 30 minutes to heat effectively.Minimum time in minutes between turning off and allowing the load to turn on again.After the load is turned off, this cooldown period must elapse before the optimization engine will consider turning it on again, even if there is sufficient surplus.Default:
Range: 0-180 minutesExample: Set to
DEFAULT_LOAD_COOLDOWN_MIN = 10Range: 0-180 minutesExample: Set to
60 for equipment that shouldn’t cycle frequently, like HVAC compressors.Load priority level (1-3). Lower numbers indicate higher priority.The optimization engine uses priority to decide which loads to turn on/off:
Range: 1-3Example: Assign priority 1 to critical loads (water heater), priority 2 to medium loads (pool pump), priority 3 to optional loads (car charger).
- Turn on: Highest priority (lowest number) eligible load is turned on first
- Turn off: Lowest priority (highest number) load is turned off first during grid import
Range: 1-3Example: Assign priority 1 to critical loads (water heater), priority 2 to medium loads (pool pump), priority 3 to optional loads (car charger).
Load Slot Configuration
Energy Control Pro provides 3 load slots, each configured through the config flow UI or configuration options.Load Slot 1
Entity ID for the first controllable load.Constant:
CONF_LOAD_1_ENTITYMinimum surplus watts for Load 1.Constant:
CONF_LOAD_1_MIN_SURPLUS_WMinimum on time in minutes for Load 1.Constant:
CONF_LOAD_1_MIN_ON_TIME_MINCooldown period in minutes for Load 1.Constant:
CONF_LOAD_1_COOLDOWN_MINPriority level for Load 1.Constant:
Default: 1 (highest priority)
CONF_LOAD_1_PRIORITYDefault: 1 (highest priority)
Load Slot 2
Entity ID for the second controllable load.Constant:
CONF_LOAD_2_ENTITYMinimum surplus watts for Load 2.Constant:
CONF_LOAD_2_MIN_SURPLUS_WMinimum on time in minutes for Load 2.Constant:
CONF_LOAD_2_MIN_ON_TIME_MINCooldown period in minutes for Load 2.Constant:
CONF_LOAD_2_COOLDOWN_MINPriority level for Load 2.Constant:
Default: 2 (medium priority)
CONF_LOAD_2_PRIORITYDefault: 2 (medium priority)
Load Slot 3
Entity ID for the third controllable load.Constant:
CONF_LOAD_3_ENTITYMinimum surplus watts for Load 3.Constant:
CONF_LOAD_3_MIN_SURPLUS_WMinimum on time in minutes for Load 3.Constant:
CONF_LOAD_3_MIN_ON_TIME_MINCooldown period in minutes for Load 3.Constant:
CONF_LOAD_3_COOLDOWN_MINPriority level for Load 3.Constant:
Default: 3 (lowest priority)
CONF_LOAD_3_PRIORITYDefault: 3 (lowest priority)
Configuration Examples
Example 1: Water Heater (High Priority)
Example 2: Pool Pump (Medium Priority)
Example 3: EV Charger (Low Priority)
Usage in Optimization Engine
The optimization engine uses these configurations in two decision functions:Turn On Decision
Fromoptimization/engine.py:50-77, the decide_turn_on function:
- Checks if export duration meets the threshold
- Sorts loads by priority (lowest number first)
- Finds the first eligible OFF load where:
- Surplus exceeds
min_surplus_w - Cooldown period has elapsed
- Surplus exceeds
- Returns action to turn on that load
Turn Off Decision
Fromoptimization/engine.py:80-108, the decide_turn_off function:
- Checks if grid import exceeds threshold for required duration
- Sorts loads by priority in reverse (highest number first)
- Finds the first eligible ON load where:
- Minimum on time has elapsed
- Returns action to turn off that load
Related Dataclasses
LoadRuntime
Tracks the runtime state of each load:EngineAction
Represents an action decision returned by the engine:See Also
- Configuration Options - All integration configuration options
- Optimization Strategies - Strategy selection and behavior