cFos Charging Manager - Formulas

The cFos Charging Manager allows the dynamic evaluation of formulas. This functionality is available for a meter of the type "Expression" and for charging rules of the type "Formula".

You can therefore set up meters that calculate values from other meters or EVSEs and keep them ready and display them. The charging rules can also use formulas to dynamically calculate the charging current and also access meters and EVSEs (including meters of the "Expression" type).

The following operations are possible with the formulas:

+ - * /Addition, subtraction, multiplication, division
^Power calculation, e.g. 10^2 = 100
min(x,y)Minimum of x and y, more than 2 arguments possible
max(x,y)Maximum of x and y, more than 2 arguments possible
abs(x)Absolute value of x, e.g. abs(-2) = 2
sqrt(x)Square root of x

Furthermore, the following logical expressions are possible:

== (equal), != (unequal), < (less), <= (less-equal), > (greater), >= (greater-equal), ! (not), || (logical Or), && (logical And), ? (conditional operator, e.g. x ? y : z, returns y if x is true, otherwise z)

This allows, for example, the current to be switched off depending on conditions: M1.current >= 6500 ? M1.current : 0 returns the current of M1 if it is greater than 6.5A and 0 otherwise, which pauses the charging. For such conditions, it is also possible to query inputs (see below)

The following names are possible:

MxMeter with unit ID x, e.g. M1
ExEVSE with device ID x, e.g. E1

It is also possible to access virtual meters, such as solar surplus, grid draw or "Power avail. for EVSEs", by setting up the meter and then using the corresponding device ID in the formula.

You can then access individual values of the units by means of the point. These are called as follows:

current_l1Current of phase 1 in mA
current_l2Current of phase 2 in mA
current_l3Current of phase 3 in mA
currentCurrent of the current phase in mA (for charging rules, the Charging Manager queries all phases one after the other; for meters of the type "Expression", the respective phase to which the formula refers applies. If you have specified a formula for "Current L1", you can omit the fields for Current L2 and L3. Then the formula for current L1 is used)
power_vaCurrent power in Watt/VA (depending on the meter type, apparent power or active power can be supplied here)
power_wCurrent active power in watts
opower_vaWallbox: Current power offered in VA related to all 3 phases.
import_whEnergy drawn in Wh
export_whInjected energy in Wh
dtThe time that has elapsed since the last past update (in seconds)
inputNInput number N of the unit, 1 = active, 0 = inactive
socSOC, charge level in percent (meter/storage)
txn_durationDuration of the current transaction in seconds (EVSE)
txn_energyCharged energy of the current transaction in Wh (EVSE)
min_currentMinimum charging current in mA (EVSE)
max_currentMaximum charging current in mA (EVSE)
stateStatus: 1 waiting, 2 plugged in, 3 charging, 4 charging with ventilation, 5 error, 6 offline (EVSE)

Example
M1.current_l1Current of meter M1, phase 1
E2.import_whConsumed Wh of the EVSE E2
E3.power_vaCurrent charging power from E3

If you use the formulas for a meter of type "Expression", you can also omit the device ID. Then the field names refer to this meter, e.g. 'power_va' is then the power of this meter in Watt/VA. You can use 'dt' to realise a few extended functions, e.g. in a meter of the type "Expression":

  • As a formula for 'import_wh': import_wh + M1.power_va * dt / 3600 updates the sourced energy based on the power during the past update time
  • As a formula for 'power_va': (power_va * (20 - dt) + M1.power_va * dt) / 20 smoothes the power over the last 20 seconds.

Global variables

date

date.yearCurrent year
date.monthMonth from 0..11
date.dayDay from 1..31
date.weekdayWeekday Mo=0, Tue=1, ... Sun=6
date.yeardayDay in the year from 0..366
date.hourHour from 0..23
date.minuteMinute from 0..60
date.secondSecond from 0..60
date.daysecondSecond of this day from 0..86399
date.dayminuteMinute of this day from 0..1439
date.dst0 = winter time, 1 = summer time

PB (cFos Power brain only)

PB.input1S0 Input 1, 1 = active, 0 = inactive
PB.input2S0 Input 2, 1 = active, 0 = inactive

CM Charging Manager variables

These variables can be set by the admin under "Configuration". For example, if the admin sets the variable 'var_x' to 1.5, CM.var_x returns the value 1.5.

Predefined variables:
_num_charging: Number of wallboxes currently charging
_num_charging1: Number of currently charging wallboxes, 1 if none is charging
_max_total_power: Maximum power of the house connection in W
_max_total_evse_power: Maximum power for the EVSEs in W

Benutzung der globalen Objekte:
charge 8A starting at 8:00am: date.dayminute >= 480 ? 8000 : 0
charge 16A on Saturday and Sunday: date.weekday == 5 || date.weekday == 6 ? 16000 : 0
charge 6A if input 2 active: PB.input2 ? 6000 : 0 charge 6A if CM variable non-zero: cm.var1 ? 6000 : 0

Application example

You want to additionally limit the charging current with regard to a consumption meter of a flat. To do this, you can set up a charging rule with the formula 16000 - M1.current.
M1 is the meter that measures the consumption of the flat. The load management of the cFos Charging Manager first tries to provide the EVSE with the maximum current in relation to the house connection power, but then limits this to 16A minus the consumption of the flat.