Repository navigation
Expand file tree
/
Copy pathFan.java
More file actions
99 lines (84 loc) · 3 KB
/
Copy pathFan.java
File metadata and controls
99 lines (84 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package io.github.hapjava.accessories;
import io.github.hapjava.*;
import io.github.hapjava.accessories.properties.RotationDirection;
import io.github.hapjava.impl.services.FanService;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
/**
* A fan, with power and rotational characteristics.
*
* @author Andy Lintner
*/
public interface Fan extends HomekitAccessory {
/**
* Retrieves the current binary state of the fan's power.
*
* @return a future that will contain the binary state
*/
CompletableFuture<Boolean> getFanPower();
/**
* Retrieves the current rotation direction of the fan.
*
* @return a future that will contain the direction
*/
CompletableFuture<RotationDirection> getRotationDirection();
/**
* Retrieves the current speed of the fan's rotation
*
* @return a future that will contain the speed, expressed as an integer between 0 and 100.
*/
CompletableFuture<Integer> getRotationSpeed();
/**
* Sets the binary state of the fan's power
*
* @param state the binary state to set
* @return a future that completes when the change is made
* @throws Exception when the change cannot be made
*/
CompletableFuture<Void> setFanPower(boolean state) throws Exception;
/**
* Sets the rotation direction of the fan
*
* @param direction the direction to set
* @return a future that completes when the change is made
* @throws Exception when the change cannot be made
*/
CompletableFuture<Void> setRotationDirection(RotationDirection direction) throws Exception;
/**
* Sets the speed of the fan's rotation
*
* @param speed the speed to set, expressed as an integer between 0 and 100.
* @return a future that completes when the change is made
* @throws Exception when the change cannot be made
*/
CompletableFuture<Void> setRotationSpeed(Integer speed) throws Exception;
@Override
default Collection<Service> getServices() {
return Collections.singleton(new FanService(this));
}
/**
* Subscribes to changes in the binary state of the fan's power.
*
* @param callback the function to call when the state changes.
*/
void subscribeFanPower(HomekitCharacteristicChangeCallback callback);
/**
* Subscribes to changes in the rotation direction of the fan.
*
* @param callback the function to call when the direction changes.
*/
void subscribeRotationDirection(HomekitCharacteristicChangeCallback callback);
/**
* Subscribes to changes in the rotation speed of the fan.
*
* @param callback the function to call when the speed changes.
*/
void subscribeRotationSpeed(HomekitCharacteristicChangeCallback callback);
/** Unsubscribes from changes in the binary state of the fan's power. */
void unsubscribeFanPower();
/** Unsubscribes from changes in the rotation direction of the fan. */
void unsubscribeRotationDirection();
/** Unsubscribes from changes in the fan's rotation speed. */
void unsubscribeRotationSpeed();
}