All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.hapjava.accessories.LockMechanismAccessory Maven / Gradle / Ivy

There is a newer version: 2.0.7
Show newest version
package io.github.hapjava.accessories;

import io.github.hapjava.characteristics.HomekitCharacteristicChangeCallback;
import io.github.hapjava.characteristics.impl.lock.LockCurrentStateEnum;
import io.github.hapjava.characteristics.impl.lock.LockTargetStateEnum;
import io.github.hapjava.services.Service;
import io.github.hapjava.services.impl.LockMechanismService;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;

/** Lock mechanism with current and target state. */
public interface LockMechanismAccessory extends HomekitAccessory {

  /**
   * Retrieves the lock current state.
   *
   * @return a future that will contain the lock current state .
   */
  CompletableFuture getLockCurrentState();

  /**
   * Retrieves the lock target state.
   *
   * @return a future that will contain the lock target state .
   */
  CompletableFuture getLockTargetState();

  /**
   * set lock target state the lock target state.
   *
   * @param state lock target state
   * @return a future that completes when the change is made
   */
  CompletableFuture setLockTargetState(LockTargetStateEnum state);

  /**
   * Subscribes to changes in the lock current state.
   *
   * @param callback the function to call when the state changes.
   */
  void subscribeLockCurrentState(HomekitCharacteristicChangeCallback callback);

  /** Unsubscribes from changes in lock current state. */
  void unsubscribeLockCurrentState();

  /**
   * Subscribes to changes in the lock target state.
   *
   * @param callback the function to call when the state changes.
   */
  void subscribeLockTargetState(HomekitCharacteristicChangeCallback callback);

  /** Unsubscribes from changes in lock target state. */
  void unsubscribeLockTargetState();

  @Override
  default Collection getServices() {
    return Collections.singleton(new LockMechanismService(this));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy