use of com.zsmartsystems.zigbee.zcl.field.AttributeReport in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclCluster method handleAttributeReport.
/**
* Processes a list of attribute reports for this cluster
*
* @param reports {@List} of {@link AttributeReport}
*/
public void handleAttributeReport(List<AttributeReport> reports) {
for (AttributeReport report : reports) {
ZclAttribute attribute = attributes.get(report.getAttributeIdentifier());
if (attribute == null) {
logger.debug("{}: Unknown attribute {} in cluster {}", zigbeeEndpoint.getEndpointAddress(), report.getAttributeIdentifier(), clusterId);
} else {
attribute.updateValue(normalizer.normalizeZclData(attribute.getDataType(), report.getAttributeValue()));
notifyAttributeListener(attribute);
}
}
}
use of com.zsmartsystems.zigbee.zcl.field.AttributeReport in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZclClusterTest method handleAttributeReport.
@Test
public void handleAttributeReport() {
createNetworkManager();
ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
node.setNetworkAddress(1234);
ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
ZclAttributeListener listenerMock = Mockito.mock(ZclAttributeListener.class);
ArgumentCaptor<ZclAttribute> attributeCapture = ArgumentCaptor.forClass(ZclAttribute.class);
cluster.addAttributeListener(listenerMock);
List<AttributeReport> attributeList = new ArrayList<AttributeReport>();
AttributeReport report;
report = new AttributeReport();
report.setAttributeDataType(ZclDataType.SIGNED_8_BIT_INTEGER);
report.setAttributeIdentifier(0);
report.setAttributeValue(Integer.valueOf(1));
System.out.println(report);
attributeList.add(report);
cluster.handleAttributeReport(attributeList);
ZclAttribute attribute = cluster.getAttribute(0);
assertTrue(attribute.getLastValue() instanceof Boolean);
Mockito.verify(listenerMock, Mockito.timeout(1000).times(1)).attributeUpdated(attributeCapture.capture());
attribute = attributeCapture.getValue();
assertTrue(attribute.getLastValue() instanceof Boolean);
assertEquals(ZclDataType.BOOLEAN, attribute.getDataType());
assertEquals(0, attribute.getId());
assertEquals(true, attribute.getLastValue());
}
Aggregations