EventTriggers to update a custom Attribute

I am working through the tutorial video 1-8 about Data Triggers, and I am trying to figure out how to use a custom Attribute that will be displayed in a label.

I am using a device with capability MediaInputSource (which has attribute InputSource). I have an “Input 1” button with an EventTrigger set to ‘clicked’ and a DataAction to bind the value “Input1” to @Device.InputSource. I have a label with text set to @Device.InputSource. This works fine.

The next step is I added InputSourceCommonName as an Attribute in Device Properties. I changed the label text to @Device.InputSourceCommonName. I added an additional DataAction under the Input 1 button’s EventTrigger to bind the value “TV” to @Device.InputSourceCommonName. But no matter what I do, the label does not display anything.

What might I be missing?

The device integration would have to support the InputSourceCommonName for this to work. I’m not aware of any official integration that support this attribute. If this is for a Plugin you’ve written this could work, but you’d need to handle this change in the onChangeRequest function. For example, your Plugin function would have to look something like this:

Ah ok thank you - that makes sense. Yes it is for a plugin I am writing, so not hard to implement. I did exactly what you describe on another plugin, so I should have thought to go that route.

I assumed (incorrectly) that using an EventTrigger by itself was enough to update the device attribute. So am I correct to say that for a Plugin I develop, any attribute, whether ‘built-in’ from a capability or a ‘custom’ attribute I add, needs to be updated using the onChangeRequest? I think I was misinterpreting Brian’s 1-8 video on triggers.

Correct. All custom attributes & attributes from capabilities have to be accepted by the Plugin.

Ok much better - thank you! That’s working.

Is there a way via Triggers to update an attribute based on another attribute changing? For instance, I have the typical DataTrigger -> Setter to highlight the button if InputSource is set to a certain value - which is helpful for if the input is changed via another method (i.e. remote control). But InputSourceCommon only updates unless the button is clicked in HR. Is the only way to do this also in the Plugin code in OnPoll?

Change requests cannot be sent on DataTriggers. Only EventTriggers can send the command. So yes, you’ll have to update in the Plugin using OnPoll as you’ve suggested.

Ok good to know, thank you! Considering this solved.

Thanks for all the timely support and help that is so evident throughout this (and the previous) communities. Home Remote is a hidden gem that I’m glad I stumbled on…

1 Like