Calculation
The Calculation task is used to perform mathematical operations inside bOS.
It can calculate values based on fixed numbers, live device values, variables, sensor data, or other values from the configuration. The calculated result can then be used in visualization, automation logic, scenes, schedules, alerts, or other tasks.
Calculation tasks are useful when a project requires additional value processing before the result is displayed or used for automation.
Common examples include:
Converting sensor values
Adjusting or correcting measured values
Creating calculated setpoints
Combining multiple values into one result
Calculating energy, consumption, or efficiency values
Creating custom values for visualization or logic
The Calculation task can perform polynomial calculations, allowing bOS to calculate an output value based on the selected input value and defined formula parameters.
This makes it possible to transform raw data into useful values that can be used for further building automation.
Table of contents
Calculation Settings
Polynome values can be object values or constants. The whole polynomial is multiplied with Constant Factor. Integration and differentiation Calculus can be applied to the polynome. Calculation is performed each time any of the input value is updated. Polynomial operations are set using the Operations list editor.
For each operation, the Operation Type can be selected (Addition, Subtraction, Multiplication, Division). Operation can contain only the Constant Factor or an Input Value (linked to an object value) scaled with the Constant Factor.
The result of the calculation is represented by Value.
Int Value is Value converted into integer. Calculate function can be called to manually trigger the calculation task. Reset function resets integration and differentiation calculus and sets Value to 0.
Math Operations
To calculate between different values, simply add a new mathematical operation under Operations window.
We can calculate between pre-defined values, set under Constant.
We can also calculate between two different variables or values from the configuration.
To do that, instead of using Constant value, we use Input value. Different functions for each value can also be selected (ABS, COS, SIN, EXP, LOG, etc).
Sub operations window is used for adding values in the brackets. All values in the Sub operation window will be placed in a bracket for the calculation. We can add as many sub operations as we need.
Calculation Examples
The examples below show different ways to use the Calculation task in bOS.
Each example demonstrates a specific use case, such as multiplying values, adjusting input data, or using live values from the configuration as part of the calculation.
Calculation tasks can use different input values, including device values, variables, sensor readings, or manually defined values. The calculated result can then be used in other parts of the project, such as automation logic, visualization, alerts, scenes, schedules, or additional tasks.
Use these examples as a reference when creating your own calculations. Depending on the project requirements, the same principle can be used to convert values, scale measurements, combine multiple inputs, or prepare data for further building automation.
Example 1: Calculate wind speed in km/h from input value measured in m/s.
1m/s = 3.6km/h.
Set Constant Factor to: 3.6.
Add Addition operation and select your input value (wind speed in m/s).
Example 2: Calculate energy (kWh) from current input value measured in amperes (A).
Energy is calculated as integration of power:
E(kWh) = Int(U*I)dt * 1/3600 / 1000
Set Calculus to: Integral.
Voltage (U) can be set as a constant (e.g. 230V). In this case Constant Factor is: 230 * 1/3600 / 1000 = 6,3e-5.
Add Addition operation and select current input value in amperes.
Use Value output in tasks or make a Double user interface control for it. A Run Function control linked to the Reset function can be used to enable resetting of the counter value.
Example 3: Count the number of ON switching
Create a counter variable (Devices->Variables->Integer).
Add Addition operation and select your counter variable.
Add Addition operation and set Constant Factor to 1.
Create a Program task. Set a trigger (i.e. device is turned ON). Add a Run command and link it to the Calculate function.
Use Reset function to enable resetting of the counter value.