Multiple Parameters for Automation Actions

Does anyone know of a way to define an automation action that take multiple parameters? For example, say I want to create a capability that allows you to set the color of a light and define the duration of the color transition. Rather than use a preference and assume all transitions are the same, I would like to be able to change the duration in the automation actions.

If I define two different fields, and set them both in the actions, I would end up getting a setColor and setDuration at two different times. I would need to get both at the same time to pull this off. If I can’t get them at the same time, can I define them in a way as to guarantee I would always get one first if used in the same automation?

from my experience the best you can do is to implement delayed execution . AFAIK there is no way to guarantee order or couple events.

1 Like

I thought about this option as well, delaying one of the two. The thing I don’t like about that is that it slows down the second action even in cases where you don’t need it. To go back to my example, you may set the color and not specify a transition duration. Maybe @nayelyz knows if there is a way to guarantee execution order on actions taken on the same device, in the same automation?

Based on the definition of the switchLevel capability, it should be possible to pass multiple arguments to a command. When I’ve tried this in the past though, the hang up has been getting both arguments to present on the automation screen. I haven’t tried recently, so it’s possible something has changed to allow for this to work now that multi-attribute capabilities are working.

@Mariano_Colmenarejo has feature in his driver that changes preset colors and also you can change duration

This colors are hard-coded by him. You cannot choose your own colors. Maybe one day

This are actions

Yes. Most drivers can set multiple items in the automation screen, but those are delivered to the driver one at a time, not simultaneously. His driver would get a setTimer and setColor as two different events. I don’t see any way in the driver code to apply them all at once since the events are delivered individually.

@Mariano_Colmenarejo I assume your timer just sets an internal duration state which is applied to any future color change events. If a user sets the duration and color at the same time, you could potentially change the color with the old duration, correct?


This function that was shown i think is not what you want to do.

This is for changing colors and how long it takes to send a new color.

I think you are referring to the transition time argument in the setColor command.

I configure that value optionally in preferences and therefore it cannot be changed dynamically with routines.
To make it dynamic with routines and apply it in a routine, it would be necessary to do it as @veonua said, delaying the sending of the command with device.thread:call_with_delay() , 1 sec, to ensure that you have the transition time value already updated.

1 Like

:+1: Thanks. Seems to be the way to go. I’ll have to play with the delay to see how short I can get it.



This is not supported yet, there’s a display type in the documentation called multiArgCommand but it isn’t implemented in the app yet. Sorry for the confusion.

About this, there is an implementation to have more than one command in actions in a single capability. Take this capability’s config as a reference:
In the driver, you can use the same handler for both commands and check if both values are there or compare if they’ve changed.
We can take reference from the Zigbee sample that has the three-axis capability and waits to get the three values to send the event because when it’s recently paired, not all of them are received:

Note: This question is related to this post, right? Capability with Relative Controls? - #18 by blueyetisoftware

1 Like

Thanks for the ideas there. I don’t see multiArgCommand in the docs for capabilities here Capabilities | SmartThings Developers

My capability does support multiple commands as you mention, but each command can only take a single parameter.

It actually isn’t related. That is a different device. To get more specific, this device is a gradient lightstrip that can be animated. For example, it has a sunrise animation that goes from blue to orange. This animation also takes a duration. So I end up telling the device to run the sunrise animation over X milliseconds. It is easy enough to create a list of all of the animations that are possible, and to create a number field to take the duration. Some animations require a duration, and some don’t, so I was hoping that I could create some defaults that user could override in the automation actions. It sounds like I will need to require that they set both if they choose one of the animations that needs it. Just makes the experience confusing to the user.

@nayelyz The capabilities can use the object type for data which would be great for me:

object `{name: sunrise, duration: 5000}`

But there isn’t an action UI to control it in the app. You actually see a similar problem for the colorControl capability which has 3 commands (setHue, setSaturation, and setColor). setColor takes an object. It looks like the ST app made a special case for this and created a UI control that provides both the hue/saturation simultaneously