Advanced Flow: Random Node

I would love to see a random node like this!

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

Logic card: Continue with a chance of x %

3 Likes

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

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.

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

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:

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

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

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

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)

3 Likes

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

1 Like

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

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

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

1 Like

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

1 Like

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

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.