Versions Compared

Key

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

...

Code Block
languagejava
titleGetting the Properties of the Remote DeviceDiscovering Properties
linenumberstrue
if (event.getStatus() == DeviceEventStatus.ADD) {
    final Collection<Property> properties = event.getDevice().getProperties();
    for (Property p : properties) {
        System.out.println("name: " + p.getName() + ", value: " + p.getValue() + ", type: " + p.getType());
    }
}

Updating Properties

You can update a Device Property as follows

Code Block
languagejava
titleUpdating a Property
linenumberstrue
final Device d = gw.getDevice(idStr);
Property property = new Property(propertyId, "", writeValue);
d.updateProperty(property).getFuture().whenComplete( (result, throwable) -> {
    if (throwable != null) {
        System.out.println("error: " + throwable.getMessage());
    } else if (result != null) {
        System.out.println("result: " + result.getValue());
    }
});

Conclusion

...