gpt4 book ai didi

com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster.offCommand()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 11:29:31 26 4
gpt4 key购买 nike

本文整理了Java中com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster.offCommand()方法的一些代码示例,展示了ZclOnOffCluster.offCommand()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZclOnOffCluster.offCommand()方法的具体详情如下:
包路径:com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster
类名称:ZclOnOffCluster
方法名:offCommand

ZclOnOffCluster.offCommand介绍

[英]The Off Command
[中]关闭命令

代码示例

代码示例来源:origin: openhab/org.openhab.binding.zigbee

@Override
public void handleCommand(final Command command) {
  if (clusterOnOffServer == null) {
    logger.warn("{}: OnOff converter is not linked to a server and cannot accept commands",
        endpoint.getIeeeAddress());
    return;
  }
  OnOffType cmdOnOff = null;
  if (command instanceof PercentType) {
    if (((PercentType) command).intValue() == 0) {
      cmdOnOff = OnOffType.OFF;
    } else {
      cmdOnOff = OnOffType.ON;
    }
  } else if (command instanceof OnOffType) {
    cmdOnOff = (OnOffType) command;
  } else {
    logger.warn("{}: OnOff converter only accepts PercentType and OnOffType - not {}",
        endpoint.getIeeeAddress(), command.getClass().getSimpleName());
    return;
  }
  if (cmdOnOff == OnOffType.ON) {
    clusterOnOffServer.onCommand();
  } else {
    clusterOnOffServer.offCommand();
  }
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

private void changeOnOff(OnOffType onoff) throws InterruptedException, ExecutionException {
  boolean on = onoff == OnOffType.ON;
  PercentType brightness = on ? PercentType.HUNDRED : PercentType.ZERO;
  if (clusterLevelControl != null) {
    changeBrightness(brightness);
    return;
  }
  if (clusterOnOff == null) {
    logger.warn("{}: ignoring on/off command", endpoint.getIeeeAddress());
    return;
  }
  HSBType oldHSB = currentHSB;
  currentHSB = new HSBType(oldHSB.getHue(), oldHSB.getSaturation(), brightness);
  lastBrightness = brightness;
  if (on) {
    clusterOnOff.onCommand().get();
  } else {
    clusterOnOff.offCommand().get();
  }
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

/**
 * If we support the OnOff cluster then we should perform the same function as the SwitchOnoffConverter. Otherwise,
 * interpret ON commands as moving to level 100%, and OFF commands as moving to level 0%.
 */
private void handleOnOffCommand(OnOffType cmdOnOff) {
  if (clusterOnOff != null) {
    if (cmdOnOff == OnOffType.ON) {
      clusterOnOff.onCommand();
    } else {
      clusterOnOff.offCommand();
    }
  } else {
    if (cmdOnOff == OnOffType.ON) {
      moveToLevel(PercentType.HUNDRED);
    } else {
      moveToLevel(PercentType.ZERO);
    }
  }
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

private void moveToLevel(PercentType percent) {
  if (clusterOnOff != null) {
    if (percent.equals(PercentType.ZERO)) {
      clusterOnOff.offCommand();
    } else {
      clusterLevelControl.moveToLevelWithOnOffCommand(percentToLevel(percent),
          configLevelControl.getDefaultTransitionTime());
    }
  } else {
    clusterLevelControl.moveToLevelCommand(percentToLevel(percent),
        configLevelControl.getDefaultTransitionTime());
  }
}

代码示例来源:origin: openhab/org.openhab.binding.zigbee

private void changeBrightness(PercentType brightness) throws InterruptedException, ExecutionException {
  if (clusterLevelControl == null) {
    if (clusterOnOff != null) {
      changeOnOff(brightness.intValue() == 0 ? OnOffType.OFF : OnOffType.ON);
    } else {
      logger.warn("{}: ignoring brightness command", endpoint.getIeeeAddress());
    }
    return;
  }
  HSBType oldHSB = currentHSB;
  currentHSB = new HSBType(oldHSB.getHue(), oldHSB.getSaturation(), brightness);
  lastBrightness = brightness;
  int level = percentToLevel(brightness);
  if (clusterOnOff != null) {
    if (brightness.equals(PercentType.ZERO)) {
      clusterOnOff.offCommand();
    } else {
      clusterLevelControl.moveToLevelWithOnOffCommand(level, configLevelControl.getDefaultTransitionTime())
          .get();
    }
  } else {
    clusterLevelControl.moveToLevelCommand(level, configLevelControl.getDefaultTransitionTime()).get();
  }
}

代码示例来源:origin: zsmartsystems/com.zsmartsystems.zigbee

@Test
public void testNodeNetworkAddressUpdate() {
  mockedTransport = Mockito.mock(ZigBeeTransportTransmit.class);
  mockedApsFrameListener = ArgumentCaptor.forClass(ZigBeeApsFrame.class);
  ZigBeeNetworkManager networkManager = new ZigBeeNetworkManager(mockedTransport);
  ZigBeeNode node = new ZigBeeNode(networkManager, new IeeeAddress("12345678990ABCDEF"));
  node.setNetworkAddress(12345);
  ZigBeeEndpoint endpoint = new ZigBeeEndpoint(node, 1);
  ZclOnOffCluster cluster = new ZclOnOffCluster(endpoint);
  networkManager.setSerializer(DefaultSerializer.class, DefaultDeserializer.class);
  Mockito.doNothing().when(mockedTransport).sendCommand(mockedApsFrameListener.capture());
  cluster.onCommand();
  assertEquals(12345, mockedApsFrameListener.getValue().getDestinationAddress());
  node.setNetworkAddress(54321);
  cluster.offCommand();
  assertEquals(54321, mockedApsFrameListener.getValue().getDestinationAddress());
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com