Skip to content

Commit

Permalink
[openweathermap] Bridge status set to ONLINE when no attached things (o…
Browse files Browse the repository at this point in the history
…penhab#11360)

Fix openhab#11191

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Dave J Schoepel <dave@theschoepels.com>
  • Loading branch information
lolodomo authored and dschoepel committed Nov 9, 2021
1 parent 6940085 commit e36d22b
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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;
Expand Down Expand Up @@ -151,21 +152,29 @@ public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
}

private void determineBridgeStatus() {
ThingStatus status = ThingStatus.OFFLINE;
for (Thing thing : getThing().getThings()) {
if (ThingStatus.ONLINE.equals(thing.getStatus())) {
status = ThingStatus.ONLINE;
break;
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()) {
if (ThingStatus.ONLINE.equals(updateThing((AbstractOpenWeatherMapHandler) thing.getHandler(), thing))) {
status = ThingStatus.ONLINE;
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);
Expand Down

0 comments on commit e36d22b

Please sign in to comment.