mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Huami: Fix sending air quality index
This commit is contained in:
@@ -632,6 +632,26 @@ public class Weather {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAqiLevelString(int aqi) {
|
||||
// Uses the [2023 Plume index](https://plumelabs.files.wordpress.com/2023/06/plume_aqi_2023.pdf) as a reference
|
||||
if (aqi < 0) {
|
||||
return "(n/a)";
|
||||
}
|
||||
if (aqi < 20) {
|
||||
return "excellent";
|
||||
} else if (aqi < 50) {
|
||||
return "fair";
|
||||
} else if (aqi < 100) {
|
||||
return "poor";
|
||||
} else if (aqi < 150) {
|
||||
return "unhealthy";
|
||||
} else if (aqi < 250) {
|
||||
return "very unhealthy";
|
||||
} else {
|
||||
return "dangerous";
|
||||
}
|
||||
}
|
||||
|
||||
public static byte mapToZeTimeConditionOld(int openWeatherMapCondition) {
|
||||
/* deducted values:
|
||||
0 = partly cloudy
|
||||
|
||||
+3
-2
@@ -3173,7 +3173,8 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
TransactionBuilder builder;
|
||||
builder = performInitialized("Sending air quality index");
|
||||
int length = 8;
|
||||
String aqiString = "(n/a)";
|
||||
int aqi = weatherSpec.airQuality != null ? weatherSpec.airQuality.aqi : -1;
|
||||
String aqiString = Weather.getAqiLevelString(aqi);
|
||||
if (supportsConditionString) {
|
||||
length += aqiString.getBytes().length + 1;
|
||||
}
|
||||
@@ -3182,7 +3183,7 @@ public abstract class HuamiSupport extends AbstractBTLEDeviceSupport implements
|
||||
buf.put((byte) 4);
|
||||
buf.putInt(weatherSpec.timestamp);
|
||||
buf.put((byte) (tz_offset_hours * 4));
|
||||
buf.putShort((short) -1);
|
||||
buf.putShort((short) aqi);
|
||||
if (supportsConditionString) {
|
||||
buf.put(aqiString.getBytes());
|
||||
buf.put((byte) 0);
|
||||
|
||||
Reference in New Issue
Block a user