# Available math functions

**URL:** <https://community.homey.app/t/available-math-functions/16622>\
**Category:** Questions & Help\
**Created:** [August 9, 2019, 9:48am UTC](https://community.homey.app/t/available-math-functions/16622 "2019-08-09T09:48:17Z")\
**Posts on this page:** 19\
**Page:** 3

<div class="post-metadata">

**Author:** ![JohanP](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johanp/32/119002_2.png) [@JohanP](https://community.homey.app/u/JohanP)\
**Post date:** [April 24, 2025, 7:45pm UTC](https://community.homey.app/t/available-math-functions/16622/41 "2025-04-24T19:45:38Z")

</div>

Add a ‘crazy’ number to the calculation, check no and subtract afterwards.

I did with temperature :

VAR + 1000  
If VAR greater than 1000 its a number (if its 1000 or less its not)  
VAR - 1000  
If VAR eq 24

Edit:  
Does NOT work if VAR is a character like ‘T’..

---

<div class="post-metadata">

**Author:** ![DeBossDK](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/debossdk/32/105832_2.png) [@DeBossDK](https://community.homey.app/u/DeBossDK)\
**Post date:** [April 28, 2025, 7:51am UTC](https://community.homey.app/t/available-math-functions/16622/42 "2025-04-28T07:51:04Z")

</div>

Awesome!! - That worked perfectly.. Now I get an error if NaN.. 🙂  
Thanks!

---

<div class="post-metadata">

**Author:** ![JohanP](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/johanp/32/119002_2.png) [@JohanP](https://community.homey.app/u/JohanP)\
**Post date:** [April 28, 2025, 7:56am UTC](https://community.homey.app/t/available-math-functions/16622/43 "2025-04-28T07:56:02Z")

</div>

Yes, I was going to add that: check for error if NaN, but you allready found out…

---

<div class="post-metadata">

**Author:** ![John\_William\_Brekke](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/john_william_brekke/32/111887_2.png) [@John\_William\_Brekke](https://community.homey.app/u/John_William_Brekke)\
**Post date:** [May 27, 2025, 6:02pm UTC](https://community.homey.app/t/available-math-functions/16622/44 "2025-05-27T18:02:51Z")

</div>

know any ways to replace text?

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [May 27, 2025, 7:28pm UTC](https://community.homey.app/t/available-math-functions/16622/45 "2025-05-27T19:28:56Z")

</div>

I thought using the standard JavaScript `replace` method would work, but I cannot get it to work in a flow card.

E.g. `{{ “TEXT TAG“.replace("Original", "New") }}` where TEXT TAG is a tag or variable containing the text “Original Text”.

However Homey gives an error (invalid or unexpected token). Maybe someone else knows how to use the replace method.

---

<div class="post-metadata">

**Author:** ![John\_William\_Brekke](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/john_william_brekke/32/111887_2.png) [@John\_William\_Brekke](https://community.homey.app/u/John_William_Brekke)\
**Post date:** [May 27, 2025, 7:42pm UTC](https://community.homey.app/t/available-math-functions/16622/46 "2025-05-27T19:42:32Z")

</div>

Yeah, i tried the exact same thing.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 27, 2025, 9:29pm UTC](https://community.homey.app/t/available-math-functions/16622/47 "2025-05-27T21:29:19Z")

</div>

Nice puzzle @John_William_Brekke

@SunBeech Unfortunately we cannot use the ‘calculate a value’ card for a string variable. But with Better Logic we can, with the 'Set [variable] to BLL [Calculation], like this:

 ![1000000982](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/9/69d51ce8cf4dc0d7effa749653b947e176fe6498.jpeg)

_Working flow_ example:

 ![1000000985](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/b/db131d3b3013887d6f32a745326a8af22da8a538.jpeg)

---

<div class="post-metadata">

**Author:** ![John\_William\_Brekke](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/john_william_brekke/32/111887_2.png) [@John\_William\_Brekke](https://community.homey.app/u/John_William_Brekke)\
**Post date:** [May 27, 2025, 11:01pm UTC](https://community.homey.app/t/available-math-functions/16622/48 "2025-05-27T23:01:05Z")

</div>

So with the better logic app replace will work?

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [May 28, 2025, 5:48am UTC](https://community.homey.app/t/available-math-functions/16622/49 "2025-05-28T05:48:53Z")

</div>

Hi @Peter_Kawa, interesting. That was also my thought. I tried the BLL ‘execute BLL expression as’ card before posting and got the same error. As I normally use that card for operations on strings, I assumed the method is not supported on Homey.

As such, I don’t understand why the said BLL card does not work with the replace method, while the ‘set variable’ card does. Did your suggested flow work?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 28, 2025, 12:16pm UTC](https://community.homey.app/t/available-math-functions/16622/50 "2025-05-28T12:16:15Z")

</div>

This card I used, can take string variables, that’s the trick.  
Mathjs functions for strings just don’t work with cards which only take numeric variables

 ![1000049440](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/d/cdaf8e6e7361acbdba89d60e4935723601d71d5e.jpeg)

> [@SunBeech](#):
>
> Did your suggested flow work?

Of course 😬, I also included the timeline notifications it produced 😉

 ![Screenshot_20250528_141729_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/f/ff9ef9a34b4498e0c9935e8a52b5583590e1270b.jpeg)

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [May 28, 2025, 12:39pm UTC](https://community.homey.app/t/available-math-functions/16622/51 "2025-05-28T12:39:57Z")

</div>

Maybe I should first look at your screenshots before commenting 😊 😅.

Is there an easy way to determine whether a flow card works with string functions? Or is it just a matter of trail and error?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [May 28, 2025, 12:49pm UTC](https://community.homey.app/t/available-math-functions/16622/52 "2025-05-28T12:49:10Z")

</div>

🤪

Yea, I 'trial and errored" until I discovered this particular BLL card, which can be used for _string/text_ calculations on _any_ variable type.

Afaik all other cards take only numeric variables to calculate on, and using .replace on strings/text just gets rejected for non-numeric data.

Does this make sense?

But, wait! Yesterday I couldn’t get it to work, but now I tried this in an ordinary notification card and it works !  
This should work with Homey variables as well

```auto
{{ "[bll_stringvar]".replace("[name]","[other_name]") }}

```

 ![Screenshot_20250528_145443_Firefox](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/9/799ba0f0493ba83f3f302f3a060839a74d6a2699.jpeg)

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [May 28, 2025, 1:07pm UTC](https://community.homey.app/t/available-math-functions/16622/53 "2025-05-28T13:07:30Z")

</div>

Strange!

I got confused because the ‘execute as tag’ BLL card I normally use for string calculations, like the following example (which extracts the first name from the full Homey user name):

 ![IMG_1877](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/6/f6706fd66fe1792601b22d6cd720ee66fc98d37f.jpeg)

did not work with the replace method. The following example with the replace method does not work:

 ![IMG_1879](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/e/7eb44b4697b85931368602cc27feffd47e978a28.jpeg)

Anyway, trial and error it is 😀!

---

<div class="post-metadata">

**Author:** ![John\_William\_Brekke](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/john_william_brekke/32/111887_2.png) [@John\_William\_Brekke](https://community.homey.app/u/John_William_Brekke)\
**Post date:** [May 28, 2025, 11:11pm UTC](https://community.homey.app/t/available-math-functions/16622/54 "2025-05-28T23:11:05Z")

</div>

Thanks, i tried what i wanted it to do and it worked!

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [June 6, 2025, 8:37pm UTC](https://community.homey.app/t/available-math-functions/16622/55 "2025-06-06T20:37:20Z")

</div>

> [@SunBeech](#):
>
> got confused because the ‘execute as tag’ BLL card I normally use for string calculations, like the following example (which extracts the first name from the full Homey user name):
> 
> ![IMG_1877](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/6/f6706fd66fe1792601b22d6cd720ee66fc98d37f.jpeg)
> 
> did not work with the replace method.

It does or doesn’t?  
Because it should work 😅

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [June 6, 2025, 9:07pm UTC](https://community.homey.app/t/available-math-functions/16622/56 "2025-06-06T21:07:22Z")

</div>

It works if I create the flow on my computer via the web app. If I create exactly the same flow via the web app on my iPad, it does not work.

Looking closer, I now see that on iPad the default double quotes are different (angled) compared to those on my laptop (straight).

 ![IMG_1906](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/9/a93ca43c8b1d1217bd3412e613824b39e896dd6f.jpeg)

Note to self: select the correct double quotes 😊.

---

<div class="post-metadata">

**Author:** ![John\_William\_Brekke](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/john_william_brekke/32/111887_2.png) [@John\_William\_Brekke](https://community.homey.app/u/John_William_Brekke)\
**Post date:** [June 13, 2025, 12:25pm UTC](https://community.homey.app/t/available-math-functions/16622/57 "2025-06-13T12:25:59Z")

</div>

Yeah hold down the ”“ button to get “” i always hold it to get the straight ones because for some reason my default is «»

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [June 20, 2025, 7:06pm UTC](https://community.homey.app/t/available-math-functions/16622/58 "2025-06-20T19:06:41Z")

</div>

> [@SunBeech](#):
>
> Note to self: select the correct double quotes 😊.

I still hope there comes an option for flowcard defenitionw (within the app for devs) to mark a flowcard-argument field as coding. So if you include a string token, it wraps it in double qoutes. Or a yes/no token as true and false, instead of yes/no (hp2019) or emoticons (hp2023).

---

<div class="post-metadata">

**Author:** ![SunBeech](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/sunbeech/32/111391_2.png) [@SunBeech](https://community.homey.app/u/SunBeech)\
**Post date:** [June 20, 2025, 7:44pm UTC](https://community.homey.app/t/available-math-functions/16622/59 "2025-06-20T19:44:26Z")

</div>

Yes that would make sense and easier for the end user.

I am a HP2023 user and also having trouble understanding how to use booleans in math.js functions, since Homey seems to convert them to symbols (as you indicate), while my mind thinks in true/false options 😅.

[Previous page](https://community.homey.app/t/available-math-functions/16622.md?page=2)
