Help with evaluating variables and functions

I am new to SharpTools and cannot figure out how to make this code work:

For the “setColor” action, how do I make SharpTools recognize $SelectdHueNumber as a variable rather than text? I have tried adding {} and {{}} on either side of the variable but the text “$SelectdHueNumber” always gets sent rather than the number selected by the pickRandom command.

I have also tried using {{ random(0,99) }} and SharpTools doesn’t evaluate the function, it just sends the text "random(0,99).

Keep in mind that the {{ inline expression syntax}} format only works within String arguments. It won’t work in objects and for numbers, you would just pick the variable directly.

Have you tried using the setHue() command and pick the $SelectdHueNumber variable directly? Keep in mind that your variable must be a numeric type for this to work as the setHue() command expects a numeric argument (so other variable types like text will get filtered out from the picker)

One other minor thing which may or may not be an issue depending on the use case, but the pickRandom() as you have it configured is picking a string from your list. If it’s being saved to a numeric variable, it’s not a huge deal as the system will automatically try to coerce it to a number and all of those strings should be coercable, but you could also pickRandom from a set of numbers. (Again the variable type you’re saving to IS important)

pickRandom([0, 5, 10, 15, 20])

(Note the lack of wrapping ‘tick’ marks which indicate text rather than a number)

I cannont get the setHue() command to change color of the lamp. I have tried with just inputting numbers and lamp color will not change.

The setColor(“hue”:xx,“saturation”:xx) command works if I use numbers for “xx”, but not if I enter a variable or a function for “xx”.

I removed the tick marks from the pickRandom command and ensured $SelectdHueNumber is setup as a numeric variable and nothing changed.

As you can see in my uploaded image the programming environment doesn’t seem to recognize $SelectdHueNumber as a variable when I type it.

I’m about 80% sure that I’m inputting something wrong on the arguments line for setColor, but I can’t figure out what I’m doing wrong.

Can you open up the setColor() command and share a screenshot of what you’re seeing?

If the icon to the left of the first argument is {} that means it’s an object type and we don’t currently support inline expressions within object types.

If it’s Aa, then it’s a string type and it should support the inline expressions. The challenge here is that your device must support accepting a string for the first argument for this to work. Many devices do, but there’s also many devices that don’t

That’s where the setHue() comes in and it should work as it’s part of the same capability that defines the setColor() command. That being said, some uncertified drivers don’t always implement things properly. What type of device is it? And are you using a specific driver with it?

I would also add that some devices respond to each of these commands differently. Some will automatically turn on the light to the last known level, whereas some might just internally adjust the Hue for the next time the light is turned on. Were you testing with the light already on and within your line of sight so you could see if it was changing?

Ok, that is my problem. It is an “object type” argument rather than “string type”.

I am able to see the device as I send “setHue” commands so I can see that it isn’t changing. I haven’t tried turning it off changing hue and turning it on…but I’d rather not have to do that just to get it to change color.

The device is an Inovelli Bulb Multi-Color LZW42. I have not changed drivers or made any updates to anything other than standard SmartThings. It shows as running firmware 2.28 which I think is the current version.