EasyFormula

From Let's Control It
Jump to navigation Jump to search

ESP Easy can use a simple formula to change the sensor value before it is send to the Home Automation controller. (In most cases this is not needed and in most cases this can also be accomplished within the Home Automation software)

A few samples will be provided here. Remember that this is just a simple build-in 'calculator' with only the basic stuff like add, substract, multiply, devide.

When the sensorvalue has been read from the device, it is parsed through the formula function. The value is addressed as this:

%value%

So if you like to add a constant value of '2' to the sensorvalue, you would enter:

%value%+2

If you count in liters and need the value in cubic meters:

%value%/1000

Arithmetic operations

You can use the following operations in formulas:

If %value% is 10 and the formula is %value%<operation>2

  • Addition (+): 10+2=12
  • Subtraction (−): 10-2=8
  • Multiplication (*): 10*2=20
  • Division (/): 10/2=5
  • Exponent (^): 10^2=100

Square root etc.

Just for information, the square root can be exchanged for %value%^0.5 and cube root for %value%^0.3333.

Conversions

You can convert integers into human readable information using these commands.

  • %c_c2f%(value), bearing/wind direction:

%c_c2f%(32)=89.6

  • %c_ms2Bft%(value), Celsius to Fahrenheit:

%c_ms2Bft%()=8

  • %c_cm2imp%(value), centimeter to imperial (feet) + inches:

%c_cm2imp%()=20

  • %c_mm2imp%(value), millimeter to imperial (feet) + inches :

%c_mm2imp%()=5

  • %c_m2day%(value), minutes to days:

%c_m2day%(=100

  • %c_m2dh%(value), minutes to days + hours:

%c_m2dh%(=100

  • %c_m2dhm%(value), minutes to days + hours + minutes:

%c_m2dhm%(3642)=2d 12h 42m

  • %c_s2dhms%(value), seconds to days + hours + minutes + seconds:

%c_s2dhms%(1234567890)=14d 6h 56m 8s