Skip to content

Commit

Permalink
Set UNINITIALIZED -> HANDLER_MISSING_ERROR after enabling a Thing and…
Browse files Browse the repository at this point in the history
… handler is missing (#1243)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp authored and kaikreuzer committed Nov 28, 2019
1 parent c50766d commit 0046774
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -1057,7 +1057,7 @@ private void registerAndInitializeHandler(final Thing thing, final ThingHandlerF
initializeHandler(thing);
} else {
logger.debug(
"Not registering a handler at this point. The thing types of bundle {} are not fully loaded yet.",
"Not registering a handler at this point. The thing types of bundle '{}' are not fully loaded yet.",
identifier);
}
} else {
Expand Down Expand Up @@ -1214,6 +1214,11 @@ public void setEnabled(ThingUID thingUID, boolean enabled) {
} else {
// No handler registered. Try to register handler and initialize the thing.
registerAndInitializeHandler(thing, findThingHandlerFactory(thing.getThingTypeUID()));
// Check if registration was successful
if (!hasBridge(thing) && !isHandlerRegistered(thing)) {
setThingStatus(thing,
buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_MISSING_ERROR));
}
}
} else {
if (!thing.isEnabled()) {
Expand Down
Expand Up @@ -683,7 +683,7 @@ public void testSetEnabledWithoutHandlerFactory() throws Exception {
waitForAssert(() -> {
assertThat(storage.containsKey(THING_UID.getAsString()), is(false));
assertThat(thing.getStatus(), is(ThingStatus.UNINITIALIZED));
assertThat(thing.getStatusInfo().getStatusDetail(), is(ThingStatusDetail.DISABLED));
assertThat(thing.getStatusInfo().getStatusDetail(), is(ThingStatusDetail.HANDLER_MISSING_ERROR));
}, SafeCaller.DEFAULT_TIMEOUT - 100, 50);
}

Expand Down

0 comments on commit 0046774

Please sign in to comment.