Package io.github.hapjava.accessories
Interface BatteryAccessory
-
- All Superinterfaces:
HomekitAccessory
public interface BatteryAccessory extends HomekitAccessory
Devices with battery .- Author:
- Gaston Dombiak
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Integer>
getBatteryLevel()
Retrieves the battery level of the accessory.java.util.concurrent.CompletableFuture<ChargingStateEnum>
getChargingState()
Retriece the battery charging state.java.util.concurrent.CompletableFuture<StatusLowBatteryEnum>
getLowBatteryState()
Queries if the device battery level is low; returning a value of true will cause a low-battery status to appear in Home for the device.default java.util.Collection<Service>
getServices()
The collection of Services this accessory supports.void
subscribeBatteryChargingState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.void
subscribeBatteryLevel(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.void
subscribeLowBatteryState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.void
unsubscribeBatteryChargingState()
Unsubscribes from changes in the low battery state.void
unsubscribeBatteryLevel()
Unsubscribes from changes in the battery level.void
unsubscribeLowBatteryState()
Unsubscribes from changes in the low battery state.-
Methods inherited from interface io.github.hapjava.accessories.HomekitAccessory
getFirmwareRevision, getId, getManufacturer, getModel, getName, getPrimaryService, getSerialNumber, identify
-
-
-
-
Method Detail
-
getBatteryLevel
java.util.concurrent.CompletableFuture<java.lang.Integer> getBatteryLevel()
Retrieves the battery level of the accessory.- Returns:
- a future that will contain the accessory's battery state
-
getLowBatteryState
java.util.concurrent.CompletableFuture<StatusLowBatteryEnum> getLowBatteryState()
Queries if the device battery level is low; returning a value of true will cause a low-battery status to appear in Home for the device.- Returns:
- a future that will contain the accessory's low battery state
-
getChargingState
java.util.concurrent.CompletableFuture<ChargingStateEnum> getChargingState()
Retriece the battery charging state.- Returns:
- a future that will contain the battery charging state
-
subscribeBatteryLevel
void subscribeBatteryLevel(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.- Parameters:
callback
- the function to call when battery level changes.
-
subscribeLowBatteryState
void subscribeLowBatteryState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.- Parameters:
callback
- the function to call when low battery state changes.
-
subscribeBatteryChargingState
void subscribeBatteryChargingState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the battery level.- Parameters:
callback
- the function to call when low battery state changes.
-
unsubscribeBatteryLevel
void unsubscribeBatteryLevel()
Unsubscribes from changes in the battery level.
-
unsubscribeLowBatteryState
void unsubscribeLowBatteryState()
Unsubscribes from changes in the low battery state.
-
unsubscribeBatteryChargingState
void unsubscribeBatteryChargingState()
Unsubscribes from changes in the low battery state.
-
getServices
default java.util.Collection<Service> getServices()
Description copied from interface:HomekitAccessory
The collection of Services this accessory supports. Services are the primary way to interact with the accessory via HomeKit. Besides the Services offered here, the accessory will automatically include the required information service.This method will only be useful if you're implementing your own accessory type. For the standard accessories, use the default implementation provided by the interfaces in
io.github.hapjava.accessories
.- Specified by:
getServices
in interfaceHomekitAccessory
- Returns:
- the collection of services.
-
-