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

io.github.hapjava.accessories.StatelessProgrammableSwitchAccessory 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.common.ProgrammableSwitchEnum;
import io.github.hapjava.services.Service;
import io.github.hapjava.services.impl.StatelessProgrammableSwitchService;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;

/** The Stateless Programmable Switch accessory */
public interface StatelessProgrammableSwitchAccessory extends HomekitAccessory {

  /**
   * Retrieves the last states of the switch. Bluetooth device should return the last event, the IP
   * device should always return null
   *
   * @return state of the switch event
   */
  CompletableFuture getSwitchEvent();

  /**
   * Subscribes to changes in switch event, i.e. pressing on the button.
   *
   * @param callback the function to call when the state changes.
   */
  void subscribeSwitchEvent(HomekitCharacteristicChangeCallback callback);

  /** Unsubscribes from changes in switch event. */
  void unsubscribeSwitchEvent();

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy