Fetching data from other Bindings

Hello, I’d like to develop an Add-on which allows to extend OH by a dynamic (or self adjusting) policy. For this purpose it would be necessary to fetch the data from selectable devices. The extension should work event-based which is the reason that I don’t want a periodical trigger.

I know that there is a rule system which provides the functionality to send Commands when an item changes but for my purposed it’s not possible to abstract from the Thing layer. Afaik accessing a thing is useless to because they don’t keep their State, please correct me if I’m wrong.

To specify my question: Is it possible to access the event-bus inside a binding and to fetch specific channel-values?

You could use input channels, fed with a follow profile. As an example take a look at the newly merged Sagercaster binding

1 Like

Could you please provide more information about what you would like to do, rather than how you think it should be done? From what you provided, it sounds like a rule would work, but using Items rather than Things, if you need State information. Scripted automation is much more powerful than the DSL and can do anything that an addon can do.

If a rule is not enough, this does not sound to me like it would fit as a binding. In OH 3.0 though, it looks like a new “automation” category will be added for add-ons, which may be more fitting.

1 Like

The goal is to interconnect all selected devices and to determine a flexible and continuously self-updating policy or “set of rules”. Basis for those rules will be data gathered by other devices which will adjust thresholds.
Alright, I will look into the scripted automation, thx for the hint.

Yes, indeed OH3.0 would fit better but unfortunately this ain’t a private project and it’s time constrained.

Your description is cryptic, but almost sounds like…

I’ve made it half through - with binding which acts on top of items. If is something reserved for rules and considered an antipattern by official guides: https://github.com/ConnectorIO/connectorio-addons/tree/master/binding/compute/efficiency

Its doable.


If I understand you correctly, you are wanting to be able to get/set state for other things from a thing right (as opposed to rules)?

I did that in the NEEO stuff (examples: simple and more complicated). That binding essentially allows you to add any openHAB thing/channels to a separate hardware platform (NEEO Brain) and receive/send state updates from it.

To send state - you essentially create a command (note: be careful of trigger vs command items - see more complicated example) and then post the command via the event publisher (pretty much what a rule does). To get state - you get the item from the registry and then get it’s state. To receive state as it comes, you subscribe to events from the event publisher and handle them (the more complicated version shows that a bit).

1 Like