Package io.github.hapjava.accessories
Interface SwitchAccessory
-
- All Superinterfaces:
HomekitAccessory
public interface SwitchAccessory extends HomekitAccessory
A simple switch with a binary state.- Author:
- Andy Lintner
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Collection<Service>
getServices()
The collection of Services this accessory supports.java.util.concurrent.CompletableFuture<java.lang.Boolean>
getSwitchState()
Retrieves the current binary state of the switch.java.util.concurrent.CompletableFuture<java.lang.Void>
setSwitchState(boolean state)
Sets the binary state of the switchvoid
subscribeSwitchState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the binary state of the switch.void
unsubscribeSwitchState()
Unsubscribes from changes in the binary state of the switch.-
Methods inherited from interface io.github.hapjava.accessories.HomekitAccessory
getFirmwareRevision, getId, getManufacturer, getModel, getName, getPrimaryService, getSerialNumber, identify
-
-
-
-
Method Detail
-
getSwitchState
java.util.concurrent.CompletableFuture<java.lang.Boolean> getSwitchState()
Retrieves the current binary state of the switch.- Returns:
- a future that will contain the binary state
-
setSwitchState
java.util.concurrent.CompletableFuture<java.lang.Void> setSwitchState(boolean state) throws java.lang.Exception
Sets the binary state of the switch- Parameters:
state
- the binary state to set- Returns:
- a future that completes when the change is made
- Throws:
java.lang.Exception
- when the change cannot be made
-
subscribeSwitchState
void subscribeSwitchState(HomekitCharacteristicChangeCallback callback)
Subscribes to changes in the binary state of the switch.- Parameters:
callback
- the function to call when the state changes.
-
unsubscribeSwitchState
void unsubscribeSwitchState()
Unsubscribes from changes in the binary state of the switch.
-
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.
-
-