Difference between revisions of "EasyFormula"

From Let's Control It
Jump to navigation Jump to search
Line 34: Line 34:
 
== Conversions ==
 
== Conversions ==
  
You can convert integers into human readable information using these commands.
+
You can convert integers into human readable information using these commands. These are not working in formulas since the output is a string and not a true float value. The intended use is in rules and display etc.  
  
 
{| class="wikitable sortable"
 
{| class="wikitable sortable"
Line 46: Line 46:
 
| Deg >>> Bearing
 
| Deg >>> Bearing
 
| bearing/wind direction
 
| bearing/wind direction
| %c_w_dir%('''%value%''')
+
| %c_w_dir%('''[TaskName#ValueName]''')
 
| '''%c_w_dir%(45)=NE''' (-359 to +360 is allowed)
 
| '''%c_w_dir%(45)=NE''' (-359 to +360 is allowed)
 
|-
 
|-
Line 52: Line 52:
 
| C >>> F
 
| C >>> F
 
| Celsius to Fahrenheit
 
| Celsius to Fahrenheit
| %c_c2f%('''%value%''')
+
| %c_c2f%('''[TaskName#ValueName]''')
 
| '''%c_c2f%(32.0)=89.6'''
 
| '''%c_c2f%(32.0)=89.6'''
 
|-
 
|-
Line 58: Line 58:
 
| m/s >>> Beaufort
 
| m/s >>> Beaufort
 
| wind speed/gust to Beaufort scale
 
| wind speed/gust to Beaufort scale
| %c_ms2Bft%('''%value%''')
+
| %c_ms2Bft%('''[TaskName#ValueName]''')
 
| '''%c_ms2Bft%(23.3)=9'''
 
| '''%c_ms2Bft%(23.3)=9'''
 
|-
 
|-
Line 64: Line 64:
 
| cm >>> ' "
 
| cm >>> ' "
 
| centimeter to imperial (feet) +  inches
 
| centimeter to imperial (feet) +  inches
| %c_cm2imp%('''%value%''')
+
| %c_cm2imp%('''[TaskName#ValueName]''')
 
| '''%c_cm2imp%(200.2)=5' 6.7"'''<br>'''%c_cm2imp%(12)=4.7"'''
 
| '''%c_cm2imp%(200.2)=5' 6.7"'''<br>'''%c_cm2imp%(12)=4.7"'''
 
|-
 
|-
Line 70: Line 70:
 
| mm >>> ' "
 
| mm >>> ' "
 
| millimeter to imperial (feet) +  inches
 
| millimeter to imperial (feet) +  inches
| %c_mm2imp%('''%value%''')
+
| %c_mm2imp%('''[TaskName#ValueName]''')
 
| '''%c_mm2imp%(200.0)=7.87"'''<br>'''%c_mm2imp%(12200)=20' 0.3"'''
 
| '''%c_mm2imp%(200.0)=7.87"'''<br>'''%c_mm2imp%(12200)=20' 0.3"'''
 
|-
 
|-
Line 76: Line 76:
 
| min >>> day
 
| min >>> day
 
| minutes to days
 
| minutes to days
| %c_m2day%('''%value%''')
+
| %c_m2day%('''%uptime%''')
 
| '''%c_m2day%(7860)=4.46'''
 
| '''%c_m2day%(7860)=4.46'''
 
|-
 
|-
Line 82: Line 82:
 
| min >>> day hour
 
| min >>> day hour
 
| minutes to days + hours
 
| minutes to days + hours
| %c_m2dh%('''%value%''')
+
| %c_m2dh%('''%uptime%''')
 
| '''%c_m2dh%(7860)=4d 11h'''
 
| '''%c_m2dh%(7860)=4d 11h'''
 
|-
 
|-
Line 88: Line 88:
 
| min >>> day hour min
 
| min >>> day hour min
 
| minutes to days + hours + minutes
 
| minutes to days + hours + minutes
| %c_m2dh%('''%value%''')
+
| %c_m2dh%('''%uptime%''')
 
| '''%c_m2dhm%(3642)=2d 12h 42m'''
 
| '''%c_m2dhm%(3642)=2d 12h 42m'''
 
|-
 
|-
Line 94: Line 94:
 
| sec >>> day hour min sec
 
| sec >>> day hour min sec
 
| seconds to days + hours + minutes + seconds
 
| seconds to days + hours + minutes + seconds
| %c_s2dhms%('''%value%''')
+
| %c_s2dhms%('''[TaskName#ValueName]''')
 
| '''%c_s2dhms%(1234567890)=14d 6h 56m 8s'''
 
| '''%c_s2dhms%(1234567890)=14d 6h 56m 8s'''
 
|-
 
|-
  
 
|}
 
|}

Revision as of 00:35, 10 March 2018

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. These are not working in formulas since the output is a string and not a true float value. The intended use is in rules and display etc.

From >>> To Type Syntax Example
Deg >>> Bearing bearing/wind direction %c_w_dir%([TaskName#ValueName]) %c_w_dir%(45)=NE (-359 to +360 is allowed)
C >>> F Celsius to Fahrenheit %c_c2f%([TaskName#ValueName]) %c_c2f%(32.0)=89.6
m/s >>> Beaufort wind speed/gust to Beaufort scale %c_ms2Bft%([TaskName#ValueName]) %c_ms2Bft%(23.3)=9
cm >>> ' " centimeter to imperial (feet) + inches %c_cm2imp%([TaskName#ValueName]) %c_cm2imp%(200.2)=5' 6.7"
%c_cm2imp%(12)=4.7"
mm >>> ' " millimeter to imperial (feet) + inches %c_mm2imp%([TaskName#ValueName]) %c_mm2imp%(200.0)=7.87"
%c_mm2imp%(12200)=20' 0.3"
min >>> day minutes to days %c_m2day%(%uptime%) %c_m2day%(7860)=4.46
min >>> day hour minutes to days + hours %c_m2dh%(%uptime%) %c_m2dh%(7860)=4d 11h
min >>> day hour min minutes to days + hours + minutes %c_m2dh%(%uptime%) %c_m2dhm%(3642)=2d 12h 42m
sec >>> day hour min sec seconds to days + hours + minutes + seconds %c_s2dhms%([TaskName#ValueName]) %c_s2dhms%(1234567890)=14d 6h 56m 8s