LightDevice
Overview
Represents a (zigbee) Light on the network.
As a sub-class of ZigbeeDevice, it inherits everything from that class 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 Type | Description |
---|---|
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
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 Type | Description |
---|---|
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
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 Type | Description |
---|---|
CompletableFuture<Property> | A CompletableFuture of the 'level' Property. |
Examples
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
Name | Type | Description |
---|---|---|
levelPercentage | int | A value between 0 and 100 representing the dimming level of a light. |
Returns
Return Type | Description |
---|---|
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
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
Name | Type | Description |
---|---|---|
levelPercentage | int | A value between 0 and 100 representing the dimming level of a light. |
transitionTime | int | The 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 Type | Description |
---|---|
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
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 Type | Description |
---|---|
DeviceType | The DeviceType object categorizing and identifying the LightDevice. |
Examples
... Collection<Device> lights = gw.getDevices( d -> d.getDeviceType().equals(LightDevice.DEVICE_TYPE)); ... System.out.println("LightDevice type: " + gw.getDevice(idStr).getDeviceType().getType() ); ...
Legal Notices
Copyright © 2020 MMB Networks, Inc. All rights reserved.
Confidential materials prepared and delivered by MMB Networks for receipt and review only by any partner subject to a valid and enforceable MMB Networks confidentiality agreement. Any receipt, review, or misuse of any of the content exchanged hereunder by any party not a party to this confidential exchange shall be subject to any and all rights available under the law. All rights, title and interest to the materials shall remain with MMB Networks.
Any suggestions provided to MMB Networks with respect to MMB Networks' products or services shall be collectively deemed “Feedback.” You, on behalf of yourself, or if you are providing Feedback on behalf of your employer or another entity, represent and warrant that you have full legal authority to bind such entity to these terms, agree to grant and hereby grant to MMB Networks a nonexclusive, perpetual, irrevocable, royalty free, worldwide license to use and otherwise exploit such Feedback within any MMB Networks products and services.