[Solved] OH 1.x binding run in OH2: refresh service is immediately stopped

As you may know, I developped a binding for Powermax alarm systems. The binding is working well in OH 1.8. When I run it in OH 2 beta 2, I encounter a strange behaviour during the starting process:

  • during the starting of my bundle, activate and deactivate are called TWICE very shortly. Is it normal ?
  • then the bundle is started. So I get a new call to activate. But one time again, deactivate is called immediately, with the result that the refresh service is run only one time.
  • As the refresh service is run once, my serial connection is correctly established and I can see that the bundle is correctly handling communications with my alarm system.

If the refresh service would not have been deactivated, I am almost sure that the binding would work well in opehNAB2.

@Kai: any idea why deactivate is called immediately after activate ?

I am curious to know if it is the only 1.x binding encountering this issue.

I have to mention that in older versions of OH2, it was working well.

Here are my log sequence:

2016-02-03 21:03:04.912 [DEBUG] [org.openhab.binding.powermax        ] - BundleEvent STARTING - org.openhab.binding.powermax
2016-02-03 21:03:04.916 [DEBUG] [.powermax.internal.PowerMaxActivator] - PowerMax binding has been started.
2016-02-03 21:03:04.950 [DEBUG] [org.openhab.binding.powermax        ] - ServiceEvent REGISTERED - {org.openhab.model.item.binding.BindingConfigReader, org.openhab.binding.powermax.PowerMaxBindingProvider}={component.name=org.openhab.binding.powermax.genericbindingprovider, component.id=168, service.id=281, service.bundleid=162, service.scope=bundle} - org.openhab.binding.powermax
2016-02-03 21:03:04.990 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Activate PowerMax alarm binding
2016-02-03 21:03:04.993 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Deactivate PowerMax alarm binding
2016-02-03 21:03:05.019 [DEBUG] [org.openhab.binding.powermax        ] - ServiceEvent REGISTERED - {org.osgi.service.event.EventHandler, org.osgi.service.cm.ManagedService}={event.topics=openhab/command/*, service.pid=org.openhab.powermax, component.name=org.openhab.binding.powermax.binding, component.id=167, service.id=283, service.bundleid=162, service.scope=bundle} - org.openhab.binding.powermax
2016-02-03 21:03:05.026 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Activate PowerMax alarm binding
2016-02-03 21:03:05.027 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Deactivate PowerMax alarm binding
2016-02-03 21:03:05.037 [DEBUG] [org.openhab.binding.powermax        ] - BundleEvent STARTED - org.openhab.binding.powermax

2016-02-03 21:03:07.840 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Activate PowerMax alarm binding
2016-02-03 21:03:07.845 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - PowerMax alarm binding: updating configuration
2016-02-03 21:03:07.874 [INFO ] [b.core.service.AbstractActiveService] - PowerMax Refresh Service has been started
2016-02-03 21:03:07.874 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - Deactivate PowerMax alarm binding
2016-02-03 21:03:07.879 [DEBUG] [ng.powermax.internal.PowerMaxBinding] - PowerMax alarm Execute

2016-02-03 21:03:28.639 [INFO ] [b.core.service.AbstractActiveService] - PowerMax Refresh Service has been shut down
1 Like

Set immediate="true" in your OSGi XML file like was done to other bindings so they stay active under Karaf.

@watou: of course !!! I am a stupid man ! I have already forgotten that !

1 Like

Yes, it was the problem. Setting immediate=true makes the binding working well in OH2.
I am happy.