Interface BatteryAccessory

    • 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 interface HomekitAccessory
        Returns:
        the collection of services.