I currently do this with a large If Then Block, but it is a pain to change the number of items to randomly pick from for Alexa to speak. It would be much easier codee to be able to dynamically reference a variable name. Is there a way to do this? Maybe I am not thinking of this in the correct manner?
e use case is just I like for Alexa to tell me how many days to big events that are coming up as part of my nightly routine and I have it randomly pick an event and tell my "there are x days until y event"
That's kinda where my first (deleted) answer was going, as I figured you meant "logic branching" or "indirect reference". But in RM, where there's a will, there's always a way!
Maybe show us a screenshot of how your rule currently works??
Try this on for size... my goal was to eliminate the IF-THEN tree and ugly hard-coding of the date strings, by putting the occasions into a compact, easier-to-maintain list to pull from.
The actions extract a random event from the list, then parse the result into two components (What and When).
From there, you can do all the computational stuff you need.
Note the random() seed must equal the number of events, since it generates 0, 1, … , N-1, ideal for 0-indexing through this list. (It will never output N; for this reason, I think your rule will never evaluate to 5.) Just update Step 1 as your list grows.
The rule works as intended. SFAIK RM doesn't offer a way to remove Time from the finished DateTime var, but that won't affect your calculations.
Warning: If you mistakenly set the random() seed higher than N (the actual count of list items), RM will stop (and Log an error) at Step 2 whenever the index goes out of bounds. Worse still, if you mistype anything in Step 5, expect the rule to crash irretrievably, and you'll have to start over. (For this reason, I keep Export'ed copies of touchy rules.)