Search in sources :

Example 1 with WriteAttributeRecord

use of com.zsmartsystems.zigbee.zcl.field.WriteAttributeRecord in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclCluster method write.

/**
 * Write an attribute
 *
 * @param attribute the attribute ID to write
 * @param dataType the {@link ZclDataType} of the object
 * @param value the value to set (as {@link Object})
 * @return command future {@link CommandResult}
 */
public Future<CommandResult> write(final int attribute, final ZclDataType dataType, final Object value) {
    logger.debug("{}: Writing cluster {}, attribute {}, value {}, as dataType {}", clusterId, attribute, value, dataType);
    final WriteAttributesCommand command = new WriteAttributesCommand();
    command.setClusterId(clusterId);
    final WriteAttributeRecord attributeIdentifier = new WriteAttributeRecord();
    attributeIdentifier.setAttributeIdentifier(attribute);
    attributeIdentifier.setAttributeDataType(dataType);
    attributeIdentifier.setAttributeValue(value);
    command.setRecords(Collections.singletonList(attributeIdentifier));
    command.setDestinationAddress(zigbeeEndpoint.getEndpointAddress());
    return send(command);
}
Also used : WriteAttributeRecord(com.zsmartsystems.zigbee.zcl.field.WriteAttributeRecord) WriteAttributesCommand(com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesCommand)

Aggregations

WriteAttributesCommand (com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesCommand)1 WriteAttributeRecord (com.zsmartsystems.zigbee.zcl.field.WriteAttributeRecord)1