Skip to content

Commit 68f09a7

Browse files
committed
add name, active and fault interfaces
1 parent 9aa77d5 commit 68f09a7

File tree

89 files changed

+721
-262
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+721
-262
lines changed

src/main/java/io/github/hapjava/accessories/LockMechanismAccessory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public interface LockMechanismAccessory extends HomekitAccessory {
3434
* set lock target state the lock trget state.
3535
*
3636
* @param state lock target state
37+
* @return a future that completes when the change is made
3738
*/
3839
CompletableFuture<Void> setLockTargetState(LockTargetStateEnum state);
3940

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithDuration.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@
1111
public interface AccessoryWithDuration {
1212

1313
/**
14-
* Retrieves the current set duration for which the valve will be scheduled to run; this is
15-
* usually used as the duration to use when the valve is set to active.
14+
* Retrieves the current set duration;
1615
*
1716
* @return a future with the value
1817
*/
1918
CompletableFuture<Integer> getSetDuration();
2019

2120
/**
22-
* Sets the duration for which the valve will be scheduled to run; this is usually used as the
23-
* duration to use when the valve is set to active.
21+
* Sets the duration for which the service should run.
2422
*
25-
* <p>If the valve is currently running, then Homekit assumes that changing this value affects the
26-
* current remaining duration.
27-
*
28-
* @return a future with the value
23+
* @param value duration in seconds
24+
* @return a future that completes when the change is made
2925
*/
3026
CompletableFuture<Void> setSetDuration(int value);
3127

3228
/**
3329
* Subscribes to changes in the set duration
3430
*
35-
* @param callback the function when the value has changed
31+
* @param callback the function when the duration has changed
3632
*/
3733
void subscribeSetDuration(HomekitCharacteristicChangeCallback callback);
3834

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithFanState.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,39 @@
1616
public interface AccessoryWithFanState {
1717

1818
/**
19-
* OPTIONAL: Retrieves the current state of the fan (INACTIVE, IDLE, BLOWING AIR).
19+
* Retrieves the current state of the fan (INACTIVE, IDLE, BLOWING AIR).
2020
*
2121
* @return a future that will contain the state
2222
*/
2323
CompletableFuture<CurrentFanStateEnum> getCurrentFanState();
2424

2525
/**
26-
* OPTIONAL: Retrieves the target state of the fan (MANUAL, AUTO).
26+
* Retrieves the target state of the fan (MANUAL, AUTO).
2727
*
2828
* @return a future that will contain the state
2929
*/
3030
CompletableFuture<TargetFanStateEnum> getTargetFanState();
3131

3232
/**
33-
* OPTIONAL: Set the target state of the fan (MANUAL, AUTO).
33+
* Set the target state of the fan (MANUAL, AUTO).
3434
*
3535
* @param targetState target state
36+
* @return a future that completes when the change is made
3637
*/
3738
CompletableFuture<Void> setTargetFanState(TargetFanStateEnum targetState);
3839

3940
/**
40-
* OPTIONAL: Retrieves the swing mode of the fan.
41+
* Retrieves the swing mode of the fan.
4142
*
4243
* @return a future that will contain the swing mode
4344
*/
4445
CompletableFuture<SwingModeEnum> getSwingMode();
4546

4647
/**
47-
* OPTIONAL: Set the swing mode of the fan (DISABLED, ENABLED).
48+
* Set the swing mode of the fan (DISABLED, ENABLED).
4849
*
4950
* @param swingMode swing mode
51+
* @return a future that completes when the change is made
5052
*/
5153
CompletableFuture<Void> setSwingMode(SwingModeEnum swingMode);
5254

@@ -58,28 +60,29 @@ public interface AccessoryWithFanState {
5860
CompletableFuture<LockPhysicalControlsEnum> getLockControls();
5961

6062
/**
61-
* OPTIONAL: Set the lock controls of the fan (DISABLED, ENABLED).
63+
* Set the lock controls of the fan (DISABLED, ENABLED).
6264
*
6365
* @param lockControls lock controls mode
66+
* @return a future that completes when the change is made
6467
*/
6568
CompletableFuture<Void> setLockControls(LockPhysicalControlsEnum lockControls);
6669

6770
/**
68-
* OPTIONAL: Retrieves the current rotation direction of the fan.
71+
* Retrieves the current rotation direction of the fan.
6972
*
7073
* @return a future that will contain the direction
7174
*/
7275
CompletableFuture<RotationDirectionEnum> getRotationDirection();
7376

7477
/**
75-
* OPTIONAL: Retrieves the current speed of the fan's rotation
78+
* Retrieves the current speed of the fan's rotation
7679
*
7780
* @return a future that will contain the speed, expressed as an integer between 0 and 100.
7881
*/
7982
CompletableFuture<Integer> getRotationSpeed();
8083

8184
/**
82-
* OPTIONAL: Sets the rotation direction of the fan
85+
* Sets the rotation direction of the fan
8386
*
8487
* @param direction the direction to set
8588
* @return a future that completes when the change is made
@@ -97,62 +100,62 @@ public interface AccessoryWithFanState {
97100
CompletableFuture<Void> setRotationSpeed(Integer speed) throws Exception;
98101

99102
/**
100-
* OPTIONAL: Subscribes to changes in the rotation direction of the fan.
103+
* Subscribes to changes in the rotation direction of the fan.
101104
*
102105
* @param callback the function to call when the direction changes.
103106
*/
104107
void subscribeRotationDirection(HomekitCharacteristicChangeCallback callback);
105108

106109
/**
107-
* OPTIONAL: Subscribes to changes in the current fan state.
110+
* Subscribes to changes in the current fan state.
108111
*
109112
* @param callback the function to call when the direction changes.
110113
*/
111114
void subscribeCurrentFanState(HomekitCharacteristicChangeCallback callback);
112115

113116
/**
114-
* OPTIONAL: Subscribes to changes in the target fan state.
117+
* Subscribes to changes in the target fan state.
115118
*
116119
* @param callback the function to call when the direction changes.
117120
*/
118121
void subscribeTargetFanState(HomekitCharacteristicChangeCallback callback);
119122

120123
/**
121-
* OPTIONAL: Subscribes to changes in the rotation speed of the fan.
124+
* Subscribes to changes in the rotation speed of the fan.
122125
*
123126
* @param callback the function to call when the speed changes.
124127
*/
125128
void subscribeRotationSpeed(HomekitCharacteristicChangeCallback callback);
126129

127130
/**
128-
* OPTIONAL: Subscribes to changes in the swing mode of the fan.
131+
* Subscribes to changes in the swing mode of the fan.
129132
*
130133
* @param callback the function to call when the swing mode changes.
131134
*/
132135
void subscribeSwingMode(HomekitCharacteristicChangeCallback callback);
133136

134137
/**
135-
* OPTIONAL: Subscribes to changes in the lock controls of the fan.
138+
* Subscribes to changes in the lock controls of the fan.
136139
*
137140
* @param callback the function to call when the lock controls changes.
138141
*/
139142
void subscribeLockControls(HomekitCharacteristicChangeCallback callback);
140143

141-
/** OPTIONAL: Unsubscribes from changes in the rotation direction of the fan. */
144+
/** Unsubscribes from changes in the rotation direction of the fan. */
142145
void unsubscribeRotationDirection();
143146

144-
/** OPTIONAL: Unsubscribes from changes in the fan's rotation speed. */
147+
/** Unsubscribes from changes in the fan's rotation speed. */
145148
void unsubscribeRotationSpeed();
146149

147-
/** OPTIONAL: Unsubscribes from changes in the current state of the fan. */
150+
/** Unsubscribes from changes in the current state of the fan. */
148151
void unsubscribeCurrentFanState();
149152

150-
/** OPTIONAL: Unsubscribes from changes in the target state of the fan. */
153+
/** Unsubscribes from changes in the target state of the fan. */
151154
void unsubscribeTargetFanState();
152155

153-
/** OPTIONAL: Unsubscribes from changes in the swing mode of the fan. */
156+
/** Unsubscribes from changes in the swing mode of the fan. */
154157
void unsubscribeSwingMode();
155158

156-
/** OPTIONAL: Unsubscribes from changes in the lock controls of the fan. */
159+
/** Unsubscribes from changes in the lock controls of the fan. */
157160
void unsubscribeLockControls();
158161
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import java.util.concurrent.CompletableFuture;
4+
5+
/**
6+
* Accessory with name.
7+
*
8+
* @author Eugen Freiter
9+
*/
10+
public interface AccessoryWithName {
11+
12+
/**
13+
* Retrieves the name of service.
14+
*
15+
* @return a future with the name
16+
*/
17+
CompletableFuture<String> getName();
18+
}

src/main/java/io/github/hapjava/accessories/optionalcharacteristic/AccessoryWithRemainingDuration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
public interface AccessoryWithRemainingDuration {
1212

1313
/**
14-
* Retrieves the current duration for which the valve will run
14+
* Retrieves the remaining duration
1515
*
16-
* @return a future with the value
16+
* @return a future with the duration in seconds
1717
*/
1818
CompletableFuture<Integer> getRemainingDuration();
1919

2020
/**
2121
* Subscribes to changes in the duration; note it is not necessary to emit a change every second,
22-
* homekit infers the countdown progress clientside.
22+
* homekit infers the countdown progress client side.
2323
*
2424
* @param callback the function when the existing duration has been replaced with a new one.
2525
*/
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import java.util.concurrent.CompletableFuture;
5+
6+
/**
7+
* Accessory with status active.
8+
*
9+
* @author Eugen Freiter
10+
*/
11+
public interface AccessoryWithStatusActive {
12+
13+
/**
14+
* Retrieves the status active. A value of true indicates that the accessory is active and is
15+
* functioning without any errors.
16+
*
17+
* @return a future with the value
18+
*/
19+
CompletableFuture<Boolean> getStatusActive();
20+
21+
/**
22+
* Subscribes to changes in status active.
23+
*
24+
* @param callback the function when the status active changes
25+
*/
26+
void subscribeStatusActive(HomekitCharacteristicChangeCallback callback);
27+
28+
/** Unsubscribes from changes */
29+
void unsubscribeStatusActive();
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.common.StatusFaultEnum;
5+
import java.util.concurrent.CompletableFuture;
6+
7+
/**
8+
* Accessory with characteristic that describes an accessory which has a fault. A non-zero value
9+
* indicates that the accessory has experienced a fault that may be interfering with its intended
10+
* functionality. A value of 0 indicates that there is no fault.
11+
*
12+
* @author Eugen Freiter
13+
*/
14+
public interface AccessoryWithStatusFault {
15+
16+
/**
17+
* Retrieves the status fault. A non-zero value indicates that the accessory has experienced a
18+
* fault that may be interfering with its intended functionality. A value of 0 indicates that
19+
* there is no fault.
20+
*
21+
* @return a future with the value
22+
*/
23+
CompletableFuture<StatusFaultEnum> getStatusFault();
24+
25+
/**
26+
* Subscribes to changes in status fault.
27+
*
28+
* @param callback the function when the status fault changes
29+
*/
30+
void subscribeStatusFault(HomekitCharacteristicChangeCallback callback);
31+
32+
/** Unsubscribes from changes */
33+
void unsubscribeStatusFault();
34+
}

src/main/java/io/github/hapjava/characteristics/impl/accessoryinformation/IdentifyCharacteristic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.github.hapjava.characteristics.impl.accessoryinformation;
22

3-
import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic;
43
import io.github.hapjava.characteristics.ExceptionalConsumer;
4+
import io.github.hapjava.characteristics.impl.base.BooleanCharacteristic;
55
import java.util.Optional;
66

77
/** This characteristic enables accessory to run its identify routine. */

src/main/java/io/github/hapjava/characteristics/impl/base/BaseCharacteristic.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.github.hapjava.characteristics.impl.base;
22

3+
import io.github.hapjava.characteristics.Characteristic;
4+
import io.github.hapjava.characteristics.EventableCharacteristic;
5+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
36
import java.math.BigDecimal;
47
import java.math.BigInteger;
58
import java.util.Optional;
@@ -13,9 +16,6 @@
1316
import javax.json.JsonValue;
1417
import org.slf4j.Logger;
1518
import org.slf4j.LoggerFactory;
16-
import io.github.hapjava.characteristics.Characteristic;
17-
import io.github.hapjava.characteristics.EventableCharacteristic;
18-
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
1919

2020
/**
2121
* Base class for implementing {@link Characteristic}.

src/main/java/io/github/hapjava/characteristics/impl/base/BooleanCharacteristic.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package io.github.hapjava.characteristics.impl.base;
22

3+
import io.github.hapjava.characteristics.ExceptionalConsumer;
4+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
35
import java.util.Optional;
46
import java.util.concurrent.CompletableFuture;
57
import java.util.function.Consumer;
68
import java.util.function.Supplier;
79
import javax.json.JsonNumber;
810
import javax.json.JsonValue;
911
import javax.json.JsonValue.ValueType;
10-
import io.github.hapjava.characteristics.ExceptionalConsumer;
11-
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
1212

1313
/**
1414
* Characteristic that exposes a Boolean value.
@@ -26,6 +26,10 @@ public abstract class BooleanCharacteristic extends BaseCharacteristic<Boolean>
2626
* @param type a string containing a UUID that indicates the type of characteristic. Apple defines
2727
* a set of these, however implementors can create their own as well.
2828
* @param description a description of the characteristic to be passed to the consuming device.
29+
* @param getter getter to retrieve the value
30+
* @param setter setter to set value
31+
* @param subscriber subscriber to subscribe to changes
32+
* @param unsubscriber unsubscriber to unsubscribe from chnages
2933
*/
3034
public BooleanCharacteristic(
3135
String type,

0 commit comments

Comments
 (0)