v4.58 added native handling of the Math.js ‹ random › function so it can be called directly in actions that calculate a value (and it’s particularly handy in the « Wait » action).
And it’s, of course, more intuitive than having to use the alternative with the « HTTP Request » action as described here.
I would need to use the math.js ‹ exp › function to define a watering duration that intensifies as follows when my tank is well filled:
I couldn’t find in the docs an existing list of mathjs functions supported natively (does one exist and I missed it?). From my tests, these functions are already supported:
- abs
- random
- ceil, floor, round
- compare, larger, largerEq (and so I suppose smaller, smallerEq… as well, but I haven’t tested)
Among everything Math.js offers, I would find it useful to add the following functions:
- min, max, mean
- log, exp, square, sqrt (and maybe cube and cbrt)
@pierre-gilles would you like a feature request per mathjs function?
No, in this case this one is sufficient 
Thanks for the request!
1 Like
@pierre-gilles , where can we find the list of native functions usable in scenes ? thanks
Hi @Nagromdark,
You’re right, there’s no documentation on this. I’ve made a note to look into it.
In the meantime, here are the available functions:
add - Addition
divide - Division
larger - Comparison « greater than » (>)
smaller - Comparison « less than » (<)
largerEq - Comparison « greater than or equal to » (>=)
smallerEq - Comparison « less than or equal to » (<=)
mod - Modulo operation
round - Rounding numbers
random - Random number generation
To use these functions, I recommend the Mathjs documentation: https://mathjs.org/
I’ll keep you posted as soon as I’ve written clearer documentation with examples 
1 Like
@pierre-gilles, based on some tests I ran, the functions ‹ compare ›, ‹ abs ›, ‹ ceil › and ‹ floor › also work.
1 Like
@Nagromdark @StephaneB I added new documentation:
I updated the documentation of Wait and Condition on variables to mention this page about the available math functions!
I managed to use everything, except compare which doesn’t work for me, so I didn’t include it in the documentation. How did you do it?
1 Like
Well, easy, I must have taken an illicit substance…
Because I can’t reproduce what I thought I saw working either… Sorry for the false lead 
1 Like
And thanks for this page, it will be very useful. Maybe the page could also describe the method via an HTTP request, for those who would like to use some slightly exotic mathjs methods?
1 Like
Which more exotic methods are you talking about? I think it will take longer to write that documentation than to add the methods in Gladys 
Well, there are the ones I listed above. But unless you plan to add them soon:
- min, max, mean
- log, exp, square, sqrt (and maybe cube and cbrt)
And otherwise, a home automation enthusiast AND mathematician
might want to use the mathematical functions fix(), mod(), gcd(), lcm(), the logical functions and(), not(), or(), xor(), the function randomInt(), the comparison functions compare(), equal(), unequal(), the text comparison functions compareText(), equalText(), the statistical function median(), some trigonometric functions, …
And I’m only picking the ones whose purpose I understand, but there are plenty of others that might also be useful, I don’t know… That’s why it would seem useful to explain that calling mathjs.org is also possible.