Skip to content

Energy Advisor - Workflow Engine

The Voltimax.EnergyAdvisor service runs inside the cloud Platform API and evaluates a gateway's workflow whenever the platform receives a telemetry update. It returns the strategy the gateway should execute, which the platform then sends down as a control command. It wraps the RulesEngine NuGet package, which evaluates C# lambda expression strings against a typed input object.

The workflow and its rules are stored per-gateway in PostgreSQL and loaded on each evaluation cycle by RulesEvaluationService.


Evaluation context

Each rule expression is evaluated against a RuleEvaluationContext instance. The context is composed of three sub-objects:

System - site measurements

PropertyTypeDescription
System.BatterySoCdoubleBattery state of charge (0–100 %).
System.SolarPowerdoubleSolar generation in watts. Positive = producing.
System.GridPowerdoubleGrid power in watts. Positive = importing, negative = exporting.
System.BatteryPowerdoubleBattery power in watts. Positive = charging, negative = discharging.

Time - temporal state

PropertyTypeDescription
Time.CurrentTimeDateTimeOffsetCurrent timestamp with timezone.
Time.CurrentHourintHour of day (0–23).
Time.IsSunsetbooltrue at sunset (transition point).
Time.IsNightbooltrue between sunset and sunrise.
Time.IsPeakHourbooltrue when the current hour falls inside the gateway's configured peak-tariff window.

Pricing - electricity market data

PropertyTypeDescription
Pricing.CurrentPricedoubleCurrent spot electricity price (currency per kWh).
Pricing.AveragePricedoubleDaily average spot price for today.
Pricing.IsLowPriceHourbooltrue when CurrentPrice < AveragePrice.
Pricing.IsHighPriceHourbooltrue when CurrentPrice > AveragePrice.
Pricing.NextHourPricesList<EpexPrice>Upcoming hourly prices for look-ahead rules.

Expression syntax

Rule expressions are C# lambda expression strings without the leading lambda parameter - RulesEngine binds the RuleEvaluationContext as the implicit input. Use standard C# comparison and logical operators.

Supported operators

OperatorMeaning
<, <=, >, >=Numeric comparison
==, !=Equality
&&Logical AND
||Logical OR
!Logical NOT

Examples - from the built-in templates

Battery Protection

csharp
// Fire when battery SoC drops below 20 %
"System.BatterySoC < 20"

// Fire when the battery is fully charged
"System.BatterySoC >= 95"

Smart Charging

csharp
// Charge on low-tariff hours while there is room in the battery
"Pricing.IsLowPriceHour && System.BatterySoC < 80"

// Avoid grid import during peak hours when battery has sufficient charge
"Time.IsPeakHour && System.GridPower > 0 && System.BatterySoC > 20"

// Detect grid import at night
"Time.IsNight && System.GridPower > 0"

Solar Optimisation

csharp
// Detect surplus: solar is producing, grid is exporting, battery is full
"System.SolarPower > 0 && System.GridPower < 0 && System.BatterySoC >= 95"

// Battery is actively charging from solar
"System.SolarPower > 0 && System.BatteryPower > 0"

Peak Demand Management

csharp
// Discharge during peak-tariff hours if battery has charge
"Time.IsPeakHour && System.BatterySoC > 30"

// Discharge on high spot price if battery can cover demand
"Pricing.IsHighPriceHour && System.BatterySoC > 40"

Combining conditions

Use && freely - expressions are evaluated as a single boolean. There is no nesting syntax; if you need complex branching, use multiple rules in sequence and let the first-match logic handle priority.


Evaluation order and result

Rules are evaluated top-to-bottom. The engine stops at the first rule whose expression evaluates to true and returns that rule's Strategy value as the EvaluationResult.

If no rule matches, no strategy change is issued and the gateway continues on its current setting.

The Strategy enum (defined in Voltimax.Iot.Contracts) maps to gateway operating modes:

ValueOperating mode
Strategy.NoneNo automatic control
Strategy.NetZeroNet-zero grid import/export
Strategy.ChargeActively charge the battery
Strategy.DischargeActively discharge the battery
Strategy.PeakShavingLimit peak grid demand

Built-in templates

The four shipped workflow templates are defined in WorkflowTemplates.cs and are available via GET /workflow/templates. They serve as working starting points that can be applied as-is or customised per gateway.

Operator documentation

See Energy Management for the non-technical overview of workflows and strategies intended for operators.