Skip to content

Commit 54908ff

Browse files
authored
Merge pull request #157 from yfre/television_support
Television support
2 parents fd51a22 + 4d9da49 commit 54908ff

File tree

58 files changed

+2243
-3
lines changed

Some content is hidden

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

58 files changed

+2243
-3
lines changed

CHANGES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@
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
55
* Close JsonWriters [#149](https://github.com/hap-java/HAP-Java/issues/149)
6+
* Fix UUID of HAP Version characteristic
7+
* Add Mute characteristic to Doorbell service
8+
9+
## New
10+
* New characteristics:
11+
* Identifier
12+
* Input Device Type
13+
* Input Source Type
14+
* Configured Name
15+
* Current Visibility State
16+
* Target Visibility State
17+
* Sleep Discovery Mode
18+
* Active Identifier
19+
* Closed Captions
20+
* Current Media State
21+
* Target Media State
22+
* Picture Mode
23+
* Power Mode
24+
* Remote Key
25+
* Volume Control Type
26+
* Volume Selector
27+
* AirPlay Enable
28+
29+
* New services
30+
* Input Source
31+
* Television
32+
* Television Speaker
33+
* Smart Speaker
634

735
# HAP-Java 2.0.0
836
* major refactoring to support optional characteristics

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Include HAP-Java in your project using maven:
1818
<dependency>
1919
<groupId>io.github.hap-java</groupId>
2020
<artifactId>hap</artifactId>
21-
<version>2.0.0-SNAPSHOT</version>
21+
<version>2.0.1-SNAPSHOT</version>
2222
</dependency>
2323
```
2424

@@ -28,7 +28,7 @@ read the [Javadoc](https://hap-java.github.io/HAP-Java/apidocs/index.html)
2828
Supported HomeKit Accessories
2929
=========
3030

31-
Current implementation fully supports 38 HomeKit accessory/services.
31+
Current implementation fully supports 42 HomeKit accessory/services.
3232

3333
| HomeKit Accessory & Service type | Supported by Java-HAP |
3434
|--------------------|--------------------|
@@ -52,6 +52,7 @@ Current implementation fully supports 38 HomeKit accessory/services.
5252
| Heater Cooler | :white_check_mark: |
5353
| Humidifier Dehumidifier | :white_check_mark: |
5454
| Humidity Sensor | :white_check_mark: |
55+
| Input Source | :white_check_mark: |
5556
| Irrigation System | :white_check_mark: |
5657
| Leak Sensor | :white_check_mark: |
5758
| Light Bulb | :white_check_mark: |
@@ -66,12 +67,15 @@ Current implementation fully supports 38 HomeKit accessory/services.
6667
| Service Label | :white_check_mark: |
6768
| Siri | :x: |
6869
| Slat | :white_check_mark: |
70+
| Smart Speaker | :white_check_mark: |
6971
| Smoke Sensor | :white_check_mark: |
7072
| Speaker | :white_check_mark: |
7173
| Stateless Programmable Switch | :white_check_mark: |
7274
| Switch | :white_check_mark: |
7375
| Target Control | :x: |
7476
| Target Control Management | :x: |
77+
| Television | :white_check_mark: |
78+
| Television Speaker | :white_check_mark: |
7579
| Temperature Sensor | :white_check_mark: |
7680
| Thermostat | :white_check_mark: |
7781
| Valve | :white_check_mark: |
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: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package io.github.hapjava.accessories;
2+
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.television.CurrentMediaStateEnum;
5+
import io.github.hapjava.characteristics.impl.television.TargetMediaStateEnum;
6+
import io.github.hapjava.services.Service;
7+
import io.github.hapjava.services.impl.SmartSpeakerService;
8+
import java.util.Collection;
9+
import java.util.Collections;
10+
import java.util.concurrent.CompletableFuture;
11+
12+
/** Smart Speaker accessory. */
13+
public interface SmartSpeakerAccessory extends HomekitAccessory {
14+
15+
/**
16+
* Retrieves the current media state (see {@link
17+
* io.github.hapjava.characteristics.impl.television.CurrentMediaStateEnum} for supported values).
18+
*
19+
* @return a future that will contain the current media state
20+
*/
21+
CompletableFuture<CurrentMediaStateEnum> getCurrentMediaState();
22+
23+
/**
24+
* Subscribes to changes in the current media state.
25+
*
26+
* @param callback the function to call when the current media state changes.
27+
*/
28+
void subscribeCurrentMediaState(HomekitCharacteristicChangeCallback callback);
29+
30+
/** Unsubscribes from changes in the current media state. */
31+
void unsubscribeCurrentMediaState();
32+
33+
/**
34+
* Retrieves the target media state (see {@link TargetMediaStateEnum} for supported values).
35+
*
36+
* @return a future that will contain the target media state
37+
*/
38+
CompletableFuture<TargetMediaStateEnum> getTargetMediaState();
39+
40+
/**
41+
* Set the target media state (see {@link TargetMediaStateEnum} for supported values).
42+
*
43+
* @param targetMediaState target media state
44+
* @return a future that completes when the change is made
45+
*/
46+
CompletableFuture<Void> setTargetMediaState(TargetMediaStateEnum targetMediaState);
47+
48+
/**
49+
* Subscribes to changes in the target media state.
50+
*
51+
* @param callback the function to call when the target media state changes.
52+
*/
53+
void subscribeTargetMediaState(HomekitCharacteristicChangeCallback callback);
54+
55+
/** Unsubscribes from changes in the target media state. */
56+
void unsubscribeTargetMediaState();
57+
58+
@Override
59+
default Collection<Service> getServices() {
60+
return Collections.singleton(new SmartSpeakerService(this));
61+
}
62+
}
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 configured name
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 configured name.
85+
*
86+
* @param callback the function to call when the configureed name changes.
87+
*/
88+
void subscribeConfiguredName(HomekitCharacteristicChangeCallback callback);
89+
90+
/** Unsubscribes from changes in the configured name 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+
}

0 commit comments

Comments
 (0)