Skip to content

Commit 9aa77d5

Browse files
committed
major refactoring to support optional attributes
1 parent 97d066a commit 9aa77d5

File tree

345 files changed

+6100
-4241
lines changed

Some content is hidden

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

345 files changed

+6100
-4241
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>hap</artifactId>
66
<name>hap-java</name>
77
<description>Homekit Accessory Protocol for Java</description>
8-
<version>1.2.0-snapshot</version>
8+
<version>2.0.0-snapshot</version>
99
<packaging>jar</packaging>
1010
<url>https://github.com/hap-java/HAP-Java</url>
1111

@@ -165,7 +165,7 @@
165165
<artifactId>maven-javadoc-plugin</artifactId>
166166
<version>3.0.1</version>
167167
<configuration>
168-
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
168+
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
169169
</configuration>
170170
<executions>
171171
<execution>
@@ -272,7 +272,7 @@
272272
<artifactId>maven-javadoc-plugin</artifactId>
273273
<version>3.0.1</version>
274274
<configuration>
275-
<excludePackageNames>io.github.hapjava.impl</excludePackageNames>
275+
<excludePackageNames>io.github.hapjava.server.impl</excludePackageNames>
276276
</configuration>
277277
<reportSets>
278278
<reportSet>
Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,74 @@
11
package io.github.hapjava.accessories;
22

3-
import io.github.hapjava.HomekitCharacteristicChangeCallback;
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.battery.ChargingStateEnum;
5+
import io.github.hapjava.characteristics.impl.battery.StatusLowBatteryEnum;
6+
import io.github.hapjava.services.Service;
7+
import io.github.hapjava.services.impl.BatteryService;
8+
import java.util.Collection;
9+
import java.util.Collections;
410
import java.util.concurrent.CompletableFuture;
511

