Migrating Jython scripts to openHAB4

In one of my scripts I am using the astro binding and thus I am verifyiing that the binding is there:

bindingRegistryInfo = get_service("org.openhab.core.binding.BindingInfoRegistry") or get_service("org.eclipse.smarthome.core.binding.BindingInfoRegistry")

After migrating to openHAB4 I now see that bindingRegistryInfo is None, but Astro binding is installed.
I was wondering if the namespace had changed, but couldn’t find anything regarding this in the discussions / release notes.
Can anybody point me in direction of what I am missing here?

I think this was replaced by the AddonInfoRegistry in openHAB 4:

1 Like

Thanks I will have a look at it :slight_smile:

It seems like it works, but I suspect that there is an error in ther call to getAddonInfo, as it returns None but if I loop all installed bindings it finds the Astro Binding in the loop.

bindingInstalled = False
bindingId = 'astro'
addonRegistryInfo = get_service("org.openhab.core.addon.AddonInfoRegistry")
self.Logger().info('[EventManager::generateTrigger] Check Astro Addon status (openHAB4 namespace): {}'.format(addonRegistryInfo.getAddonInfo(bindingId)))
if (addonRegistryInfo.getAddonInfo(bindingId) is not None):
    bindingInstalled = True
else:
    addonInfos = addonRegistryInfo.getAddonInfos()    
    for addonInfo in addonInfos:
        if bindingId == addonInfo.getId():
            bindingInstalled = True
            self.Logger().info("[EventManager::generateTrigger] MATCHING BINDING FOUND")
            break

My log looks like this:

2023-08-17 11:34:16.067 [INFO ] [.jsr223.jython.eventmgr.EventManager] - [EventManager::generateTrigger] Check Astro Addon status (openHAB4 namespace): None
2023-08-17 11:34:16.070 [INFO ] [.jsr223.jython.eventmgr.EventManager] - [EventManager::generateTrigger] MATCHING BINDING FOUND'

Am I doing something wrong or is there a problem in the call to getAddonInfo()?

Does it work if you use binding-astro instead of astro ?

1 Like

Yes - then it works. Thanks for your help :slight_smile:

1 Like