Calculation of variables (Logic or better Logic)

Anyone an idea how to perform some advanced calculations fot variables?

I would like to round the number at max 2 decimals

i’ve done some trial-and-errorring with Logic and better logic

$round(<number, 2)
math.round(, 2)
{{$math.round(, 2)}}

thus far no succes

{{round (Tag inserted here,2)}}


Now the volume of the Top2000 on all the Sonos in the house increases or decreases nicely proportional

anywhere I can find a tutorial for these kind of syntaxes?
I’ve searched the community and Google but I get Lost

1 Like

Same here. I searched my ass off, but very little examples…
I’m looking for creating an array of names.
Like {{random(round(1,10))}} results in a number between 1 and 10.
How about a random pick between John, Ben, Julie, Jill?

that doesn’t work anymore since last update:

  • [Logic] Changes rounding Logic variables from 0 to 2 decimals

very nice the change, but unbelievable that they won’t tell how it works now…
So, do u have an idea? i want round values with 1 decimal.

Ah, So that’s why this morning Sonos went from soft to Deaffening-loud within one click :open_mouth:
now my ears hurt

{{round(value*10)/10 }}

Thnx! that works… but what is the new solution, any idea of that?
why did they changed it? it was the correct way and now a workarround. :frowning:

o dear… i had that also in the beginning. my neighbours now hate me while it never happend again. that is because i limited the max volume in de sonos settings to max 50%

What is going wrong and right here?

The watermeter is writing its data in 486.555 Dutch. Where 555 are the liters…… thats why divided by 1000.

Round by 3 numbers behind the comma

Divided by 1000??

But… why would you want to round liters to 3 decimals. Liters is the smallest unit in case of a watermeter
So, the calculation needed looks like this: {{[tag_eind]-[tag_begin]}}
Example: 486.755−486.555=0.2
When you want the number 0.2(m³) in liter units, then all you have to do is multiply it with 1000: {{([tag_eind]-[tag_begin])*1000}}
Example: (486.755−486.555)*1000=200

For people like me who can’t speak Dutch please translate it in English. Thx!

1 Like

Ha Peter, dankjewel…. En inderdaad, die drie komma’s zijn onzin…

1 Like

Whoops Dirk, I Englified my post :wink:
Sometimes I’m writing in English in Dutch topics… I think it comes with age :rofl:

1 Like

Works for me as of june 22 :slight_smile:

can u show?

This is a way to round values to 0.1 or 0.5 or 0.01 or 0.25

Input value:



1 Like

For 2 decimals, use: {{round(value*100)/100}}

1 Like

I am trying to work out how to use better logic variables versus logic variables. It looks like Better Logic variables are seperate.
I want to set a variable to the result of subtracting one Tag from another Tag. I can do this with Better Logic but then I can’t work out how to access the Better Logic variable from other flow cards.