mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-25 16:15:55 +01:00
Xiaomi: Weather fixes and Implement wind and AQI
Many fields were incorrectly being sent as uint32 instead of sint32. This caused issues with forecast icons.
This commit is contained in:
parent
cb7121a32e
commit
372aa88e6e
@ -111,13 +111,13 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
|
|||||||
.setHumidity(weatherSpec.currentHumidity)
|
.setHumidity(weatherSpec.currentHumidity)
|
||||||
.setSymbol("%")
|
.setSymbol("%")
|
||||||
)
|
)
|
||||||
.setUnk5(XiaomiProto.WeatherCurrentUnk5.newBuilder()
|
.setWind(XiaomiProto.WeatherCurrentWind.newBuilder()
|
||||||
.setUnk1("")
|
.setWind(weatherSpec.windSpeedAsBeaufort())
|
||||||
.setUnk2(0)
|
.setSymbol("")
|
||||||
)
|
)
|
||||||
.setUnk6(XiaomiProto.WeatherCurrentUnk6.newBuilder()
|
.setUv(XiaomiProto.WeatherCurrentUVIndex.newBuilder()
|
||||||
.setUnk1("")
|
.setUnk1("")
|
||||||
.setUnk2(0)
|
.setIndex(Math.round(weatherSpec.uvIndex)) // This is sent as an sint but seems to be displayed with a decimal point
|
||||||
)
|
)
|
||||||
.setAQI(XiaomiProto.WeatherCurrentAQI.newBuilder()
|
.setAQI(XiaomiProto.WeatherCurrentAQI.newBuilder()
|
||||||
.setAQIText("Unknown") // some string like "Moderate"
|
.setAQIText("Unknown") // some string like "Moderate"
|
||||||
@ -139,10 +139,12 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
|
|||||||
XiaomiProto.WeatherDailyList.Builder dailyListBuilder = XiaomiProto.WeatherDailyList.newBuilder();
|
XiaomiProto.WeatherDailyList.Builder dailyListBuilder = XiaomiProto.WeatherDailyList.newBuilder();
|
||||||
int daysToSend = Math.min(7, weatherSpec.forecasts.size());
|
int daysToSend = Math.min(7, weatherSpec.forecasts.size());
|
||||||
for (int i = 0; i < daysToSend; i++) {
|
for (int i = 0; i < daysToSend; i++) {
|
||||||
|
WeatherSpec.AirQuality airQuality = weatherSpec.forecasts.get(i).airQuality;
|
||||||
|
|
||||||
dailyListBuilder.addForecastDay(XiaomiProto.WeatherDailyForecastDay.newBuilder()
|
dailyListBuilder.addForecastDay(XiaomiProto.WeatherDailyForecastDay.newBuilder()
|
||||||
.setUnk1(XiaomiProto.DailyUnk1.newBuilder()
|
.setAQI(XiaomiProto.DailyAQI.newBuilder()
|
||||||
.setUnk1("")
|
.setAQIText("")
|
||||||
.setUnk2(0)
|
.setAQI(airQuality != null && airQuality.aqi >= 0 ? airQuality.aqi : 0)
|
||||||
)
|
)
|
||||||
.setUnk2(XiaomiProto.DailyUnk2.newBuilder()
|
.setUnk2(XiaomiProto.DailyUnk2.newBuilder()
|
||||||
.setUnk1(HuamiWeatherConditions.mapToAmazfitBipWeatherCode(weatherSpec.forecasts.get(i).conditionCode)) // TODO: verify
|
.setUnk1(HuamiWeatherConditions.mapToAmazfitBipWeatherCode(weatherSpec.forecasts.get(i).conditionCode)) // TODO: verify
|
||||||
|
@ -752,8 +752,8 @@ message WeatherCurrent {
|
|||||||
optional uint32 weatherCondition = 2;
|
optional uint32 weatherCondition = 2;
|
||||||
optional WeatherCurrentTemperature temperature = 3;
|
optional WeatherCurrentTemperature temperature = 3;
|
||||||
optional WeatherCurrentHumidity humidity= 4;
|
optional WeatherCurrentHumidity humidity= 4;
|
||||||
optional WeatherCurrentUnk5 unk5 = 5;
|
optional WeatherCurrentWind wind = 5;
|
||||||
optional WeatherCurrentUnk6 unk6 = 6;
|
optional WeatherCurrentUVIndex uv = 6;
|
||||||
optional WeatherCurrentAQI AQI = 7;
|
optional WeatherCurrentAQI AQI = 7;
|
||||||
optional WeatherCurrentWarning warning = 8; // Seems to be an array?
|
optional WeatherCurrentWarning warning = 8; // Seems to be an array?
|
||||||
optional float pressure = 9;
|
optional float pressure = 9;
|
||||||
@ -776,14 +776,14 @@ message WeatherCurrentHumidity {
|
|||||||
optional sint32 humidity = 2;
|
optional sint32 humidity = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message WeatherCurrentUnk5 {
|
message WeatherCurrentWind {
|
||||||
optional string unk1 = 1;
|
optional string symbol = 1;
|
||||||
optional uint32 unk2 = 2;
|
optional sint32 wind = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message WeatherCurrentUnk6 {
|
message WeatherCurrentUVIndex {
|
||||||
optional string unk1 = 1;
|
optional string unk1 = 1;
|
||||||
optional uint32 unk2 = 2;
|
optional sint32 index = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message WeatherCurrentAQI {
|
message WeatherCurrentAQI {
|
||||||
@ -817,21 +817,21 @@ message WeatherDailyList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message WeatherDailyForecastDay {
|
message WeatherDailyForecastDay {
|
||||||
optional DailyUnk1 unk1 = 1;
|
optional DailyAQI AQI = 1;
|
||||||
optional DailyUnk2 unk2 = 2;
|
optional DailyUnk2 unk2 = 2;
|
||||||
optional DailyHighLowTemp highLowTemp = 3;
|
optional DailyHighLowTemp highLowTemp = 3;
|
||||||
optional string temperatureSymbol = 4;
|
optional string temperatureSymbol = 4;
|
||||||
optional DailySunriseSunset sunriseSunset = 5;
|
optional DailySunriseSunset sunriseSunset = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DailyUnk1 {
|
message DailyAQI {
|
||||||
optional string unk1 = 1;
|
optional string AQIText = 1;
|
||||||
optional uint32 unk2 = 2;
|
optional sint32 AQI = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DailyUnk2 {
|
message DailyUnk2 {
|
||||||
optional uint32 unk1 = 1;
|
optional sint32 unk1 = 1;
|
||||||
optional uint32 unk2 = 2;
|
optional sint32 unk2 = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DailyHighLowTemp {
|
message DailyHighLowTemp {
|
||||||
|
Loading…
Reference in New Issue
Block a user