How to pick a random number between 1-50 and enter it as a parameter

Oops, never mind, forgot the % at the end of the variable name!

It seems to be working! But i'm still getting an error:

The error doesn't seem to bother anything and the LED controller is picking a random effect now with the push of a button. My daughter is going to be so excited! Thanks @672southmain! I'm also a little more familiar with variables now which have been a black box to me mostly!

Sorry to make you struggle without giving an answer you could simply copy, but itā€™s the only way I knew to get you to think and learn.

Sadly, the Hubitat documentation is cr*p, in my opinion.

Hereā€™s a screenshot of the two lines of a rule you need to insert to get the number (1 to 50, inclusive) you want. I added a logging statement so you could try it a few times, but the way to test, really, is to just create the two line Rule that sets Effect, and hit the ā€œRun Actionsā€ button and watch the resulting value of Effect.

No worries, I totally get it! Where do I find the "add 1 to variable" in the list of actions? I can't find it anywhere!

Nevermind, spoke to soon.. found it!

1 Like

Edit: see you found it.

Sorry! Thank you though! I think everything is working great now! Minus that pesky error grovvy error.

One more for good measure

Thatā€™s being generated by the driver. I donā€™t have that device, so I canā€™t know what the driver wants. Iā€™d look at the code, but I donā€™t have the driver. If itā€™s a community driver, open it up, look at line 488, and at the definition of the setEffect routine and what types it expects for arguments.

Does it generate the error if you call it with integers 1 to 50 ?

Oh that makes sense then. Here's a screenshot from that area of the driver code:

If I manually set an effect through the driver, I get the same error in the Log. Perhaps it's expecting and FX Speed, FX Intensity and Color Pallette as well; although it works fine without them as it seems to be using defualt ones built into the effect.

image

Sorry, I just realized the line numbers from the device driver didn't show up in the screenshot. This is line 488: def paletteName = state.palettes.getAt(pal.intValue())

This is probably more something for the guy who wrote the driver but I appreciate you looking into it for me anyways!

Looking at the log, it seems to indicate that the effect is some sort of enum (Halloween, Theater Rainbow, etc.) or list. I can understand why it barfed on 53, if your docs indicate it wants 1 .. 50, but I donā€™t understand the other errors.

Is there an enum or list or map earlier in the driver that is used as the type for fx?

I don't see anything. If you're interested, here's the code on GitHub but don't feel obligated at all to spend time on it:

Glancing at the driver, the error is always when it tries to get the Color Palette name. Try putting a valid palette in as a parameter.

For some reason it's getting an array of 0 instead of a number when you call the function. Technically it shouldn't have even worked. I added the segment index to the setEffect call, see if that fixes this for you.

Thanks! I'll try that new driver soon. For now, things are working great minus that error in the log. Nice to have this awesome LED controller integrated into Hubitat.

Here's my daughter's bed. She's pretty excited.

1 Like

Is it too bright only on photo?

The LEDs are on full brightness in the video but you can adjust the brightness down. I'm using a Lutron Pico remote and have programmed it to turn the LEDs on, off, adjust brightness and randomly choose a different effect. There are about 71 effects.

Sorry to bring up an old thread. I am utilizing the information from this thread to make a BC rule that involves random number selection. My current issue is that I need to the button to select a random number from 1-10, then 101-241 for a Govee scene selection on a strip light. Is this possible?