From 38271f28029a4f97c18ab98c7e5f3dc668f55884 Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Sat, 9 Oct 2021 19:58:08 +0200 Subject: [PATCH] [openweathermap] Bridge status set to UNKNOWN when no attached things Fix #11191 Signed-off-by: Laurent Garnier --- .../internal/handler/OpenWeatherMapAPIHandler.java | 8 ++++++++ .../main/resources/OH-INF/i18n/openweathermap.properties | 2 ++ .../resources/OH-INF/i18n/openweathermap_de.properties | 2 ++ .../resources/OH-INF/i18n/openweathermap_fr.properties | 2 ++ 4 files changed, 14 insertions(+) diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapAPIHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapAPIHandler.java index 644065d1473fc..7a5279a25fe7c 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapAPIHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapAPIHandler.java @@ -151,6 +151,10 @@ public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) { } private void determineBridgeStatus() { + if (getThing().getThings().size() == 0) { + updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "@text/unknown.waiting-for-things-setup"); + return; + } ThingStatus status = ThingStatus.OFFLINE; for (Thing thing : getThing().getThings()) { if (ThingStatus.ONLINE.equals(thing.getStatus())) { @@ -162,6 +166,10 @@ private void determineBridgeStatus() { } private void updateThings() { + if (getThing().getThings().size() == 0) { + updateStatus(ThingStatus.UNKNOWN, ThingStatusDetail.NONE, "@text/unknown.waiting-for-things-setup"); + return; + } ThingStatus status = ThingStatus.OFFLINE; for (Thing thing : getThing().getThings()) { if (ThingStatus.ONLINE.equals(updateThing((AbstractOpenWeatherMapHandler) thing.getHandler(), thing))) { diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties index 8e01970181261..bc021163b0bdb 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties @@ -485,6 +485,8 @@ offline.conf-error-not-supported-onecall-number-of-hours = The 'forecastHours' p offline.conf-error-not-supported-onecall-number-of-days = The 'forecastDays' parameter must be between 0 and 7. offline.conf-error-not-supported-onecall-number-of-alerts = The 'numberOfAlerts' parameter must be greater than or equals to 0. +unknown.waiting-for-things-setup = Waiting for setup of at least one thing. + # discovery result discovery.openweathermap.weather-and-forecast.api.local.label = Local Weather And Forecast discovery.openweathermap.air-pollution.api.local.label = Local Air Pollution diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_de.properties b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_de.properties index 78b315aa30593..23e6568eb7d5c 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_de.properties +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_de.properties @@ -423,6 +423,8 @@ offline.conf-error-not-supported-onecall-number-of-hours = Der Parameter 'foreca offline.conf-error-not-supported-onecall-number-of-days = Der Parameter 'forecastDays' muss zwischen 0 und 7 liegen. offline.conf-error-not-supported-onecall-number-of-alerts = Der Parameter 'numberOfAlerts' muss größer oder gleich 0 sein. +unknown.waiting-for-things-setup = Warten auf Einrichtung von mindestens einer Sache. + # discovery result discovery.openweathermap.weather-and-forecast.api.local.label = Lokales Wetter und Wettervorhersage discovery.openweathermap.air-pollution.api.local.label = Lokale Luftqualität diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_fr.properties b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_fr.properties index 1ebe61246a8d5..745030063a58f 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_fr.properties +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap_fr.properties @@ -256,6 +256,8 @@ offline.conf-error-not-supported-onecall-number-of-minutes = Le paramètre 'fore offline.conf-error-not-supported-onecall-number-of-hours = Le paramètre 'forecastHours' doit être compris entre 0 et 48. offline.conf-error-not-supported-onecall-number-of-days = Le paramètre 'forecastDays' doit être compris entre 0 et 7. +unknown.waiting-for-things-setup = En attente de la configuration d''au moins une "thing". + # discovery result discovery.openweathermap.weather-and-forecast.api.local.label = Météo locale et prévisions discovery.openweathermap.uvindex.api.local.label = Indice UV local