Virtual math sensor

The element allows to calculate the value from the data of arbitrary sensors.

Requests for management:

addvirtual - add a virtual sensor. Extra options are:

  • k - user session ID;
  • id - the identifier of the element; if the identifier is absent, a new element is created; otherwise the existing one is modified;
  • name - the name of the element, the length is not more than 63 characters;
  • virtual_type - type of virtual sensor, "math";
  • vmax - maximum value for the measuring range;
  • vmin - minimum value for the measuring range;
  • low_alarm - threshold level for notification;
  • low_warning - threshold level for notification;
  • high_warning - threshold level for notification;
  • high_alarm - threshold level for notification;
  • hyst_type - the type of algorithm used to calculate the hysteresis:
    • disable - the hysteresis is disabled;
    • value - hysteresis by the value measured by the sensor value;
    • time - hysteresis using time (used by default).
  • hyst_value - the value of the deviation of the sensor value when calculating the hysteresis by value, the value with a floating point (minimum 0, maximum 10,000, default 0.3);
  • hyst_low_alarm - the time in seconds, during which the sensor should keep its value in this range, for transition of the sensor to this state (minimum 0, maximum 1000, default 1);
  • hyst_low_warning - same as previous (default 1);
  • hyst_normal - same as previous (default is 0);
  • hyst_high_warning - same as previous (default 1);
  • hyst_high_alarm - same as previous (default 1).
  • expr - expression for calculating the output value, by default "A";
  • um - unit of measurement of this element;
  • utype - custom type, defines the sensor icon: current, factor, frequency, humidity, power, temperature, vibration, voltage;
  • var - list of elements id's corresponding to variable names A - Z;
  • period - the polling period, seconds.


If the new element is successfully created, the response is:

<error type="no error" id="215005" />

When creating a new sensor (id is not specified), some parameters are mandatory - virtual_type, name, var. The rest of the query parameters are optional, and if not set, they will be set to the default values.

Identifiers in the list (var), in number of 26, must be separated by commas. If the variable is not used, then the corresponding identifier must be -1. For example: 201001,203001,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,213001,-1,-1. Corresponding variables is A, B and X.

When editing an element, you can change individual fields. Editing an element is also possible with the updateelement command.


delvirtual - remove the virtual sensor. Extra options:

  • k - user session ID;
  • id - ID of the element.


getelement - read the element. Extra options are:

  • k - the user session ID;
  • id - the ID of the item.

Information about the element looks like:

<element id="215001" index="8" module="2009" clas="analog" type="math" name="Math 01" state="high alarm" um="parrots" hwport="1" utype="current" value="38" vmax="500.0" vmin="-10.0" low_alarm="13.0" low_warning="36.0" high_warning="174.0" high_alarm="197.0" expr="A+b+100+x" hyst_type="time" hyst_low_alarm="1" hyst_low_warning="1" hyst_normal="0" hyst_high_warning="1" hyst_high_alarm="1" hyst_value="0.300" period="20" var="201001,203001,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,213001,-1,-1," >
<time t="1506342326" last="1506342226" period="1">
<d v="12.116" t="1506342325"></d>
<d v="12.116" t="1506342324"></d>
<d v="12.116" t="1506342323"></d>
...
</time>
<time t="1506342326" last="1506336326" period="60">
<d v="12.116" t="1506342266"></d>
<d v="12.209" t="1506342206"></d>
<d v="12.209" t="1506342146"></d>
...
</time>
<time t="1506339739" last="1506336139" period="3600">
<d v="11.950" t="1506336139"></d>
</time>
<time t="1506336126" last="1506336126" period="86400"> </time>
</element>