Inbound triggers into a binding

There are a lot of examples of how you can generate triggers from a binding. However, I can’t find any examples of the opposite - how can the user invoke a trigger on a binding and how does the binding handle that?

I have a binding (Omnilink) that models some items without state. For example, executing a macro on the remote system or sending a status request to another device. Right now, they are modeled as a switch which gets its state set to UNDEF after the command is passed to the Omnipro. Is that the appropriate way to handle this - or is there a way to use inbound trigger events into a binding?

Take a look at some handleCommand(…) exemples in addons repo

Are you saying you can just use handleCommand as you normally would for a state style item - but with an inbound trigger… Just check for the channel UID?

The yamaha binding seems to do just that - so I will give it a shot.

Are there any examples of how you would invoke a trigger from a rule? I found plenty of examples of detecting triggers in rules, but none for invoking.

1 Like

from within a rule, you can use sendCommand(…) to your item that sends it back to the channel

Not really. For momentary events the stadium is to use Channel triggers. See the Astro binding’s sunrise or sunset events or the Dash Button binding.

For “triggering” the binding, like Gaël said, that’s what sending commands to Items is for. The Item links to a Channel on a thing. I can’t say what that looks like in the binding code though, but since almost every binding does this it shouldn’t be hard to find an example.

Yes, you can search examples of RefreshType. You’ll find a good example here

Thanks @rlkoshak -
I think my question was poorly worded.

The examples you gave are what I would call “outbound triggers form a binding” not “inbound triggers into a binding”

Outbound:
Sunrise Happens -> Astro Binding Generates Trigger -> Rule Listening for Sunrise Trigger Channel
Dash Button Pressed -> Dash Binding Generates Trigger -> Rule listens for trigger

I am asking about the opposite. How in a rule do you invoke a trigger channel?
Rule -> Generates Trigger -> Binding responds to trigger

I think I did find a binding that processes inbound triggers, but no corresponding example rule. If you look at the navagation_channel for the Yamaha Receiver binding.

How do you invoke navigation_channels#navigation_updown from a rule?

The documentation for sendCommand has the following:
MyItem.sendCommand(<new_state>)

However, trigger channels are stateless (that is the whole point of triggers, right?). So what new state would I be sending on a trigger channel, do I just pass null?

Edit: Looking at the code for the yamaha binding it checks for UpDownType when looking at the trigger channel. So it would appear you can pass a new “state”, that is just a command. Will give that try.

@David_Graeff -
It appears that you ran into the same question. I see that issue is closed in GitHub. Did you ever discover how to handle stateless items in a binding? Do you use trigger channels somehow or did you go a different route?

There was a recent addition to the core for “command” options. You would use those nowadays for a stateless command only channel.

I still have to adapt the Yamaha binding and milight binding to use this pattern. Will be available with oh 2.5 for the mainstream and is included in 2.5m1 already Afaik.

And no there is no documentation for this feature. It works like state options.