[tradfri] Fix NPE if gateway is unreachable (#9629)

Fixes #9628

Signed-off-by: Stefan Triller <github@stefantriller.de>
This commit is contained in:
t2000 2021-01-01 21:45:55 +01:00 committed by GitHub
parent d3ae64140f
commit 572da80fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -66,6 +66,10 @@ public abstract class TradfriThingHandler extends BaseThingHandler implements Co
this.id = getConfigAs(TradfriDeviceConfig.class).id;
TradfriGatewayHandler handler = (TradfriGatewayHandler) tradfriGateway.getHandler();
active = true;
updateStatus(ThingStatus.UNKNOWN);
switch (tradfriGateway.getStatus()) {
case ONLINE:
String uriString = handler.getGatewayURI() + "/" + id;
try {
URI uri = new URI(uriString);
@ -76,10 +80,7 @@ public abstract class TradfriThingHandler extends BaseThingHandler implements Co
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
return;
}
active = true;
updateStatus(ThingStatus.UNKNOWN);
switch (tradfriGateway.getStatus()) {
case ONLINE:
scheduler.schedule(() -> {
observeRelation = coapClient.startObserve(this);
}, 3, TimeUnit.SECONDS);