612
/**
7-
* Do not use. Devices that have battery levels should implement LowBatteryStatusAccessory.
13+
* Devices with battery .
814
*
915
* @author Gaston Dombiak
1016
*/
11-
@Deprecated
12-
public interface BatteryAccessory {
17+
public interface BatteryAccessory extends HomekitAccessory {
1318

1419
/**
1520
* Retrieves the battery level of the accessory.
1621
*
1722
* @return a future that will contain the accessory's battery state
1823
*/
19-
CompletableFuture<Integer> getBatteryLevelState();
24+
CompletableFuture<Integer> getBatteryLevel();
25+
26+
/**
27+
* Queries if the device battery level is low; returning a value of true will cause a low-battery
28+
* status to appear in Home for the device.
29+
*
30+
* @return a future that will contain the accessory's low battery state
31+
*/
32+
CompletableFuture<StatusLowBatteryEnum> getLowBatteryState();
33+
34+
/**
35+
* Retriece the battery charging state.
36+
*
37+
* @return a future that will contain the battery charging state
38+
*/
39+
CompletableFuture<ChargingStateEnum> getChargingState();
2040

2141
/**
2242
* Subscribes to changes in the battery level.
2343
*
2444
* @param callback the function to call when battery level changes.
2545
*/
26-
void subscribeBatteryLevelState(HomekitCharacteristicChangeCallback callback);
46+
void subscribeBatteryLevel(HomekitCharacteristicChangeCallback callback);
47+
/**
48+
* Subscribes to changes in the battery level.
49+
*
50+
* @param callback the function to call when low battery state changes.
51+
*/
52+
void subscribeLowBatteryState(HomekitCharacteristicChangeCallback callback);
53+
54+
/**
55+
* Subscribes to changes in the battery level.
56+
*
57+
* @param callback the function to call when low battery state changes.
58+
*/
59+
void subscribeBatteryChargingState(HomekitCharacteristicChangeCallback callback);
2760

2861
/** Unsubscribes from changes in the battery level. */
29-
void unsubscribeBatteryLevelState();
62+
void unsubscribeBatteryLevel();
63+
64+
/** Unsubscribes from changes in the low battery state. */
65+
void unsubscribeLowBatteryState();
66+
67+
/** Unsubscribes from changes in the low battery state. */
68+
void unsubscribeBatteryChargingState();
69+
70+
@Override
71+
default Collection<Service> getServices() {
72+
return Collections.singleton(new BatteryService(this));
73+
}
3074
}

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

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/java/io/github/hapjava/impl/accessories/Bridge.java renamed to src/main/java/io/github/hapjava/accessories/Bridge.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package io.github.hapjava.impl.accessories;
2-
3-
import io.github.hapjava.HomekitAccessory;
1+
package io.github.hapjava.accessories;
42

53
public interface Bridge extends HomekitAccessory {
64

src/main/java/io/github/hapjava/accessories/CarbonDioxideSensor.java renamed to src/main/java/io/github/hapjava/accessories/CarbonDioxideSensorAccessory.java

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.hapjava.accessories;
22

3-
import io.github.hapjava.HomekitAccessory;
4-
import io.github.hapjava.HomekitCharacteristicChangeCallback;
5-
import io.github.hapjava.Service;
6-
import io.github.hapjava.accessories.properties.CarbonDioxideDetectedState;
7-
import io.github.hapjava.impl.services.CarbonDioxideSensorService;
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.carbondioxidesensor.CarbonDioxideDetectedEnum;
5+
import io.github.hapjava.services.Service;
6+
import io.github.hapjava.services.impl.CarbonDioxideSensorService;
87
import java.util.Collection;
98
import java.util.Collections;
109
import java.util.concurrent.CompletableFuture;
@@ -13,23 +12,18 @@
1312
* A carbon dioxide sensor reports whether carbon dioxide has been detected or not.
1413
*
1514
* <p>Carbon dioxide sensors that run on batteries will need to implement this interface and also
16-
* implement {@link BatteryStatusAccessory}.
15+
* implement {@link BatteryAccessory}.
1716
*
1817
* @author Eugen Freiter
1918
*/
20-
public interface CarbonDioxideSensor extends HomekitAccessory {
19+
public interface CarbonDioxideSensorAccessory extends HomekitAccessory {
2120

2221
/**
2322
* Retrieves the state of the sensor that indicates if carbon dioxide has been detected.
2423
*
2524
* @return a future that will contain the carbon dioxide sensor's state
2625
*/
27-
CompletableFuture<CarbonDioxideDetectedState> getCarbonDioxideDetectedState();
28-
29-
@Override
30-
default Collection<Service> getServices() {
31-
return Collections.singleton(new CarbonDioxideSensorService(this));
32-
}
26+
CompletableFuture<CarbonDioxideDetectedEnum> getCarbonDioxideDetectedState();
3327

3428
/**
3529
* Subscribes to changes in the carbon dioxide's state.
@@ -38,23 +32,11 @@ default Collection<Service> getServices() {
3832
*/
3933
void subscribeCarbonDioxideDetectedState(HomekitCharacteristicChangeCallback callback);
4034

41-
/**
42-
* Retrieves the carbon dioxide level
43-
*
44-
* @return a future that will contain the carbon dioxide level as a value between 0 and 100000
45-
*/
46-
CompletableFuture<Double> getCarbonDioxideLevel();
47-
4835
/** Unsubscribes from changes in the carbon dioxide's state. */
4936
void unsubscribeCarbonDioxideDetectedState();
5037

51-
/**
52-
* Subscribes to changes in the carbon dioxide level.
53-
*
54-
* @param callback the function to call when the state changes.
55-
*/
56-
void subscribeCarbonDioxideLevel(HomekitCharacteristicChangeCallback callback);
57-
58-
/** Unsubscribes from changes in the carbon dioxide level. */
59-
void unsubscribeCarbonDioxideLevel();
38+
@Override
39+
default Collection<Service> getServices() {
40+
return Collections.singleton(new CarbonDioxideSensorService(this));
41+
}
6042
}

src/main/java/io/github/hapjava/accessories/CarbonMonoxideSensor.java renamed to src/main/java/io/github/hapjava/accessories/CarbonMonoxideSensorAccessory.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.hapjava.accessories;
22

3-
import io.github.hapjava.HomekitAccessory;
4-
import io.github.hapjava.HomekitCharacteristicChangeCallback;
5-
import io.github.hapjava.Service;
6-
import io.github.hapjava.accessories.properties.CarbonMonoxideDetectedState;
7-
import io.github.hapjava.impl.services.CarbonMonoxideSensorService;
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.carbonmonoxidesensor.CarbonMonoxideDetectedEnum;
5+
import io.github.hapjava.services.Service;
6+
import io.github.hapjava.services.impl.CarbonMonoxideSensorService;
87
import java.util.Collection;
98
import java.util.Collections;
109
import java.util.concurrent.CompletableFuture;
@@ -13,23 +12,18 @@
1312
* A carbon monoxide sensor reports whether carbon monoxide has been detected or not.
1413
*
1514
* <p>Carbon monoxide sensors that run on batteries will need to implement this interface and also
16-
* implement {@link BatteryStatusAccessory}.
15+
* implement {@link BatteryAccessory}.
1716
*
1817
* @author Gaston Dombiak
1918
*/
20-
public interface CarbonMonoxideSensor extends HomekitAccessory {
19+
public interface CarbonMonoxideSensorAccessory extends HomekitAccessory {
2120

2221
/**
2322
* Retrieves the state of the sensor that indicates if carbon monoxide has been detected.
2423
*
2524
* @return a future that will contain the carbon monoxide sensor's state
2625
*/
27-
CompletableFuture<CarbonMonoxideDetectedState> getCarbonMonoxideDetectedState();
28-
29-
@Override
30-
default Collection<Service> getServices() {
31-
return Collections.singleton(new CarbonMonoxideSensorService(this));
32-
}
26+
CompletableFuture<CarbonMonoxideDetectedEnum> getCarbonMonoxideDetectedState();
3327

3428
/**
3529
* Subscribes to changes in the carbon monoxide's state.
@@ -40,4 +34,9 @@ default Collection<Service> getServices() {
4034

4135
/** Unsubscribes from changes in the carbon monoxide's state. */
4236
void unsubscribeCarbonMonoxideDetectedState();
37+
38+
@Override
39+
default Collection<Service> getServices() {
40+
return Collections.singleton(new CarbonMonoxideSensorService(this));
41+
}
4342
}

src/main/java/io/github/hapjava/accessories/ContactSensor.java renamed to src/main/java/io/github/hapjava/accessories/ContactSensorAccessory.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package io.github.hapjava.accessories;
22

3-
import io.github.hapjava.HomekitAccessory;
4-
import io.github.hapjava.HomekitCharacteristicChangeCallback;
5-
import io.github.hapjava.Service;
6-
import io.github.hapjava.accessories.properties.ContactState;
7-
import io.github.hapjava.impl.services.ContactSensorService;
3+
import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
4+
import io.github.hapjava.characteristics.impl.contactsensor.ContactStateEnum;
5+
import io.github.hapjava.services.Service;
6+
import io.github.hapjava.services.impl.ContactSensorService;
87
import java.util.Collection;
98
import java.util.Collections;
109
import java.util.concurrent.CompletableFuture;
@@ -14,24 +13,19 @@
1413
* window/door sensors. When contact is detected it means that the door/window is closed.
1514
*
1615
* <p>Contact sensors that run on batteries will need to implement this interface and also implement
17-
* {@link BatteryStatusAccessory}.
16+
* {@link BatteryAccessory}.
1817
*
1918
* @author Gaston Dombiak
2019
*/
21-
public interface ContactSensor extends HomekitAccessory {
20+
public interface ContactSensorAccessory extends HomekitAccessory {
2221

2322
/**
2423
* Retrieves the state of the contact. This is whether the contact is detected or not. Detected
2524
* contact means door/window is closed.
2625
*
2726
* @return a future that will contain the contact's state
2827
*/
29-
CompletableFuture<ContactState> getCurrentState();
30-
31-
@Override
32-
default Collection<Service> getServices() {
33-
return Collections.singleton(new ContactSensorService(this));
34-
}
28+
CompletableFuture<ContactStateEnum> getCurrentState();
3529

3630
/**
3731
* Subscribes to changes in the contact state.
@@ -42,4 +36,9 @@ default Collection<Service> getServices() {
4236

4337
/** Unsubscribes from changes in the contact state. */
4438
void unsubscribeContactState();
39+
40+
@Override
41+
default Collection<Service> getServices() {
42+
return Collections.singleton(new ContactSensorService(this));
43+
}
4544
}

0 commit comments

Comments
 (0)