Functions

From webCoRE Wiki - Web-enabled Community's own Rule Engine
Revision as of 03:34, 15 April 2017 by C1arkbar (talk | contribs)
Jump to: navigation, search
Share on FacebookShare on TwitterShare on Google+Share on LinkedInShare on DiggShare on deliciousShare on redditShare on StumbleUpon
Boolean
bool()
boolean()
contains('The quick brown fox jumped over the lazy dog', 'brown') - tests parameter 1 for parameter 2 as any word (case sensitive)
endsWith('The quick brown fox jumped over the lazy dog', 'brown') - tests parameter 1 for parameter 2 as the last word (case sensitive)
eq('123', '321') - checks if both parameters are equal. This will return false
ge(1000, 900) - Checks if parameter 1 is greater than or equal to parameter 2. This will return true.
gt(1000, 900) - Checks if parameter 1 is greater than parameter 2. This will return true.
isEmpty()
le(1000, 900) - Checks if parameter 1 is less than or equal to parameter 2. This will return false.
lt(1000, 900) - Checks if parameter 1 is less than parameter 2. This will return false.
not()
startsWith('The quick brown fox jumped over the lazy dog', 'brown') - tests parameter 1 for parameter 2 as the first word (case sensitive)
Date
date()
datetime
addDays()
addHours()
addMinutes()
addSeconds()
addWeeks()
Decimal
avg([Device 1:temperature], [Device2:temperature], [Device 3:temperature]) - Gives you the average temperature of the three devices
ceil()
ceiling()
celsius([Sensor:temperature]) - Gives the temperature reading in celsius
decimal()
dewPoint([Sensor:temperature], [Sensor:humidity]) - Gives you the dewpoint temperature for that sensor
fahrenheit([Sensor:temperature]) - Gives the temperature reading in fahrenheit
float()
floor()
max([Front Door :temperature], [Back Door :temperature], [test sensor :temperature]) - Returns the max value of selected devices
median([Front Door :temperature], [Back Door :temperature], [test sensor :temperature]) - Returns the median value of selected devices
min([Front Door :temperature], [Back Door :temperature], [test sensor :temperature]) - Returns the min value of selected devices
number()
power(10,3) - Evaluates parameter 1 to the parameter 2 power (e.g. 10*10*10 = 1000)
round(75.6548, 1) - Rounds a decimal based on value of parameter 2. This will return 75.7
sqr(100) - Gives the squared value of the parameter. This returns 10000
sqrt(100) - Gives the square root of the parameter. This returns 10.0
stdev()
sum(1,5,6) - Adds all the values
variance()
Dynamic
if()
least()
most()
previousValue()
Integers
age([Device:switch) - Gives you the time in MS the device has been on
count([Device 1:contact], [Device 2:contact], [Device 3:contact], [Device 4:contact]) - Returns the number of open doors
int()
integer()
newer()
older()
previousAge()
String
concat('abc', 'def') - Returns the two strings as 'abcdef'
format("%.2f", celsius([Sensor:temperature])) - Returns the Celsius temperature formatted with two decimals
left('abcdef', 2) - Returns the first two characters in the string value or variable (ex: 'ab')
lower("HELLO, WORLD") - Returns as "hello, world"
mid('abcdef', 2, 3) - Skips the first 2 characters and returns the next 3
replace()
right('abcdef', 2) - Returns the last two characters in the string value or variable (ex: 'ef')
sprintf()
string()
substring("abcdef", 2, 4) - Skips the first 2 characters and returns the next 4
text()
title("hello, world") - Returns as "Hello, World"
upper("hello, world") - Returns as "HELLO, WORLD"
Time

time()