1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-09 03:37:03 +01:00

Huawei: Fix for weather

- Also the sunrise/set cannot be zero
- We could send a single forecast more when exactly 7 are provided
- It seems like the watches may require exactly 8 days to be sent for
  the forecast - one of which is for today
This commit is contained in:
Martin.JM 2024-07-28 20:33:31 +02:00
parent ecda7b9f78
commit 2dbf70cb77
2 changed files with 3 additions and 3 deletions

View File

@ -628,9 +628,9 @@ public class Weather {
dayTlv.put(0x15, dayData.lowTemperature);
}
if (settings.sunRiseSetSupported) {
if (dayData.sunriseTime != null)
if (dayData.sunriseTime != null && dayData.sunriseTime != 0)
dayTlv.put(0x16, dayData.sunriseTime);
if (dayData.sunsetTime != null)
if (dayData.sunsetTime != null && dayData.sunsetTime != 0)
dayTlv.put(0x17, dayData.sunsetTime);
if (dayData.moonRiseTime != null && dayData.moonRiseTime != 0)
dayTlv.put(0x1a, dayData.moonRiseTime);

View File

@ -40,7 +40,7 @@ public class SendWeatherForecastRequest extends Request {
@Override
protected List<byte[]> createRequest() throws RequestCreationException {
int hourlyCount = Math.min(weatherSpec.hourly.size(), 24);
int dayCount = Math.min(weatherSpec.forecasts.size(), 8);
int dayCount = Math.min(weatherSpec.forecasts.size() + 1, 8); // We add today as well
ArrayList<WeatherForecastData.TimeData> timeDataArrayList = new ArrayList<>(hourlyCount);
ArrayList<WeatherForecastData.DayData> dayDataArrayList = new ArrayList<>(dayCount);