1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Xiaomi: fix NPE when no air quality is available

This commit is contained in:
Andreas Shimokawa 2023-10-25 18:17:10 +02:00 committed by José Rebelo
parent 0e3e406320
commit e2f60b38c9

View File

@ -105,7 +105,7 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
)
.setAQI(XiaomiProto.WeatherCurrentAQI.newBuilder()
.setAQIText("Unknown") // some string like "Moderate"
.setAQI(weatherSpec.airQuality.aqi)
.setAQI(weatherSpec.airQuality != null && weatherSpec.airQuality.aqi >=0 ? weatherSpec.airQuality.aqi : 0)
)
.setWarning(XiaomiProto.WeatherCurrentWarning.newBuilder()
.setCurrentWarning1(XiaomiProto.WeatherCurrentWarning1.newBuilder()