Homey Community Forum

Available math functions

Are there built-in math functions that can be used in variable calculations (in basic logic flows, not Homeyscript)? If so, where can I find the docs?

You can use the Logic-card “Calculate a numeric value” in THEN field an set variables to calculated values from other variables or/and tags.
I’m sorry to say I don’t know where you can find the docs.

“You can even perform math inside a Flow! Surround your formula with curly brackets, for example:
{{ 1 + 2 }}
Of course you can add tags in this calculation.”

Try this list:

Example: {{round(5.345,2)}}


Thanks @Ton_Meek - this is what I was looking for.

This was what I was looking for but I fail to use it.

I tried this in a Simple Logic card:
{{print('Foo $0', <Temperature>)}}
where is one of the Tags I get the following on the timeline:
{{print('Foo $0', 19.9)}}
where 19.9 is the value of

What am I doing wrong?

What do you expect of the “print” function?

I expected Foo 19.9. I assumed it was like sprintf in C.
When I tried {{ 10 + 20 }} it returned 30.

When I looked at the link https://mathjs.org/docs/reference/functions.html above I assumed all functioned were possible to use. Maybe it was wrong assumption.

I’m not sure, but I expect print means print to terminal, what not is possible at Homey

The math.print() “values” argument (the second one) is expected to be an object, an array or a matrix, not a scalar value.

Try this:

{{ print('Foo $0', [ <Temperature> ]) }}

When I enter your proposal I get the following:
{{ print('Foo $0', [ 19.9 ])}}
which is the same as I got earlier.
It seems like I fail with the print function. But I do realize how to solve my initial problem which was to create a string including a tag value in the middle. I wanted to create a json string, e.g. {{ value : <Temperature> }}.
I thought I needed the print function for it nut it now works with what you just gave me above. Thanks!

are spaces allowed?

floor(x) : partie entière mathématique usuelle = entier immédiatement inférieur à x

ceil(x) : partie entière par excès = entier immédiatement supérieur à x

round(x) : arrondi entier le plus proche

abs(x) : retourne la valeur positive

sqrt(x) : racine carrée

English please.