Invocation of handleCommand() before initializing has finished

I observed that Thing.handleCommand() can be invoked, before Thing.initialize() has been finished.

From the binding developer perspective, I find this a bit unintuitive. Is this intended behavior? I would expect that a Thing is only started to be used, when it has finished initializing.

According to my understanding of https://www.openhab.org/docs/developer/bindings/#the-thinghandler the thing handler signals „initialized“ by setting the thing status to UNKNOWN, ONLINE or OFFLINE. This is a sort of „ready to process commands“. So the thing handler of a thing that is still in UNINITIALIZED or INITIALIZING should not receive commands.

If it does, it is a bug. Can you show the code that produces this problems?

That’s embarrassing. I should have read the documentation more accurately. updateStatus(ThingStatus.UNKNOWN) was called to early in my initialize() and after that handleCommand() can be invoked by the framework.

2 Likes