Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
maxLevel32

Overview

Represents a (zigbee) Light on the network.

As a sub-class of Device ZigbeeDevice, it inherits everything from that interfaceclass and its parent Device class, as well as providing convenience methods for interacting with Lights.

API

on()

Usage

Sends a command over the network to turn the LightDevice on.

Returns a PropertyCommandData object containing the future result of the Property modified by the command.

This is a non-blocking call.

Parameters

None.

Returns

Return TypeDescription
PropertyCommandData

Contains a CompletableFuture<Property> of the property being modified by the command.

Contains the last known (cached) value of the property being modified by the command.

Examples

Code Block
languagejava
GatewayClient gateway = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0"),
...
Collection<Device> lights = gateway.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE) );
for (Device device : lights) {
    LightDevice light = (LightDevice) device;
	light.on();
}

off()

Usage

Sends a command over the network to turn the LightDevice off.

Returns a PropertyCommandData object containing the future result of the Property modified by the command.

This is a non-blocking call.

Parameters

None.

Returns

Return TypeDescription
PropertyCommandData

Contains a CompletableFuture<Property> of the property being modified by the command.

Contains the last known (cached) value of the property being modified by the command.

Examples

Code Block
languagejava
GatewayClient gateway = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0"),
...
Collection<Device> lights = gateway.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE) );
for (Device device : lights) {
    LightDevice light = (LightDevice) device;
	light.off();
}

readLevel()

Usage

Sends a command over the network to read the level of the LightDevice (i.e. the dimming level)

Returns a CompletableFuture of the 'level' Property.

This is a non-blocking call.

Parameters

None.

Returns

Return TypeDescription
CompletableFuture<Property>A CompletableFuture of the 'level' Property.

Examples

Code Block
languagejava
GatewayClient gateway = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0"),
...
Collection<Device> lights = gateway.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE) );
for (Device device : lights) {
    final LightDevice light = (LightDevice) device;
	CompletableFuture<Property> futureLevel = light.readLevel();
    // you can block on the future, or handle it asynchronously
    
    // blocking example
    Property level = futureLevel.get();

    // async example
    futureLevel.thenAccept( levelProperty -> System.out.println("Level: " + levelProperty) );
}

moveToLevel(int levelPercentage)

Usage

Sends a command to move the level of the LightDevice (i.e. the dimming level)

Returns a PropertyCommandData object containing the future result of the Property modified by the command.

This is a non-blocking call.

Parameters

NameTypeDescription
levelPercentageintA value between 0 and 100 representing the dimming level of a light.

Returns

Return TypeDescription
PropertyCommandData

Contains a CompletableFuture<Property> of the property being modified by the command.

Contains the last known (cached) value of the property being modified by the command.

Examples

Code Block
languagejava
GatewayClient gateway = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0"),
...
Collection<Device> lights = gateway.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE) );
for (Device device : lights) {
    LightDevice light = (LightDevice) device;
	light.moveToLevel(50);
}

moveToLevel(int levelPercentage, int transitionTime)

Usage

...Same as moveToLevel, with the addition of a transition time (in tenths of a second, or as close as the remote device is able to adhere to).

Parameters

NameTypeDescription
levelPercentageintA value between 0 and 100 representing the dimming level of a light.
transitionTimeintThe time to transition to the desired dimming level, in tenths of a second (or as close as the remote device is able to adhere to).

Returns

Return TypeDescription
PropertyCommandData

Contains a CompletableFuture<Property> of the property being modified by the command.

Contains the last known (cached) value of the property being modified by the command.

Examples

Code Block
languagejava
GatewayClient gateway = new GatewayClient(new ConnectionInfo(ConnectionType.ZIGBEE_UART, "/dev/ttyUSB0"),
...
Collection<Device> lights = gateway.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE) );
for (Device device : lights) {
    LightDevice light = (LightDevice) device;
	light.moveToLevel(25, 10); // move to 25% dim level, over 1 second
}

getDeviceType()

Usage

Returns the DeviceType that the Device belongs to. DeviceType contains a type and category. For a LightDevice, this would be:

  • Category: Lighting
  • Type: Light

The value returned from this method can be used to search the network for Devices of the same type.

Parameters

None.

Returns

Return TypeDescription
DeviceTypeThe DeviceType object categorizing and identifying the LightDevice.

Examples

Code Block
languagejava
...
Collection<Device> lights = gw.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE));
...
System.out.println("LightDevice type: " + gw.getDevice(idStr).getDeviceType().getType() );
...