[tradfri] Fix NPE if gateway is unreachable (#9629)
Fixes #9628 Signed-off-by: Stefan Triller <github@stefantriller.de>
This commit is contained in:
parent
d3ae64140f
commit
572da80fd9
@ -66,6 +66,10 @@ public abstract class TradfriThingHandler extends BaseThingHandler implements Co
|
|||||||
this.id = getConfigAs(TradfriDeviceConfig.class).id;
|
this.id = getConfigAs(TradfriDeviceConfig.class).id;
|
||||||
TradfriGatewayHandler handler = (TradfriGatewayHandler) tradfriGateway.getHandler();
|
TradfriGatewayHandler handler = (TradfriGatewayHandler) tradfriGateway.getHandler();
|
||||||
|
|
||||||
|
active = true;
|
||||||
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
|
switch (tradfriGateway.getStatus()) {
|
||||||
|
case ONLINE:
|
||||||
String uriString = handler.getGatewayURI() + "/" + id;
|
String uriString = handler.getGatewayURI() + "/" + id;
|
||||||
try {
|
try {
|
||||||
URI uri = new URI(uriString);
|
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());
|
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
active = true;
|
|
||||||
updateStatus(ThingStatus.UNKNOWN);
|
|
||||||
switch (tradfriGateway.getStatus()) {
|
|
||||||
case ONLINE:
|
|
||||||
scheduler.schedule(() -> {
|
scheduler.schedule(() -> {
|
||||||
observeRelation = coapClient.startObserve(this);
|
observeRelation = coapClient.startObserve(this);
|
||||||
}, 3, TimeUnit.SECONDS);
|
}, 3, TimeUnit.SECONDS);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user