[DEPRECATED THREAD] webCoRE design process

Yeah, you can, place it in between single or double quotes. You may need to add some blanks to the strings to make sure the result is readable.

Equivalent expressions:

"Time is now " + $now

"Time is now {$now}"

Or as a value:

Time is now {$now}

You can use functions in values too, not just expressions. A value is an expression with implicit " " around it. Everything inside { } is treated as an expression of its own.

There are many functions, here are a couple:

format( value, format )
Lookup sprintf for how the format works.

format(“%.2f”, 12) should output 12.00

% is an argument placeholder (next argument)
.2 means two decimal points
f means float

if(condition, value1, value2)

If condition is true, value1 is returned, otherwise value2 is returned.

Expression example:

“It is " + if( ge( integer([Weather:wind]), 10 ), “very windy”, “pretty calm” ) + " outside”

The output would be either:

It is very windy outside

or

It is pretty calm outside

Depending on the wind value.

Break down:
[Weather:wind] returns the wind value of the Weather device
integer(value) converts that into an integer - your DTH returns a string…
ge(value, 10) returns true if value >= 10 or false otherwise
if(value, “very windy”, “pretty calm”) returns “very windy” if value is true, or “very calm” otherwise

2 Likes