Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# HAP-Java 2.0.6
* Several methods allowing library users to manipulate characteristics themselves
* Allow library users to provider their own implementation of AccessoryInformationService
* Fix ProgrammableSwitchEventEnum that has an incorrect value

# HAP-Java 2.0.5
* Implement List-Pairings method. Compatibility with new Home infrastructure from iOS 16.2?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class EnumCharacteristic<T extends CharacteristicEnum>
extends BaseCharacteristic<Integer> {

private final T[] validValues;
Optional<Supplier<CompletableFuture<T>>> getter;
protected Optional<Supplier<CompletableFuture<T>>> getter;
protected Optional<ExceptionalConsumer<T>> setter;

/**
Expand Down Expand Up @@ -100,7 +100,16 @@ public CompletableFuture<Integer> getValue() {
if (!getter.isPresent()) {
return null;
}
return getter.get().get().thenApply(T::getCode);
return getter
.get()
.get()
.thenApply(
e -> {
if (e == null) {
return null;
}
return e.getCode();
});
}

public void setValue(T value) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public enum ProgrammableSwitchEnum implements CharacteristicEnum {
SINGLE_PRESS(0),
DOUBLE_PRESS(1),
LONG_PRESS(3);
LONG_PRESS(2);

private static final Map<Integer, ProgrammableSwitchEnum> reverse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,18 @@ public ProgrammableSwitchEventCharacteristic(
Supplier<CompletableFuture<ProgrammableSwitchEnum>> getter,
Consumer<HomekitCharacteristicChangeCallback> subscriber,
Runnable unsubscriber) {
this(ProgrammableSwitchEnum.values(), getter, subscriber, unsubscriber);
}

public ProgrammableSwitchEventCharacteristic(
ProgrammableSwitchEnum[] validValues,
Supplier<CompletableFuture<ProgrammableSwitchEnum>> getter,
Consumer<HomekitCharacteristicChangeCallback> subscriber,
Runnable unsubscriber) {
super(
"00000073-0000-1000-8000-0026BB765291",
"Switch Event",
ProgrammableSwitchEnum.values(),
validValues,
Optional.of(getter),
Optional.empty(),
Optional.of(subscriber),
Expand Down