Calling a specific Thing java-function from within a Rule


I’m thinking of extending a binding with some additional functionalities/commands. These functionalities address acyclic request that should enhance the usage of specific ‘things’.

I’d like these enhancements to be able to be triggered by OpenHAB rules. The issue is that these functions I’m talking about aren’t related to ‘items’ or ‘channels’, but are actually properties of the ‘thing’ itself. They are so specific that adding them as additional channels would only make the binding unnecessary complex.

How would I go about adding a thing function inside my binding that would be callable from within an OpenHAB rule?

A bit more to the point:
I’d need to send specific array of bytes to a device to apply some new configuration from time to time.
I’m aware of the sendCommand for ‘items’ and the Actions addons, but I’d need a command for the ‘thing’ itself. Is this at all possible with OpenHAB and rules? Do I need to create my own action to achieve this, and if so should that be separate from the binding?

Kind regards,
Frederic Depuydt

It sounds like what you want is a thing action. Take a look at this PR for an example:

(There are undoubtedly better examples, but I happen to know that one.)

And the developer docs here:

1 Like