Zepp OS: Fix setting of unknown button press apps

This commit is contained in:
José Rebelo 2023-10-06 21:52:09 +01:00
parent be07545eca
commit fe9b88df17

View File

@ -574,7 +574,21 @@ public class ZeppOsConfigService extends AbstractZeppOsService {
switch (configArg) {
case UPPER_BUTTON_LONG_PRESS:
case LOWER_BUTTON_PRESS:
return MapUtils.reverse(Huami2021MenuType.displayItemNameLookup).get(value);
final String itemHex = MapUtils.reverse(Huami2021MenuType.displayItemNameLookup).get(value);
if (itemHex != null) {
return itemHex;
}
// Unknown button press value - attempt to parse it as hex
final Matcher matcher = Pattern.compile("^([0-9A-F]{8})$").matcher(value);
if (matcher.matches()) {
LOG.debug("Sending unknown button press item {} as hex", value);
return value;
}
LOG.warn("Failed to map button press value {}", value);
return null;
case DATE_FORMAT:
return value.replace("/", ".");
}