Skip to content

Commit d0d4f27

Browse files
author
Eugen Freiter
committed
add support for television service
Signed-off-by: Eugen Freiter <[email protected]>
1 parent 915efec commit d0d4f27

File tree

50 files changed

+1927
-1
lines changed

Some content is hidden

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

50 files changed

+1927
-1
lines changed

CHANGES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
## Fixes
33
* Log accessory names instead of futures. [#150](https://github.com/hap-java/HAP-Java/issues/150)
44
* Fix rotation speed data type (BREAKING API CHANGE). According to HAP specification it must be float
5+
* Fix UUID of HAP Version characteristic
6+
7+
## New
8+
* New characteristics:
9+
* Identifier
10+
* Input Device Type
11+
* Input Source Type
12+
* Configured Name
13+
* Current Visibility State
14+
* Target Visibility State
15+
* Sleep Discovery Mode
16+
* Active Identifier
17+
* Closed Captions
18+
* Current Media State
19+
* Target Media State
20+
* Picture Mode
21+
* Power Mode
22+
* Remote Key
23+
* Volume Control Type
24+
* Volume Selector
25+
26+
* New services
27+
* Input Source
28+
* Television
29+
* Television Speaker
530

631
# HAP-Java 2.0.0
732
* major refactoring to support optional characteristics
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.common.IsConfiguredEnum;
5+
import io.github.hapjava.characteristics.impl.inputsource.CurrentVisibilityStateEnum;
6+
import io.github.hapjava.characteristics.impl.inputsource.InputSourceTypeEnum;
7+
import io.github.hapjava.services.Service;
8+
import io.github.hapjava.services.impl.InputSourceService;
9+
import java.util.Collection;
10+
import java.util.Collections;
11+
import java.util.concurrent.CompletableFuture;
12+
13+
/** Input Source accessory. */
14+
public interface InputSourceAccessory extends HomekitAccessory {
15+
16+
/**
17+
* Retrieves configured name of input source.
18+
*
19+
* @return configured name of input source
20+
*/
21+
CompletableFuture<String> getConfiguredName();
22+
23+
/**
24+
* Sets the configured name.
25+
*
26+
* @param name configured name
27+
* @return a future that completes when the change is made
28+
* @throws Exception when the change cannot be made
29+
*/
30+
CompletableFuture<Void> setConfiguredName(String name) throws Exception;
31+
32+
/**
33+
* Subscribes to changes in configured name.
34+
*
35+
* @param callback the function to call when the configured name changes.
36+
*/
37+
void subscribeConfiguredName(HomekitCharacteristicChangeCallback callback);
38+
39+
/** Unsubscribes from changes in the configured name. */
40+
void unsubscribeConfiguredName();
41+
42+
/**
43+
* Retrieves the flag whether input source is configured.
44+
*
45+
* @return a future that will contain the flag .
46+
*/
47+
CompletableFuture<IsConfiguredEnum> isConfigured();
48+
/**
49+
* set the flag whether input source is configured.
50+
*
51+
* @param state is configured state
52+
* @return a future that completes when the change is made
53+
*/
54+
CompletableFuture<Void> setIsConfigured(IsConfiguredEnum state);
55+
56+
/**
57+
* Subscribes to changes in isConfigured.
58+
*
59+
* @param callback the function to call when the state changes.
60+
*/
61+
void subscribeIsConfigured(HomekitCharacteristicChangeCallback callback);
62+
63+
/** Unsubscribes from changes in isConfigured. */
64+
void unsubscribeIsConfigured();
65+
66+
/**
67+
* Retrieves the input source type.
68+
*
69+
* @return a future that will contain the input source type.
70+
*/
71+
CompletableFuture<InputSourceTypeEnum> getInputSourceType();
72+
73+
/**
74+
* Subscribes to changes in input source type.
75+
*
76+
* @param callback the function to call when the type changes.
77+
*/
78+
void subscribeInputSourceType(HomekitCharacteristicChangeCallback callback);
79+
80+
/** Unsubscribes from changes in the input source type. */
81+
void unsubscribeInputSourceType();
82+
83+
/**
84+
* Retrieves the current visibility state.
85+
*
86+
* @return a future that will contain the current visibility state.
87+
*/
88+
CompletableFuture<CurrentVisibilityStateEnum> getCurrentVisibilityState();
89+
90+
/**
91+
* Subscribes to changes in current visibility state.
92+
*
93+
* @param callback the function to call when the state changes.
94+
*/
95+
void subscribeCurrentVisibilityState(HomekitCharacteristicChangeCallback callback);
96+
97+
/** Unsubscribes from changes in the current visibility state. */
98+
void unsubscribeCurrentVisibilityState();
99+
100+
@Override
101+
default Collection<Service> getServices() {
102+
return Collections.singleton(new InputSourceService(this));
103+
}
104+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.television.RemoteKeyEnum;
5+
import io.github.hapjava.characteristics.impl.television.SleepDiscoveryModeEnum;
6+
import io.github.hapjava.services.Service;
7+
import io.github.hapjava.services.impl.TelevisionService;
8+
import java.util.Collection;
9+
import java.util.Collections;
10+
import java.util.concurrent.CompletableFuture;
11+
12+
/** Television accessory. */
13+
public interface TelevisionAccessory extends HomekitAccessory {
14+
15+
/**
16+
* Retrieves the current active state of the TV.
17+
*
18+
* @return a future that will contain the state
19+
*/
20+
CompletableFuture<Boolean> isActive();
21+
22+
/**
23+
* Sets the active state of the TV
24+
*
25+
* @param state the state to set
26+
* @return a future that completes when the change is made
27+
* @throws Exception when the change cannot be made
28+
*/
29+
CompletableFuture<Void> setActive(boolean state) throws Exception;
30+
31+
/**
32+
* Subscribes to changes in the active state of the TV .
33+
*
34+
* @param callback the function to call when the active state changes.
35+
*/
36+
void subscribeActive(HomekitCharacteristicChangeCallback callback);
37+
38+
/** Unsubscribes from changes in the active state of the TV. */
39+
void unsubscribeActive();
40+
41+
/**
42+
* Retrieves the active identifier
43+
*
44+
* @return a future that will contain the active identifier.
45+
*/
46+
CompletableFuture<Integer> getActiveIdentifier();
47+
48+
/**
49+
* Sets the active identifier
50+
*
51+
* @param identifier the active identifier
52+
* @return a future that completes when the active identifier is changed
53+
* @throws Exception when the active identifier cannot be set
54+
*/
55+
CompletableFuture<Void> setActiveIdentifier(Integer identifier) throws Exception;
56+
57+
/**
58+
* Subscribes to changes in the active identifier.
59+
*
60+
* @param callback the function to call when the active identifier changes.
61+
*/
62+
void subscribeActiveIdentifier(HomekitCharacteristicChangeCallback callback);
63+
64+
/** Unsubscribes from changes in the active identifier. */
65+
void unsubscribeActiveIdentifier();
66+
67+
/**
68+
* Retrieves configured name.
69+
*
70+
* @return configured name
71+
*/
72+
CompletableFuture<String> getConfiguredName();
73+
74+
/**
75+
* Sets the mute status
76+
*
77+
* @param name configured name
78+
* @return a future that completes when the change is made
79+
* @throws Exception when the change cannot be made
80+
*/
81+
CompletableFuture<Void> setConfiguredName(String name) throws Exception;
82+
83+
/**
84+
* Subscribes to changes in mute state.
85+
*
86+
* @param callback the function to call when the state changes.
87+
*/
88+
void subscribeConfiguredName(HomekitCharacteristicChangeCallback callback);
89+
90+
/** Unsubscribes from changes in the mute state. */
91+
void unsubscribeConfiguredName();
92+
93+
/**
94+
* Sends the remote key.
95+
*
96+
* @param key remote key
97+
* @return a future that completes when the change is made
98+
* @throws Exception when the change cannot be made
99+
*/
100+
CompletableFuture<Void> setRemoteKey(RemoteKeyEnum key) throws Exception;
101+
102+
/**
103+
* Retrieves the sleep discovery mode.
104+
*
105+
* @return a future that will contain the sleep discovery mode .
106+
*/
107+
CompletableFuture<SleepDiscoveryModeEnum> getSleepDiscoveryMode();
108+
109+
/**
110+
* Subscribes to changes in sleep discovery mode.
111+
*
112+
* @param callback the function to call when the sleep discovery mode changes.
113+
*/
114+
void subscribeSleepDiscoveryMode(HomekitCharacteristicChangeCallback callback);
115+
116+
/** Unsubscribes from changes in the sleep discovery mode. */
117+
void unsubscribeSleepDiscoveryMode();
118+
119+
@Override
120+
default Collection<Service> getServices() {
121+
return Collections.singleton(new TelevisionService(this));
122+
}
123+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.services.Service;
5+
import io.github.hapjava.services.impl.TelevisionSpeakerService;
6+
import java.util.Collection;
7+
import java.util.Collections;
8+
import java.util.concurrent.CompletableFuture;
9+
10+
/** Television speaker accessory. */
11+
public interface TelevisionSpeakerAccessory extends HomekitAccessory {
12+
13+
/**
14+
* Retrieves mute status.
15+
*
16+
* @return true if accessory is muted
17+
*/
18+
CompletableFuture<Boolean> isMuted();
19+
20+
/**
21+
* Sets the mute status
22+
*
23+
* @param mute true if accessory should be muted
24+
* @return a future that completes when the change is made
25+
* @throws Exception when the change cannot be made
26+
*/
27+
CompletableFuture<Void> setMute(boolean mute) throws Exception;
28+
29+
/**
30+
* Subscribes to changes in mute state.
31+
*
32+
* @param callback the function to call when the state changes.
33+
*/
34+
void subscribeMuteState(HomekitCharacteristicChangeCallback callback);
35+
36+
/** Unsubscribes from changes in the mute state. */
37+
void unsubscribeMuteState();
38+
39+
@Override
40+
default Collection<Service> getServices() {
41+
return Collections.singleton(new TelevisionSpeakerService(this));
42+
}
43+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.common.ActiveEnum;
5+
import java.util.concurrent.CompletableFuture;
6+
7+
/**
8+
* Accessory with active characteristic {@link
9+
* io.github.hapjava.characteristics.impl.common.ActiveCharacteristic}.
10+
*/
11+
public interface AccessoryWithActive {
12+
13+
/**
14+
* Retrieves the active state (see {@link
15+
* io.github.hapjava.characteristics.impl.common.ActiveEnum} for supported values).
16+
*
17+
* @return a future that will contain the active state
18+
*/
19+
CompletableFuture<ActiveEnum> getActive();
20+
21+
/**
22+
* Set the active state (see {@link ActiveEnum} for supported values).
23+
*
24+
* @param active active state
25+
* @return a future that completes when the change is made
26+
*/
27+
CompletableFuture<Void> setActive(ActiveEnum active);
28+
29+
/**
30+
* Subscribes to changes in the active state.
31+
*
32+
* @param callback the function to call when the active state changes.
33+
*/
34+
void subscribeActive(HomekitCharacteristicChangeCallback callback);
35+
36+
/** Unsubscribes from changes in the active state. */
37+
void unsubscribeActive();
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.github.hapjava.accessories.optionalcharacteristic;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.television.ClosedCaptionsEnum;
5+
import java.util.concurrent.CompletableFuture;
6+
7+
/**
8+
* Accessory with closed captions characteristic {@link
9+
* io.github.hapjava.characteristics.impl.television.ClosedCaptionsCharacteristic}.
10+
*/
11+
public interface AccessoryWithClosedCaptions {
12+
13+
/**
14+
* Retrieves the closed captions state (see {@link ClosedCaptionsEnum} for supported values).
15+
*
16+
* @return a future that will contain the closed captions
17+
*/
18+
CompletableFuture<ClosedCaptionsEnum> getClosedCaptions();
19+
20+
/**
21+
* Set the closed captions state (see {@link ClosedCaptionsEnum} for supported values).
22+
*
23+
* @param closedCaptions closed captions
24+
* @return a future that completes when the change is made
25+
*/
26+
CompletableFuture<Void> setClosedCaptions(ClosedCaptionsEnum closedCaptions);
27+
28+
/**
29+
* Subscribes to changes in the closed captions.
30+
*
31+
* @param callback the function to call when the closed captions changes.
32+
*/
33+
void subscribeClosedCaptions(HomekitCharacteristicChangeCallback callback);
34+
35+
/** Unsubscribes from changes in the closed captions. */
36+
void unsubscribeClosedCaptions();
37+
}

0 commit comments

Comments
 (0)