openhab-core
openhab-core copied to clipboard
Thing manager logic causes things to stuck in NOT_YET_READY
I'm in process of updating bindings to OH 4 and spotted a bug, which I believe is related to new logic which improves reliability and predictability of thing startup process.
Bindings I have are rather basic in their form, one which I test with use no dynamic (generated) channels or thing types. Its entirely provided through XML descriptors. However, OH 4.0 makes it stuck in "NOT_YET_READY" state, despite of all descriptors being available and valid.
Expected Behavior
Valid thing types should cause handlers to be initialized.
Current Behavior
Despite of thing descriptors being properly parsed and available thing is marked as not ready, because its handler is refused.
I've traced it to a logic which populated "missing prerequisites". It turns that this collection is being feed in few places, but released only in one. This means that depending on startup order (and performance of machine), some handlers may never be used, because thing manager will miss opportunity to remove missing prerequisites, even if these conditions are met.
Please see below screenshot where missing prerequisites contains co7io-amsads:network, but thing thing type is already registered in appropriate registry:
Steps to Reproduce (for Bugs)
So far I was not able to get a reproducer, as it is strictly speaking, dependent to startup order. If thing is added before thing descriptor is parsed - there is high probability that ThingManager will never update solved prerequisites.
Your Environment
- openHAB 4.0.3
- JVM Temurin 17
- Linux 6.5
This issue has been mentioned on openHAB Community. There might be relevant details there:
https://community.openhab.org/t/creating-a-new-thing-in-own-developed-binding-works-but-after-restart-of-demo-app-the-thing-is-missing-the-thinghandler/159325/8
@J-N-K : maybe it "talks" to you?
I wonder why addThingHandlerFactory does not properly remove the missing thingType from the ThingPrerequisites. Can you enable debug logging for the ThingManagerImpl and see in which order the things and the thing handler factory get added?