|
1 | 1 | package io.github.hapjava.accessories; |
2 | 2 |
|
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; |
4 | 10 | import java.util.concurrent.CompletableFuture; |
5 | 11 |
|
6 | 12 | /** |
7 | | - * Do not use. Devices that have battery levels should implement LowBatteryStatusAccessory. |
| 13 | + * Devices with battery . |
8 | 14 | * |
9 | 15 | * @author Gaston Dombiak |
10 | 16 | */ |
11 | | -@Deprecated |
12 | | -public interface BatteryAccessory { |
| 17 | +public interface BatteryAccessory extends HomekitAccessory { |
13 | 18 |
|
14 | 19 | /** |
15 | 20 | * Retrieves the battery level of the accessory. |
16 | 21 | * |
17 | 22 | * @return a future that will contain the accessory's battery state |
18 | 23 | */ |
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(); |
20 | 40 |
|
21 | 41 | /** |
22 | 42 | * Subscribes to changes in the battery level. |
23 | 43 | * |
24 | 44 | * @param callback the function to call when battery level changes. |
25 | 45 | */ |
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); |
27 | 60 |
|
28 | 61 | /** 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 | + } |
30 | 74 | } |
0 commit comments