mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
Mi Band 8: Fix weather (set current location)
This commit is contained in:
parent
50f086b03a
commit
ff2a26756f
@ -491,4 +491,8 @@ public abstract class XiaomiCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
public AbstractNotificationPattern[] getNotificationLedPatterns() {
|
||||
return new AbstractNotificationPattern[0];
|
||||
}
|
||||
|
||||
public boolean supportsMultipleWeatherLocations() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -55,4 +55,9 @@ public class MiBand8Coordinator extends XiaomiEncryptedCoordinator {
|
||||
public int getDisabledIconResource() {
|
||||
return R.drawable.ic_device_miband6_disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsMultipleWeatherLocations() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import java.util.Locale;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiWeatherConditions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.xiaomi.XiaomiCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.proto.xiaomi.XiaomiProto;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi.XiaomiSupport;
|
||||
@ -37,6 +38,7 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
|
||||
private static final int CMD_TEMPERATURE_UNIT_SET = 10;
|
||||
private static final int CMD_SET_CURRENT_WEATHER = 0;
|
||||
private static final int CMD_SET_DAILY_WEATHER = 1;
|
||||
private static final int CMD_SET_CURRENT_LOCATION = 6;
|
||||
|
||||
public XiaomiWeatherService(final XiaomiSupport support) {
|
||||
super(support);
|
||||
@ -66,6 +68,26 @@ public class XiaomiWeatherService extends AbstractXiaomiService {
|
||||
public void onSendWeather(final WeatherSpec weatherSpec) {
|
||||
String timestamp = unixTimetstampToISOWithColons(weatherSpec.timestamp);
|
||||
|
||||
final XiaomiCoordinator coordinator = getSupport().getCoordinator();
|
||||
|
||||
if (coordinator.supportsMultipleWeatherLocations()) {
|
||||
// TODO actually support multiple locations
|
||||
getSupport().sendCommand(
|
||||
"set current location",
|
||||
XiaomiProto.Command.newBuilder()
|
||||
.setType(COMMAND_TYPE)
|
||||
.setSubtype(CMD_SET_CURRENT_LOCATION)
|
||||
.setWeather(XiaomiProto.Weather.newBuilder().setCurrentLocation(
|
||||
XiaomiProto.WeatherCurrentLocation.newBuilder()
|
||||
.setLocation(XiaomiProto.WeatherLocation.newBuilder()
|
||||
.setCode("accu:123456") // FIXME:AccuWeather code (we do not have it here)
|
||||
.setName(weatherSpec.location)
|
||||
)
|
||||
))
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
getSupport().sendCommand(
|
||||
"set current weather",
|
||||
XiaomiProto.Command.newBuilder()
|
||||
|
Loading…
Reference in New Issue
Block a user