smarthomej / addons

SmartHome/J addons for openHAB
Eclipse Public License 2.0
59 stars 23 forks source link

Expose ItemChannelLinkRegistry in JavaRule #406

Closed lordjaxom closed 1 year ago

lordjaxom commented 1 year ago

While trying to debug a problem where some of my rules don't work on all items on a group (which of course only happens when I am not there to observe), I would like to log if any of the group's member's things are offline at that point in time. For that I would go over the members of the group and get the linked things via the ItemChannelLinkRegistry. Would it be possible to expose that in JavaRule, like with the ItemRegistry and ThingRegistry?

J-N-K commented 1 year ago

Did you try to get it yourself with something like

ItemChannelLinkRegistry iclr = FrameworkUtil.getBundle(ItemChannelLinkRegistry.class).getBundleContext().getServiceReferences(
                ItemChannelLinkRegistry.class, null).stream().findFirst().map(bundleContext::getService).orElse(null);
lordjaxom commented 1 year ago

No I didn't. I wasn't aware that it is possible to dive into the framework at this level.

Would it also be possible to register new services, i.e. a transformation service, within a JavaRule?

(Issue can be closed, except you'd like to provide the registry as a convenience of course)

lordjaxom commented 1 year ago

@J-N-K However, I've had to add osgi.core to my project's dependencies manually, since FrameworkUtil (and others) is not exposed via core-dependencies.