[openweathermap] Bridge status set to ONLINE when no attached things (#11360)

Fix #11191

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2021-10-11 13:15:46 +02:00 committed by GitHub
parent 22e8a37ee9
commit 60b4dad600
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 9 deletions

View File

@ -14,6 +14,7 @@ package org.openhab.binding.openweathermap.internal.handler;
import static org.openhab.binding.openweathermap.internal.OpenWeatherMapBindingConstants.*;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@ -151,23 +152,31 @@ public class OpenWeatherMapAPIHandler extends BaseBridgeHandler {
}
private void determineBridgeStatus() {
ThingStatus status = ThingStatus.OFFLINE;
for (Thing thing : getThing().getThings()) {
ThingStatus status = ThingStatus.ONLINE;
List<Thing> childs = getThing().getThings();
if (!childs.isEmpty()) {
status = ThingStatus.OFFLINE;
for (Thing thing : childs) {
if (ThingStatus.ONLINE.equals(thing.getStatus())) {
status = ThingStatus.ONLINE;
break;
}
}
}
updateStatus(status);
}
private void updateThings() {
ThingStatus status = ThingStatus.OFFLINE;
for (Thing thing : getThing().getThings()) {
ThingStatus status = ThingStatus.ONLINE;
List<Thing> childs = getThing().getThings();
if (!childs.isEmpty()) {
status = ThingStatus.OFFLINE;
for (Thing thing : childs) {
if (ThingStatus.ONLINE.equals(updateThing((AbstractOpenWeatherMapHandler) thing.getHandler(), thing))) {
status = ThingStatus.ONLINE;
}
}
}
updateStatus(status);
}