use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleReportingUnsubscribeCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length != 6) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
final int clusterId = parseCluster(args[3]);
final ZclCluster cluster;
final String direction = args[2].toUpperCase();
if ("IN".equals(direction)) {
cluster = endpoint.getInputCluster(clusterId);
} else if ("OUT".equals(direction)) {
cluster = endpoint.getOutputCluster(clusterId);
} else {
throw new IllegalArgumentException("Cluster direction must be IN or OUT");
}
final int attributeId = parseAttribute(args[4]);
final ZclAttribute attribute = cluster.getAttribute(attributeId);
final CommandResult result = cluster.setReporting(attribute, 0, 0xFFFF, null).get();
if (result.isSuccess()) {
final ConfigureReportingResponse response = result.getResponse();
final ZclStatus statusCode = response.getRecords().get(0).getStatus();
if (statusCode == ZclStatus.SUCCESS) {
out.println("Attribute value configure reporting success.");
} else {
out.println("Attribute value configure reporting error: " + statusCode);
}
} else {
out.println("Error executing command: " + result);
}
}
use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleAttributeReadCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length != 4) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
final Integer clusterId = parseCluster(args[2]);
ZclCluster cluster = endpoint.getInputCluster(clusterId);
if (cluster != null) {
out.println("Using input cluster");
} else {
cluster = endpoint.getOutputCluster(clusterId);
if (cluster != null) {
out.println("Using output cluster");
} else {
out.println("Cluster not found");
return;
}
}
final Integer attributeId = parseAttribute(args[3]);
String attributeName;
ZclAttribute attribute = cluster.getAttribute(attributeId);
if (attribute == null) {
attributeName = "Attribute " + attributeId;
} else {
attributeName = attribute.getName();
}
out.println("Reading " + cluster.getClusterName() + ", " + attributeName);
CommandResult result;
result = cluster.read(attributeId).get();
if (result.isSuccess()) {
final ReadAttributesResponse response = result.getResponse();
if (response.getRecords().size() == 0) {
out.println("No records returned");
return;
}
final ZclStatus statusCode = response.getRecords().get(0).getStatus();
if (statusCode == ZclStatus.SUCCESS) {
out.println("Cluster " + String.format("%04X", response.getClusterId()) + ", Attribute " + response.getRecords().get(0).getAttributeIdentifier() + ", type " + response.getRecords().get(0).getAttributeDataType() + ", value: " + response.getRecords().get(0).getAttributeValue());
} else {
out.println("Attribute value read error: " + statusCode);
}
return;
} else {
out.println("Error executing command: " + result);
return;
}
}
use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeConsoleAttributeSupportedCommand method process.
@Override
public void process(ZigBeeNetworkManager networkManager, String[] args, PrintStream out) throws IllegalArgumentException, InterruptedException, ExecutionException {
if (args.length != 3) {
throw new IllegalArgumentException("Invalid number of arguments");
}
final ZigBeeEndpoint endpoint = getEndpoint(networkManager, args[1]);
final Integer clusterId = parseCluster(args[2]);
ZclCluster cluster = endpoint.getInputCluster(clusterId);
if (cluster != null) {
out.println("Using input cluster");
} else {
cluster = endpoint.getOutputCluster(clusterId);
if (cluster != null) {
out.println("Using output cluster");
} else {
out.println("Cluster not found");
return;
}
}
final Future<Boolean> future = cluster.discoverAttributes(false);
Boolean result = future.get();
if (result) {
out.println("Supported attributes for " + cluster.getClusterName() + " Cluster " + printClusterId(cluster.getClusterId()));
out.println("AttrId Data Type Name");
for (Integer attributeId : cluster.getSupportedAttributes()) {
out.print(" ");
ZclAttribute attribute = cluster.getAttribute(attributeId);
out.print(printAttributeId(attributeId));
if (attribute != null) {
out.print(" " + printZclDataType(attribute.getDataType()) + " " + attribute.getName());
}
out.println();
}
} else {
out.println("Failed to retrieve supported attributes");
}
}
use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclIasZoneCluster method initializeAttributes.
// Attribute initialisation
protected Map<Integer, ZclAttribute> initializeAttributes() {
Map<Integer, ZclAttribute> attributeMap = new ConcurrentHashMap<Integer, ZclAttribute>(7);
attributeMap.put(ATTR_ZONESTATE, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_ZONESTATE, "ZoneState", ZclDataType.ENUMERATION_8_BIT, true, true, false, false));
attributeMap.put(ATTR_ZONETYPE, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_ZONETYPE, "ZoneType", ZclDataType.ENUMERATION_16_BIT, true, true, false, false));
attributeMap.put(ATTR_ZONESTATUS, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_ZONESTATUS, "ZoneStatus", ZclDataType.BITMAP_16_BIT, true, true, false, false));
attributeMap.put(ATTR_IASCIEADDRESS, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_IASCIEADDRESS, "IASCIEAddress", ZclDataType.IEEE_ADDRESS, true, true, true, false));
attributeMap.put(ATTR_ZONEID, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_ZONEID, "ZoneID", ZclDataType.UNSIGNED_8_BIT_INTEGER, true, true, false, false));
attributeMap.put(ATTR_NUMBEROFZONESENSITIVITYLEVELSSUPPORTED, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_NUMBEROFZONESENSITIVITYLEVELSSUPPORTED, "NumberOfZoneSensitivityLevelsSupported", ZclDataType.UNSIGNED_8_BIT_INTEGER, false, true, false, false));
attributeMap.put(ATTR_CURRENTZONESENSITIVITYLEVEL, new ZclAttribute(ZclClusterType.IAS_ZONE, ATTR_CURRENTZONESENSITIVITYLEVEL, "CurrentZoneSensitivityLevel", ZclDataType.UNSIGNED_8_BIT_INTEGER, false, true, true, false));
return attributeMap;
}
use of com.zsmartsystems.zigbee.zcl.ZclAttribute in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclPressureMeasurementCluster method initializeAttributes.
// Attribute initialisation
protected Map<Integer, ZclAttribute> initializeAttributes() {
Map<Integer, ZclAttribute> attributeMap = new ConcurrentHashMap<Integer, ZclAttribute>(9);
attributeMap.put(ATTR_MEASUREDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_MEASUREDVALUE, "MeasuredValue", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, true));
attributeMap.put(ATTR_MINMEASUREDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_MINMEASUREDVALUE, "MinMeasuredValue", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, false));
attributeMap.put(ATTR_MAXMEASUREDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_MAXMEASUREDVALUE, "MaxMeasuredValue", ZclDataType.SIGNED_16_BIT_INTEGER, true, true, false, true));
attributeMap.put(ATTR_TOLERANCE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_TOLERANCE, "Tolerance", ZclDataType.UNSIGNED_16_BIT_INTEGER, false, true, false, false));
attributeMap.put(ATTR_SCALEDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_SCALEDVALUE, "ScaledValue", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, true));
attributeMap.put(ATTR_MINSCALEDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_MINSCALEDVALUE, "MinScaledValue", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, false));
attributeMap.put(ATTR_MAXSCALEDVALUE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_MAXSCALEDVALUE, "MaxScaledValue", ZclDataType.SIGNED_16_BIT_INTEGER, false, true, false, false));
attributeMap.put(ATTR_SCALEDTOLERANCE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_SCALEDTOLERANCE, "ScaledTolerance", ZclDataType.UNSIGNED_16_BIT_INTEGER, false, true, false, true));
attributeMap.put(ATTR_SCALE, new ZclAttribute(ZclClusterType.PRESSURE_MEASUREMENT, ATTR_SCALE, "Scale", ZclDataType.UNSIGNED_8_BIT_INTEGER, false, true, false, false));
return attributeMap;
}
Aggregations