# Advanced Flow: Random Node

**URL:** <https://community.homey.app/t/advanced-flow-random-node/73130>\
**Category:** Ideas & Suggestions\
**Tags:** homey-pro, advancedflow\
**Created:** [December 5, 2022, 12:39pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130 "2022-12-05T12:39:58Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [December 5, 2022, 12:39pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/1 "2022-12-05T12:39:58Z")

</div>

![random](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/9/e901717299c8de130f8a93e56aaa2688b8956f0b.png)

I would love to see a random node like this!

What do you think?  
What is the currently the way to recreate this randomness?

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [December 5, 2022, 12:47pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/2 "2022-12-05T12:47:52Z")

</div>

> [@dima](#):
>
> What is the currently the way to recreate this randomness?

Logic card: Continue with a chance of x %

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/9/d982ebea96dcb59915e45ce0e55b8c12ef05f237.png)

---

<div class="post-metadata">

**Author:** ![Gruijter](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gruijter/32/1973_2.png) [@Gruijter](https://community.homey.app/u/Gruijter)\
**Post date:** [December 5, 2022, 4:31pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/4 "2022-12-05T16:31:52Z")

</div>

Maybe you need to enable Power User in your Homey experiments settings.

 ![Screenshot_20221205-173131_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/e/ee4538f6acd82fd529f7ffef85164bb120965efc.jpeg)

---

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [December 5, 2022, 4:36pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/5 "2022-12-05T16:36:08Z")

</div>

Nevermind, I found the card. It was under … AND and not … THEN

Anyways, this only allows for 2, 4, 8, 16, 32, … etc. outcomes. Unfortunate if you want to have exactly 12. Unless you do some fancy math.

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [December 5, 2022, 4:53pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/6 "2022-12-05T16:53:10Z")

</div>

“Fancy” math 😉 , still most of the time it is 50%, just not the first step where it should be 33% chance

 ![fancy math](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/b/2b74721e0d9e6adb1033f6df5248f4a0f78fa903.jpeg)

But if you wanted to start to go this route, calculating a random number and checking what the value is might be getting easier and more expandable:

 ![random](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/1/118a5c8b2f7ec9da1f132003f6fd2f74ba1b3d73.jpeg)

Calculation: `{{ floor(random() * (max - min) + min) }}`  
_(calculation in the image has a tiny mistake by adding an end bracket too many!)_

---

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [December 5, 2022, 5:22pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/7 "2022-12-05T17:22:02Z")

</div>

Ok, I admit, it’s not too fancy. Still, I would prefer a “random” node 😜

I think you could also use randomInt([1, 12]) istead of {{ floor(random() \* (max - min) + min) }}

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [December 5, 2022, 5:23pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/8 "2022-12-05T17:23:42Z")

</div>

not with the default logic cards, it isn’t MathJS that they use there, then you should use the app “better logic library” to be able to do that.

But yes, a random node would be easier, feel free too ask Athom to add it via their support form, shouldn’t be too too hard to add something like that. (i think)

---

<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:** [December 5, 2022, 6:35pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/9 "2022-12-05T18:35:37Z")

</div>

![Screenshot 2022-12-05 at 19-34-29 1.HomeyPro Peter](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/5/5595650f6617f559c41e30c222d947b762b9631d.png)

---

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [December 6, 2022, 1:52pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/10 "2022-12-06T13:52:14Z")

</div>

Not to be a smartass, but you can use “randomInt(1,12)” without the round() 🕶

---

<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:** [December 6, 2022, 4:55pm UTC](https://community.homey.app/t/advanced-flow-random-node/73130/11 "2022-12-06T16:55:10Z")

</div>

No, I like improvements / simplifying 🍻 Thanks for the hint!

---

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [February 9, 2023, 9:26am UTC](https://community.homey.app/t/advanced-flow-random-node/73130/12 "2023-02-09T09:26:02Z")

</div>

> [@Caseda](#):
>
> it isn’t MathJS that they use there

are you sure? randomInt() definetly works on my homey. The threads found on this forum also point to the math.js reference page:

> [@Available math functions](https://community.homey.app/t/available-math-functions/16622):
>
> 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?

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [February 9, 2023, 9:34am UTC](https://community.homey.app/t/advanced-flow-random-node/73130/13 "2023-02-09T09:34:03Z")

</div>

Back in 2019 it was not the case, several were added manually after i asked for them.

---

<div class="post-metadata">

**Author:** ![dima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dima/32/16639_2.png) [@dima](https://community.homey.app/u/dima)\
**Post date:** [February 9, 2023, 9:48am UTC](https://community.homey.app/t/advanced-flow-random-node/73130/14 "2023-02-09T09:48:13Z")

</div>

btw, thank you for this one! It’s the route I went for in the end:

 ![Screenshot 2023-02-09 104734](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/2/326e93ca8968b7dbfd34448f085b1a9e40027039.jpeg)

---

<div class="post-metadata">

**Author:** ![Freek\_V](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/freek_v/32/47643_2.png) [@Freek\_V](https://community.homey.app/u/Freek_V)\
**Post date:** [April 1, 2024, 10:32am UTC](https://community.homey.app/t/advanced-flow-random-node/73130/15 "2024-04-01T10:32:56Z")

</div>

With the other solution above, I arrived at this “random” method:

 ![Homey Random](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/a/2ac50e9cf0d147b7da165b142ca67efc207bdbb5.png)

So a trigger is started based on the outcome. (1 till 12)

At the end the value is set to 0 to prevent the trigger from ending up with the same number.
