Search in sources :

Example 1 with WriteAttributesCommand

use of com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesCommand in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclGeneralCluster method writeAttributesCommand.

/**
 * The Write Attributes Command
 * <p>
 * The write attributes command is generated when a device wishes to change the
 * values of one or more attributes located on another device. Each write attribute
 * record shall contain the identifier and the actual value of the attribute to be
 * written.
 *
 * @param records {@link List<WriteAttributeRecord>} Records
 * @return the {@link Future<CommandResult>} command result future
 */
public Future<CommandResult> writeAttributesCommand(List<WriteAttributeRecord> records) {
    WriteAttributesCommand command = new WriteAttributesCommand();
    // Set the fields
    command.setRecords(records);
    return send(command);
}
Also used : WriteAttributesCommand(com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesCommand)

Example 2 with WriteAttributesCommand

use of com.zsmartsystems.zigbee.zcl.clusters.general.WriteAttributesCommand 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)2 WriteAttributeRecord (com.zsmartsystems.zigbee.zcl.field.WriteAttributeRecord)1