[airquality] Switch API access from http to https (#19472)

Resolves #19461

Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
Gaël L'hopital
2025-10-12 17:42:03 +02:00
committed by GitHub
parent 32a7c33e95
commit 30446cf1f6
2 changed files with 4 additions and 4 deletions
@@ -36,7 +36,7 @@ import com.google.gson.JsonSyntaxException;
@NonNullByDefault
public class ApiBridge {
private static final Gson GSON = new Gson();
private static final String URL = "http://api.waqi.info/feed/%query%/?token=%apiKey%";
private static final String URL = "https://api.waqi.info/feed/%query%/?token=%apiKey%";
private static final int REQUEST_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30);
private final Logger logger = LoggerFactory.getLogger(ApiBridge.class);
@@ -53,8 +53,8 @@ public class ApiBridge {
* @throws AirQualityException
*/
private String buildRequestURL(String key, int stationId, String location) {
String geoStr = stationId != 0 ? String.format("@%d", stationId)
: String.format("geo:%s",
String geoStr = stationId != 0 ? "@%d".formatted(stationId)
: "geo:%s".formatted(
location.replace(" ", "").replace(",", ";").replace("\"", "").replace("'", "").trim());
return URL.replace("%apiKey%", key).replace("%query%", geoStr);
@@ -69,7 +69,7 @@ public class AirQualityDiscoveryService extends AbstractThingHandlerDiscoverySer
if (provider != null) {
PointType location = provider.getLocation();
AirQualityBridgeHandler bridge = this.thingHandler;
if (location == null || bridge == null) {
if (location == null) {
logger.info("openHAB server location is not defined, will not provide any discovery results");
return;
}