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 , 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

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()

1 Like

No, I like improvements / simplifying 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.