Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* Valid values are supported for enum characteristics instead of min and max values
* Supported valid states for Thermostat, SecuritySystem, HeaterCooler and HumidifierDehumidifier [#108] [#120](https://github.com/hap-java/HAP-Java/pull/120)
* Support for FilterMaintenance. Can be used as a linked service for an Air Purifier [#124](https://github.com/hap-java/HAP-Java/pull/124)

# HAP-Java 1.1.5

Expand All @@ -27,6 +28,7 @@
* Fix various spec violations and optimize communications to improve performance [#65](https://github.com/hap-java/HAP-Java/pull/65)
* Fix a pairing issue in which HAP-Java could listen on a different interface than that which it advertises [#67](https://github.com/hap-java/HAP-Java/pull/67)
* Allow window covering to be used without optional characteristics. The inclusion of `HoldPositionCharacteristic` did terrible things, and we're still not sure why. Addressed [#56](https://github.com/hap-java/HAP-Java/pull/56)
* Air Purifier didn't support rotation speed characteristics. [#124](https://github.com/hap-java/HAP-Java/pull/124)

## New and improved

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ After that, check out the [Sample](https://github.com/hap-java/HAP-Java/tree/sam
Supported HomeKit Accessories
=========

Current implementation fully supports 37 HomeKit accessory/services.
Current implementation fully supports 38 HomeKit accessory/services.

| HomeKit Accessory & Service type | Supported by Java-HAP |
|--------------------|--------------------|
Expand All @@ -41,7 +41,7 @@ Current implementation fully supports 37 HomeKit accessory/services.
| Doorbell | :white_check_mark: |
| Fan | :white_check_mark: |
| Faucet | :white_check_mark: |
| Filter Maintenance | :x: |
| Filter Maintenance | :white_check_mark: |
| Garage Door Opener | :white_check_mark: |
| HAP Protocol Information | :white_check_mark: |
| Heater Cooler | :white_check_mark: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,23 @@ public interface AirPurifierAccessory extends HomekitAccessory {
/** Unsubscribes from changes in the target state of the air purifier. */
void unsubscribeTargetState();

/**
* If a filter maintenance service is needed as a linked service to this AirPurifier, this is the
* place.
*
* @return an instance of FilterMaintenanceAccessory, null if not needed.
*/
default FilterMaintenanceAccessory getFilterMaintenanceAccessory() {
return null;
};

@Override
default Collection<Service> getServices() {
return Collections.singleton(new AirPurifierService(this));
AirPurifierService service = new AirPurifierService(this);
FilterMaintenanceAccessory fmAccessory = this.getFilterMaintenanceAccessory();
if (fmAccessory != null) {
service.addLinkedService(fmAccessory.getPrimaryService());
}
return Collections.singleton(service);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ protected CompletableFuture<JsonObjectBuilder> makeBuilder(int iid) {
return super.makeBuilder(iid)
.thenApply(
builder -> {
return builder
.add("minValue", minValue)
.add("maxValue", maxValue)
.add("minStep", 1)
.add("unit", unit);
builder.add("minValue", minValue).add("maxValue", maxValue).add("minStep", 1);
if (this.unit != null) {
builder.add("unit", unit);
}
return builder;
});
}

@Override
protected CompletableFuture<Integer> getValue() {
return getter.map(integerGetter -> integerGetter.get()).get();
if (getter.isPresent()) {
return getter.map(integerGetter -> integerGetter.get()).get();
} else {
return null;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.hapjava.accessories.AirPurifierAccessory;
import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithName;
import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithPhysicalControlsLock;
import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithRotationSpeed;
import io.github.hapjava.accessories.optionalcharacteristic.AccessoryWithSwingMode;
import io.github.hapjava.characteristics.impl.airpurifier.CurrentAirPurifierCharacteristic;
import io.github.hapjava.characteristics.impl.airpurifier.TargetAirPurifierStateCharacteristic;
Expand Down Expand Up @@ -53,13 +54,13 @@ public AirPurifierService(AirPurifierAccessory accessory) {
((AccessoryWithSwingMode) accessory)::subscribeSwingMode,
((AccessoryWithSwingMode) accessory)::unsubscribeSwingMode));
}
if (accessory instanceof AccessoryWithSwingMode) {
if (accessory instanceof AccessoryWithRotationSpeed) {
addOptionalCharacteristic(
new SwingModeCharacteristic(
((AccessoryWithSwingMode) accessory)::getSwingMode,
((AccessoryWithSwingMode) accessory)::setSwingMode,
((AccessoryWithSwingMode) accessory)::subscribeSwingMode,
((AccessoryWithSwingMode) accessory)::unsubscribeSwingMode));
new RotationSpeedCharacteristic(
((AccessoryWithRotationSpeed) accessory)::getRotationSpeed,
((AccessoryWithRotationSpeed) accessory)::setRotationSpeed,
((AccessoryWithRotationSpeed) accessory)::subscribeRotationSpeed,
((AccessoryWithRotationSpeed) accessory)::unsubscribeRotationSpeed));
}
if (accessory instanceof AccessoryWithPhysicalControlsLock) {
addOptionalCharacteristic(
Expand Down