Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set 'UNINITIALIZED' -> 'HANDLER_MISSING_ERROR' after enabling a thing and handler / factory is missing #1243

Merged
merged 1 commit into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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