[ST Edge] updating multiple attributes with single device:emit_event call

Hi,

For multi attribute capabilities, is it possible to update several attributes with single device:emit_event call?
For example, consider a standard signalStrength capability.
It has 2 attributes: rssi and lqi

The classical approach to update both would be 2 calls:

device:emit_event(capabilities.signalStrength.lqi({value = lqi}))
device:emit_event(capabilities.signalStrength.rssi({value = lqi}))

I’m looking for something like this:

device:emit_event(capabilities.signalStrength( { lqi = {value = lqi}, rssi = { value = rssi} } )
1 Like

You can do it if your capability supports it. The colorControl capability is a good example. It has a hue and saturation. colorControl encodes the object as a string but you don’t have to. You can also use the object type when you define your attribute:

device:emit_event(capabilities.colorControl.hue(hue))
device:emit_event(capabilities.colorControl.saturation(saturation))

device:emit_event(capabilities.colorControl.color(json.encode({
  hue = hue,
  saturation = saturation
})))
1 Like

Hi, @ygerlovin & @blueyetisoftware

This is true, but it is also true that, currently, the only capability that supports it is colorControl. So @ygerlovin the short answer is you have to do it separately unless you are using colorControl.

1 Like

I do this using encoded json strings in custom capabilities. There is no way to use the events from the UI, but they do work programmatically.

1 Like