Huawei: extend weather

This commit is contained in:
Me7c7
2025-10-02 19:44:28 +03:00
parent 186550df84
commit d9cfcc025e
5 changed files with 38 additions and 2 deletions
@@ -638,6 +638,10 @@ public class HuaweiCoordinator {
return supportsExpandCapability(0x2f);
}
public boolean supportsWeatherExtendedHourForecast() {
return supportsExpandCapability(0xc0);
}
public boolean supportsWorkouts() {
return supportsCommandForService(0x17, 0x01);
}
@@ -43,6 +43,7 @@ public class Weather {
public boolean timeSupported = false;
public boolean sourceSupported = false;
public boolean weatherIconSupported = false;
public boolean extendedHourlyForecast = false;
// WeatherSunMoonSupport
public boolean sunRiseSetSupported = false;
@@ -382,7 +383,10 @@ public class Weather {
Short airQualityIndex,
Integer observationTime,
Float uvIndex,
String sourceName
String sourceName,
Byte humidity,
Integer windSpeedValue,
Integer feelLikeTemperature
) {
super(paramsProvider);
@@ -438,6 +442,16 @@ public class Weather {
if (uvIndex != null && settings.uvIndexSupported)
this.tlv.put(0x0f, uvIndex.byteValue());
if(settings.extendedHourlyForecast) {
if(humidity != null)
this.tlv.put(0x10, humidity);
if(windSpeedValue != null)
this.tlv.put(0x11, windSpeedValue);
if(feelLikeTemperature != null)
this.tlv.put(0x12, feelLikeTemperature);
}
this.isEncrypted = true;
this.complete = true;
}
@@ -586,6 +600,8 @@ public class Weather {
public int timestamp;
public WeatherIcon icon;
public Byte temperature;
public Byte precipitation;
public Byte uvIndex;
@NonNull
@Override
@@ -596,6 +612,8 @@ public class Weather {
", timestamp=" + timestampStr +
", icon=" + icon +
", temperature=" + temperature +
", precipitation=" + precipitation +
", uvIndex=" + uvIndex +
'}';
}
}
@@ -652,6 +670,14 @@ public class Weather {
timeTlv.put(0x04, iconToByte(timeData.icon));
if (timeData.temperature != null && (settings.temperatureSupported || settings.currentTemperatureSupported))
timeTlv.put(0x05, timeData.temperature);
if(settings.extendedHourlyForecast) {
if (timeData.precipitation != null) {
timeTlv.put(0x06, timeData.precipitation);
}
if (timeData.uvIndex != null) {
timeTlv.put(0x07, timeData.uvIndex);
}
}
timeDataTlv.put(0x82, timeTlv);
}
this.tlv.put(0x81, timeDataTlv);
@@ -227,6 +227,7 @@ public class HuaweiWeatherManager {
Weather.Settings weatherSettings = new Weather.Settings();
weatherSettings.uvIndexSupported = supportProvider.getHuaweiCoordinator().supportsWeatherUvIndex();
weatherSettings.extendedHourlyForecast = supportProvider.getHuaweiCoordinator().supportsWeatherExtendedHourForecast();
SendWeatherStartRequest weatherStartRequest = new SendWeatherStartRequest(supportProvider, weatherSettings);
weatherStartRequest.setFinalizeReq(errorHandler);
@@ -66,7 +66,10 @@ public class SendWeatherCurrentRequest extends Request {
aqi,
weatherSpec.getTimestamp(),
weatherSpec.getUvIndex(),
"Gadgetbridge"
"Gadgetbridge",
(byte) weatherSpec.getCurrentHumidity(),
(int) weatherSpec.getWindSpeed(),
(weatherSpec.getFeelsLikeTemp() - 273)
).serialize();
} catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e);
@@ -50,6 +50,8 @@ public class SendWeatherForecastRequest extends Request {
timeData.timestamp = hourly.getTimestamp();
timeData.icon = supportProvider.openWeatherMapConditionCodeToHuaweiIcon(hourly.getConditionCode());
timeData.temperature = (byte) (hourly.getTemp() - 273);
timeData.precipitation = (byte) hourly.getPrecipProbability();
timeData.uvIndex = (byte) hourly.getUvIndex();
timeDataArrayList.add(timeData);
}