-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from timcharper/tharper/fix-window-covering
Introduce BasicWindowCovering and deprecate WindowCovering
- Loading branch information
Showing
9 changed files
with
162 additions
and
121 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/main/java/com/beowulfe/hap/accessories/BasicWindowCovering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.beowulfe.hap.accessories; | ||
|
||
import com.beowulfe.hap.HomekitAccessory; | ||
import com.beowulfe.hap.HomekitCharacteristicChangeCallback; | ||
import com.beowulfe.hap.Service; | ||
import com.beowulfe.hap.accessories.properties.WindowCoveringPositionState; | ||
import com.beowulfe.hap.impl.services.WindowCoveringService; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface BasicWindowCovering extends HomekitAccessory { | ||
|
||
/** | ||
* Retrieves the current position | ||
* | ||
* @return a future that will contain the position as a value between 0 and 100 | ||
*/ | ||
CompletableFuture<Integer> getCurrentPosition(); | ||
|
||
/** | ||
* Retrieves the target position | ||
* | ||
* @return a future that will contain the target position as a value between 0 and 100 | ||
*/ | ||
CompletableFuture<Integer> getTargetPosition(); | ||
|
||
/** | ||
* Retrieves the state of the position: increasing, decreasing, or stopped | ||
* | ||
* @return a future that will contain the current state | ||
*/ | ||
CompletableFuture<WindowCoveringPositionState> getPositionState(); | ||
|
||
/** | ||
* Sets the target position | ||
* | ||
* @param position the target position to set, as a value between 1 and 100 | ||
* @return a future that completes when the change is made | ||
* @throws Exception when the change cannot be made | ||
*/ | ||
CompletableFuture<Void> setTargetPosition(int position) throws Exception; | ||
|
||
/** | ||
* Subscribes to changes in the current position. | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeCurrentPosition(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** | ||
* Subscribes to changes in the target position. | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeTargetPosition(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** | ||
* Subscribes to changes in the position state: increasing, decreasing, or stopped | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribePositionState(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** Unsubscribes from changes in the current position. */ | ||
void unsubscribeCurrentPosition(); | ||
|
||
/** Unsubscribes from changes in the target position. */ | ||
void unsubscribeTargetPosition(); | ||
|
||
/** Unsubscribes from changes in the position state */ | ||
void unsubscribePositionState(); | ||
|
||
@Override | ||
default Collection<Service> getServices() { | ||
return Collections.singleton(new WindowCoveringService(this)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/beowulfe/hap/accessories/HoldPositionWindowCovering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.beowulfe.hap.accessories; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface HoldPositionWindowCovering { | ||
|
||
/** | ||
* Sets the hold position state | ||
* | ||
* @param hold whether or not to hold the current position state | ||
* @return a future that completes when the change is made | ||
* @throws Exception when the change cannot be made | ||
*/ | ||
CompletableFuture<Void> setHoldPosition(boolean hold) throws Exception; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/beowulfe/hap/accessories/ObstructionDetectedWindowCovering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.beowulfe.hap.accessories; | ||
|
||
import com.beowulfe.hap.HomekitCharacteristicChangeCallback; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
public interface ObstructionDetectedWindowCovering { | ||
|
||
/** | ||
* Retrieves an indication that the window covering is obstructed from moving | ||
* | ||
* @return a future that will contain a boolean indicating whether an obstruction is present | ||
*/ | ||
CompletableFuture<Boolean> getObstructionDetected(); | ||
|
||
/** | ||
* Subscribes to changes in the obstruction detected state | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeObstructionDetected(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** Unsubscribes from changes in the obstruction detected state */ | ||
void unsubscribeObstructionDetected(); | ||
} |
107 changes: 8 additions & 99 deletions
107
src/main/java/com/beowulfe/hap/accessories/WindowCovering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,16 @@ | ||
package com.beowulfe.hap.accessories; | ||
|
||
import com.beowulfe.hap.*; | ||
import com.beowulfe.hap.accessories.properties.WindowCoveringPositionState; | ||
import com.beowulfe.hap.impl.services.WindowCoveringService; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* A window covering, like blinds, which can be remotely controlled. | ||
* | ||
* @author Andy Lintner | ||
* @deprecated In 1.2.x, this interface will become replaced with BasicWindowCovering. Update your | ||
* code to use that interface for now, and include the HoldPositionWindowCovering and | ||
* ObstructionDetectedWindowCovering interfaces respectively | ||
*/ | ||
public interface WindowCovering extends HomekitAccessory { | ||
|
||
/** | ||
* Retrieves the current position | ||
* | ||
* @return a future that will contain the position as a value between 0 and 100 | ||
*/ | ||
CompletableFuture<Integer> getCurrentPosition(); | ||
|
||
/** | ||
* Retrieves the target position | ||
* | ||
* @return a future that will contain the target position as a value between 0 and 100 | ||
*/ | ||
CompletableFuture<Integer> getTargetPosition(); | ||
|
||
/** | ||
* Retrieves the state of the position: increasing, decreasing, or stopped | ||
* | ||
* @return a future that will contain the current state | ||
*/ | ||
CompletableFuture<WindowCoveringPositionState> getPositionState(); | ||
|
||
/** | ||
* Retrieves an indication that the window covering is obstructed from moving | ||
* | ||
* @return a future that will contain a boolean indicating whether an obstruction is present | ||
*/ | ||
CompletableFuture<Boolean> getObstructionDetected(); | ||
|
||
@Override | ||
default Collection<Service> getServices() { | ||
return Collections.singleton(new WindowCoveringService(this)); | ||
} | ||
|
||
/** | ||
* Sets the target position | ||
* | ||
* @param position the target position to set, as a value between 1 and 100 | ||
* @return a future that completes when the change is made | ||
* @throws Exception when the change cannot be made | ||
*/ | ||
CompletableFuture<Void> setTargetPosition(int position) throws Exception; | ||
|
||
/** | ||
* Sets the hold position state | ||
* | ||
* @param hold whether or not to hold the current position state | ||
* @return a future that completes when the change is made | ||
* @throws Exception when the change cannot be made | ||
*/ | ||
CompletableFuture<Void> setHoldPosition(boolean hold) throws Exception; | ||
|
||
/** | ||
* Subscribes to changes in the current position. | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeCurrentPosition(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** | ||
* Subscribes to changes in the target position. | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeTargetPosition(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** | ||
* Subscribes to changes in the position state: increasing, decreasing, or stopped | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribePositionState(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** | ||
* Subscribes to changes in the obstruction detected state | ||
* | ||
* @param callback the function to call when the state changes. | ||
*/ | ||
void subscribeObstructionDetected(HomekitCharacteristicChangeCallback callback); | ||
|
||
/** Unsubscribes from changes in the current position. */ | ||
void unsubscribeCurrentPosition(); | ||
|
||
/** Unsubscribes from changes in the target position. */ | ||
void unsubscribeTargetPosition(); | ||
|
||
/** Unsubscribes from changes in the position state */ | ||
void unsubscribePositionState(); | ||
|
||
/** Unsubscribes from changes in the obstruction detected state */ | ||
void unsubscribeObstructionDetected(); | ||
@Deprecated | ||
public interface WindowCovering | ||
extends BasicWindowCovering, HoldPositionWindowCovering, ObstructionDetectedWindowCovering { | ||
/* | ||
* TODO - 1.2.x: Replace this interface with BasicWindowCovering */ | ||
} |
6 changes: 3 additions & 3 deletions
6
...a/com/beowulfe/hap/impl/characteristics/windowcovering/CurrentPositionCharacteristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...java/com/beowulfe/hap/impl/characteristics/windowcovering/HoldPositionCharacteristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ava/com/beowulfe/hap/impl/characteristics/windowcovering/PositionStateCharacteristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...va/com/beowulfe/hap/impl/characteristics/windowcovering/TargetPositionCharacteristic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters