Difference between revisions of "Functions"
From webCoRE Wiki - Web-enabled Community's own Rule Engine
Line 1: | Line 1: | ||
− | = [[Boolean| | + | = [[Variable_data_types#Boolean|Boolean]] = |
;bool() | ;bool() | ||
://todo | ://todo | ||
Line 27: | Line 27: | ||
:returns true if a string starts with a substring | :returns true if a string starts with a substring | ||
− | = Date = | + | = [[Variable_data_types#Date|Date]] = |
;date(value) | ;date(value) | ||
:returns the value as a date type | :returns the value as a date type | ||
− | = | + | = [[Variable_data_types#Date_and_Time|Datetime]] = |
;addDays(dateTime, days) | ;addDays(dateTime, days) | ||
:returns the value as a time type | :returns the value as a time type | ||
Line 43: | Line 43: | ||
:returns the value as a time type | :returns the value as a time type | ||
− | = Decimal = | + | = [[Variable_data_types#Number_.28Decimal.29|Decimal]] = |
;avg(values) | ;avg(values) | ||
:calculates the average of a series of numeric values | :calculates the average of a series of numeric values | ||
Line 85: | Line 85: | ||
:calculates the standard deviation of a series of numeric values | :calculates the standard deviation of a series of numeric values | ||
− | = Dynamic = | + | = [[Variable_data_types#Dynamic|Dynamic]] = |
;if(condition, valueIfTrue, valueIfFalse) | ;if(condition, valueIfTrue, valueIfFalse) | ||
:evaluates a boolean and returns value1 if true, or value2 otherwise | :evaluates a boolean and returns value1 if true, or value2 otherwise | ||
Line 95: | Line 95: | ||
:returns the previous value of the attribute | :returns the previous value of the attribute | ||
− | = Integers = | + | = [[Variable_data_types#Number_.28Integer.29|Integers]] = |
;age([device;attribute]) | ;age([device;attribute]) | ||
:returns the number of milliseconds an attribute had the current value | :returns the number of milliseconds an attribute had the current value | ||
Line 111: | Line 111: | ||
:returns the number of milliseconds an attribute had the previous value | :returns the number of milliseconds an attribute had the previous value | ||
− | = String = | + | = [[Variable_data_types#String|String]] = |
;concat(string1, string2) | ;concat(string1, string2) | ||
:returns two strings appended together | :returns two strings appended together | ||
Line 139: | Line 139: | ||
:returns an upper case value of a string | :returns an upper case value of a string | ||
− | = Time = | + | = [[Variable_data_types#Time|Time]] = |
;time(value) | ;time(value) | ||
:returns the value as a time type | :returns the value as a time type |
Revision as of 03:34, 18 April 2017
Boolean
- bool()
- //todo
- boolean(anything)
- converts a value to it's boolean value
- contains(string, substring)
- returns true if a string contains a substring
- endsWith(string, substring)
- returns true if a string ends with a substring
- eq(value1, value2)
- returns true if two values are equal
- ge(value1, value2)
- returns true if value1 >= value2
- gt(value1, value2)
- returns true if value1 > value2
- isBetween(value, startValue, endValue)
- returns true if value >= startValue and value <= endValue
- isEmpty(value)
- returns true if the value is empty
- le(value1, value2)
- returns true if value1 <= value2
- lt(value1, value2)
- returns true if value1 < value2
- not(value)
- returns the negative boolean value
- startsWith(string, substring)
- returns true if a string starts with a substring
Date
- date(value)
- returns the value as a date type
Datetime
- addDays(dateTime, days)
- returns the value as a time type
- addHours(dateTime, hours)
- returns the value as a time type
- addMinutes(dateTime, minutes)
- returns the value as a time type
- addSeconds(dateTime, seconds)
- returns the value as a time type
- addWeeks(dateTime, weeks)
- returns the value as a time type
Decimal
- avg(values)
- calculates the average of a series of numeric values
- ceil()
- //todo
- ceiling(decimal or string)
- converts a decimal value to it's closest higher integer value
- celsius(temperature)
- converts temperature from Fahrenheit to Celsius
- decimal(integer or string)
- converts an integer value to it's decimal value
- dewPoint(temperature, relativeHumidity[, scale])
- returns the calculated dew point temperature
- fahrenheit([Sensor;temperature])
- converts temperature from Celsius to Fahrenheit
- float()
- //todo
- floor(decimal or string)
- converts a decimal value to it's closest lower integer value
- max(values)
- calculates the maximum of a series of numeric values
- median(values)
- returns the value in the middle of a sorted array
- min(values)
- calculates the minimum of a series of numeric values
- number()
- //todo
- power(integer or decimal or string, power)
- converts a decimal value to it's power decimal value
- round(decimal or string, [precision])
- converts a decimal value to it's rounded value
- sqr(integer or decimal or string)
- converts a decimal value to it's square decimal value
- sqrt(integer or decimal or string)
- converts a decimal value to it's square root decimal value
- stdev(values)
- calculates the standard deviation of a series of numeric values
- sum(values)
- calculates the sum of a series of numeric values
- variance(values)
- calculates the standard deviation of a series of numeric values
Dynamic
- if(condition, valueIfTrue, valueIfFalse)
- evaluates a boolean and returns value1 if true, or value2 otherwise
- least(values)
- returns the value that is least found a series of numeric values
- most(values)
- returns the value that is most found a series of numeric values
- previousValue([device;attribute])
- returns the previous value of the attribute
Integers
- age([device;attribute])
- returns the number of milliseconds an attribute had the current value
- count(values)
- calculates the number of true/non-zero/non-empty items in a series of numeric values
- int()
- //todo
- integer(decimal or string)
- converts a decimal value to it's integer value
- newer([device;attribute],[...], [device;attribute], threshold)
- returns the number of devices whose attribute had the current value for less than the specified number of milliseconds
- older([device;attribute],[...], [device;attribute], threshold)
- returns the number of devices whose attribute had the current value for more than the specified number of milliseconds
- previousAge([device;attribute])
- returns the number of milliseconds an attribute had the previous value
String
- concat(string1, string2)
- returns two strings appended together
- format()
- //todo
- left(string, count)
- returns a substring of a value
- lower(string)
- returns a lower case value of a string
- mid(string, start, count)
- returns a substring of a value
- replace(string, search, replace[, [..], search, replace])
- replaces a search text inside of a value
- right(string, count)
- returns a substring of a value
- sprintf(format, arguments)
- formats a series of values into a string
- string(anything)
- converts a value to it's string value
- substring(string, start, count)
- returns a substring of a value
- text()
- //todo
- title(string)
- returns a title case value of a string
- upper(string)
- returns an upper case value of a string
Time
- time(value)
- returns the value as a time type
- addSeconds(dateTime, seconds)
- adds seconds to time, returns the value as a time type
- addMinutes(dateTime, minutes)
- adds minutes to time, returns the value as a time type
- addHours(dateTime, hours)
- adds hours to time, returns the value as a time type
- addDays(dateTime, days)
- adds days to time, returns the value as a time type
- addWeeks(dateTime, weeks)
- adds weeks to time, returns the value as a time type