Search in sources :

Example 1 with ZclOnOffCluster

use of com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method unbind.

@Test
public void unbind() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    cluster.unbind(new IeeeAddress("1234567890ABCDEF"), 11);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof UnbindRequest);
    UnbindRequest unbindCommand = (UnbindRequest) command;
    assertEquals(new ZigBeeEndpointAddress(1234, 0), unbindCommand.getDestinationAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), unbindCommand.getDstAddress());
    assertEquals(Integer.valueOf(5), unbindCommand.getSrcEndpoint());
    assertEquals(Integer.valueOf(11), unbindCommand.getDstEndpoint());
    assertEquals(Integer.valueOf(3), unbindCommand.getDstAddrMode());
    assertEquals(Integer.valueOf(0x0022), unbindCommand.getClusterId());
    assertEquals(Integer.valueOf(6), unbindCommand.getBindCluster());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) UnbindRequest(com.zsmartsystems.zigbee.zdo.command.UnbindRequest) Test(org.junit.Test)

Example 2 with ZclOnOffCluster

use of com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method getReporting.

@Test
public void getReporting() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    ZclAttribute attribute = cluster.getAttribute(0);
    cluster.getReporting(attribute);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof ReadReportingConfigurationCommand);
    ReadReportingConfigurationCommand cfgCommand = (ReadReportingConfigurationCommand) command;
    assertEquals(1, cfgCommand.getRecords().size());
    AttributeRecord record = cfgCommand.getRecords().get(0);
    assertEquals(0, record.getAttributeIdentifier());
    assertEquals(0, record.getDirection());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) AttributeRecord(com.zsmartsystems.zigbee.zcl.field.AttributeRecord) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) ReadReportingConfigurationCommand(com.zsmartsystems.zigbee.zcl.clusters.general.ReadReportingConfigurationCommand) Test(org.junit.Test)

Example 3 with ZclOnOffCluster

use of com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeApi method on.

/**
 * Switches destination on.
 *
 * @param destination the {@link ZigBeeAddress}
 * @return the command result future.
 */
public Future<CommandResult> on(final ZigBeeAddress destination) {
    if (!(destination instanceof ZigBeeEndpointAddress)) {
        return null;
    }
    ZigBeeEndpointAddress endpointAddress = (ZigBeeEndpointAddress) destination;
    ZigBeeEndpoint endpoint = networkManager.getNode(endpointAddress.getAddress()).getEndpoint(endpointAddress.getEndpoint());
    if (endpoint == null) {
        return null;
    }
    ZclOnOffCluster cluster = (ZclOnOffCluster) endpoint.getInputCluster(ZclOnOffCluster.CLUSTER_ID);
    return cluster.onCommand();
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint)

Example 4 with ZclOnOffCluster

use of com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method bind.

@Test
public void bind() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    cluster.bind(new IeeeAddress("1234567890ABCDEF"), 11);
    assertEquals(1, commandCapture.getAllValues().size());
    ZigBeeCommand command = commandCapture.getValue();
    assertNotNull(command);
    System.out.println(command);
    assertTrue(command instanceof BindRequest);
    BindRequest bindCommand = (BindRequest) command;
    assertEquals(new ZigBeeEndpointAddress(1234, 0), bindCommand.getDestinationAddress());
    assertEquals(new IeeeAddress("1234567890ABCDEF"), bindCommand.getDstAddress());
    assertEquals(Integer.valueOf(5), bindCommand.getSrcEndpoint());
    assertEquals(Integer.valueOf(11), bindCommand.getDstEndpoint());
    assertEquals(Integer.valueOf(3), bindCommand.getDstAddrMode());
    assertEquals(Integer.valueOf(0x0021), bindCommand.getClusterId());
    assertEquals(Integer.valueOf(6), bindCommand.getBindCluster());
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeCommand(com.zsmartsystems.zigbee.ZigBeeCommand) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) BindRequest(com.zsmartsystems.zigbee.zdo.command.BindRequest) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 5 with ZclOnOffCluster

use of com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZclClusterTest method isAttributeSupported.

@Test
public void isAttributeSupported() {
    createNetworkManager();
    ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress());
    node.setNetworkAddress(1234);
    ZigBeeEndpoint device = new ZigBeeEndpoint(networkManager, node, 5);
    ZclCluster cluster = new ZclOnOffCluster(networkManager, device);
    Set<Integer> set = new HashSet<Integer>();
    set.add(1);
    set.add(4);
    set.add(2);
    setSupportedClusters(cluster, set);
    assertEquals(3, cluster.getSupportedAttributes().size());
    assertTrue(cluster.isAttributeSupported(1));
    assertTrue(cluster.isAttributeSupported(2));
    assertFalse(cluster.isAttributeSupported(3));
}
Also used : ZclOnOffCluster(com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster) ZigBeeNode(com.zsmartsystems.zigbee.ZigBeeNode) ZigBeeEndpoint(com.zsmartsystems.zigbee.ZigBeeEndpoint) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)8 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)8 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)7 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)7 Test (org.junit.Test)7 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)4 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)3 ConfigureReportingCommand (com.zsmartsystems.zigbee.zcl.clusters.general.ConfigureReportingCommand)1 ReadReportingConfigurationCommand (com.zsmartsystems.zigbee.zcl.clusters.general.ReadReportingConfigurationCommand)1 AttributeRecord (com.zsmartsystems.zigbee.zcl.field.AttributeRecord)1 AttributeReport (com.zsmartsystems.zigbee.zcl.field.AttributeReport)1 AttributeReportingConfigurationRecord (com.zsmartsystems.zigbee.zcl.field.AttributeReportingConfigurationRecord)1 BindRequest (com.zsmartsystems.zigbee.zdo.command.BindRequest)1 UnbindRequest (com.zsmartsystems.zigbee.zdo.command.UnbindRequest)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1