gpt4 book ai didi

com.zsmartsystems.zigbee.zcl.ZclAttribute.getLastValue()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 22:29:31 28 4
gpt4 key购买 nike

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

ZclAttribute.getLastValue介绍

[英]Gets the last reported value of this attribute
[中]获取此属性上次报告的值

代码示例

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

/**
 * Synchronously get the <i>APSTxUcastRetry</i> attribute [attribute ID <b>266</b>].
 * <p>
 * This method can return cached data if the attribute has already been received.
 * The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
 * within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
 * received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
 * <p>
 * This method will block until the response is received or a timeout occurs unless the current value is returned.
 * <p>
 * The attribute is of type {@link Integer}.
 * <p>
 * The implementation of this attribute by a device is MANDATORY
 *
 * @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
 * @return the {@link Integer} attribute value, or null on error
 */
public Integer getApsTxUcastRetry(final long refreshPeriod) {
  if (attributes.get(ATTR_APSTXUCASTRETRY).isLastValueCurrent(refreshPeriod)) {
    return (Integer) attributes.get(ATTR_APSTXUCASTRETRY).getLastValue();
  }
  return (Integer) readSync(attributes.get(ATTR_APSTXUCASTRETRY));
}

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

/**
 * Synchronously get the <i>NeighborStale</i> attribute [attribute ID <b>271</b>].
 * <p>
 * This method can return cached data if the attribute has already been received.
 * The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
 * within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
 * received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
 * <p>
 * This method will block until the response is received or a timeout occurs unless the current value is returned.
 * <p>
 * The attribute is of type {@link Integer}.
 * <p>
 * The implementation of this attribute by a device is MANDATORY
 *
 * @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
 * @return the {@link Integer} attribute value, or null on error
 */
public Integer getNeighborStale(final long refreshPeriod) {
  if (attributes.get(ATTR_NEIGHBORSTALE).isLastValueCurrent(refreshPeriod)) {
    return (Integer) attributes.get(ATTR_NEIGHBORSTALE).getLastValue();
  }
  return (Integer) readSync(attributes.get(ATTR_NEIGHBORSTALE));
}

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

/**
 * Synchronously get the <i>JoinIndication</i> attribute [attribute ID <b>272</b>].
 * <p>
 * This method can return cached data if the attribute has already been received.
 * The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
 * within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
 * received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
 * <p>
 * This method will block until the response is received or a timeout occurs unless the current value is returned.
 * <p>
 * The attribute is of type {@link Integer}.
 * <p>
 * The implementation of this attribute by a device is MANDATORY
 *
 * @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
 * @return the {@link Integer} attribute value, or null on error
 */
public Integer getJoinIndication(final long refreshPeriod) {
  if (attributes.get(ATTR_JOININDICATION).isLastValueCurrent(refreshPeriod)) {
    return (Integer) attributes.get(ATTR_JOININDICATION).getLastValue();
  }
  return (Integer) readSync(attributes.get(ATTR_JOININDICATION));
}

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

/**
 * Synchronously get the <i>APSUnauthorizedKey</i> attribute [attribute ID <b>276</b>].
 * <p>
 * This method can return cached data if the attribute has already been received.
 * The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
 * within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
 * received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
 * <p>
 * This method will block until the response is received or a timeout occurs unless the current value is returned.
 * <p>
 * The attribute is of type {@link Integer}.
 * <p>
 * The implementation of this attribute by a device is MANDATORY
 *
 * @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
 * @return the {@link Integer} attribute value, or null on error
 */
public Integer getApsUnauthorizedKey(final long refreshPeriod) {
  if (attributes.get(ATTR_APSUNAUTHORIZEDKEY).isLastValueCurrent(refreshPeriod)) {
    return (Integer) attributes.get(ATTR_APSUNAUTHORIZEDKEY).getLastValue();
  }
  return (Integer) readSync(attributes.get(ATTR_APSUNAUTHORIZEDKEY));
}

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

/**
 * Synchronously get the <i>APSDecryptFailures</i> attribute [attribute ID <b>278</b>].
 * <p>
 * This method can return cached data if the attribute has already been received.
 * The parameter <i>refreshPeriod</i> is used to control this. If the attribute has been received
 * within <i>refreshPeriod</i> milliseconds, then the method will immediately return the last value
 * received. If <i>refreshPeriod</i> is set to 0, then the attribute will always be updated.
 * <p>
 * This method will block until the response is received or a timeout occurs unless the current value is returned.
 * <p>
 * The attribute is of type {@link Integer}.
 * <p>
 * The implementation of this attribute by a device is MANDATORY
 *
 * @param refreshPeriod the maximum age of the data (in milliseconds) before an update is needed
 * @return the {@link Integer} attribute value, or null on error
 */
public Integer getApsDecryptFailures(final long refreshPeriod) {
  if (attributes.get(ATTR_APSDECRYPTFAILURES).isLastValueCurrent(refreshPeriod)) {
    return (Integer) attributes.get(ATTR_APSDECRYPTFAILURES).getLastValue();
  }
  return (Integer) readSync(attributes.get(ATTR_APSDECRYPTFAILURES));
}

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

@Override
  public synchronized void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.LEVEL_CONTROL
        && attribute.getId() == ZclLevelControlCluster.ATTR_CURRENTLEVEL) {
      lastLevel = levelToPercent((Integer) attribute.getLastValue());
      if (currentOnOffState.get()) {
        // Note that state is only updated if the current On/Off state is TRUE (ie ON)
        updateChannelState(lastLevel);
      }
    } else if (attribute.getCluster() == ZclClusterType.ON_OFF && attribute.getId() == ZclOnOffCluster.ATTR_ONOFF) {
      if (attribute.getLastValue() != null) {
        currentOnOffState.set((Boolean) attribute.getLastValue());
        updateChannelState(currentOnOffState.get() ? lastLevel : OnOffType.OFF);
      }
    }
  }
}

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

private void printAttributes(final ZclCluster cluster, final PrintStream out) {
    Map<Integer, ZclAttribute> attributeTree = new TreeMap<Integer, ZclAttribute>();
    for (ZclAttribute attribute : cluster.getAttributes()) {
      attributeTree.put(attribute.getId(), attribute);
    }

    for (ZclAttribute attribute : attributeTree.values()) {
      out.println(String.format("        %s   %5d %s%s%s %s %-40s %s %s",
          (cluster.getSupportedAttributes().contains(attribute.getId()) ? "S" : "U"), attribute.getId(),
          (attribute.isReadable() ? "r" : "-"), (attribute.isWritable() ? "w" : "-"),
          (attribute.isReportable() ? "s" : "-"), printZclDataType(attribute.getDataType()),
          attribute.getName(),
          (attribute.getLastValue() == null ? "" : attribute.getLastReportTime().getTime()),
          (attribute.getLastValue() == null ? "" : attribute.getLastValue())));
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.RELATIVE_HUMIDITY_MEASUREMENT
        && attribute.getId() == ZclRelativeHumidityMeasurementCluster.ATTR_MEASUREDVALUE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        updateChannelState(new DecimalType(BigDecimal.valueOf(value, 2)));
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.ILLUMINANCE_MEASUREMENT
        && attribute.getId() == ZclIlluminanceMeasurementCluster.ATTR_MEASUREDVALUE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        updateChannelState(new DecimalType(BigDecimal.valueOf(value, 2)));
      }
    }
  }
}

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

@Override
public void attributeUpdated(ZclAttribute attribute) {
  logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
  if (attribute.getCluster() == ZclClusterType.IAS_ZONE
      && attribute.getId() == ZclIasZoneCluster.ATTR_ZONESTATUS) {
    updateChannelState((Integer) attribute.getLastValue());
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.TEMPERATURE_MEASUREMENT
        && attribute.getId() == ZclTemperatureMeasurementCluster.ATTR_MEASUREDVALUE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        updateChannelState(new QuantityType<>(BigDecimal.valueOf(value, 2), SIUnits.CELSIUS));
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.ELECTRICAL_MEASUREMENT
        && attribute.getId() == ZclElectricalMeasurementCluster.ATTR_RMSVOLTAGE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        BigDecimal valueInVolts = BigDecimal.valueOf(value * multiplier / divisor);
        updateChannelState(new QuantityType<ElectricPotential>(valueInVolts, SmartHomeUnits.VOLT));
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.ELECTRICAL_MEASUREMENT
        && attribute.getId() == ZclElectricalMeasurementCluster.ATTR_ACTIVEPOWER) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        BigDecimal valueInWatt = BigDecimal.valueOf(value * multiplier / divisor);
        updateChannelState(new QuantityType<Power>(valueInWatt, SmartHomeUnits.WATT));
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.ELECTRICAL_MEASUREMENT
        && attribute.getId() == ZclElectricalMeasurementCluster.ATTR_RMSCURRENT) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null) {
        BigDecimal valueInAmpere = BigDecimal.valueOf(value * multiplier / divisor);
        updateChannelState(new QuantityType<ElectricCurrent>(valueInAmpere, SmartHomeUnits.AMPERE));
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.POWER_CONFIGURATION
        && attribute.getId() == ZclPowerConfigurationCluster.ATTR_BATTERYVOLTAGE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value == null || value == 0xFF) {
        // The value 0xFF indicates an invalid or unknown reading.
        return;
      }
      BigDecimal valueInVolt = BigDecimal.valueOf(value, 1);
      updateChannelState(new QuantityType<ElectricPotential>(valueInVolt, SmartHomeUnits.VOLT));
    }
  }
}

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

@Override
public void attributeUpdated(ZclAttribute attribute) {
  logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
  if (attribute.getCluster() == ZclClusterType.ON_OFF && attribute.getId() == ZclOnOffCluster.ATTR_ONOFF) {
    Boolean value = (Boolean) attribute.getLastValue();
    if (value != null && value) {
      updateChannelState(OnOffType.ON);
    } else {
      updateChannelState(OnOffType.OFF);
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.OCCUPANCY_SENSING
        && attribute.getId() == ZclOccupancySensingCluster.ATTR_OCCUPANCY) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null && value == 1) {
        updateChannelState(OnOffType.ON);
      } else {
        updateChannelState(OnOffType.OFF);
      }
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.POWER_CONFIGURATION
        && attribute.getId() == ZclPowerConfigurationCluster.ATTR_BATTERYPERCENTAGEREMAINING) {
      Integer value = (Integer) attribute.getLastValue();
      if (value == null) {
        return;
      }

      updateChannelState(new DecimalType(value / 2));
    }
  }
}

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

@Override
  public void attributeUpdated(ZclAttribute attribute) {
    logger.debug("{}: ZigBee attribute reports {}", endpoint.getIeeeAddress(), attribute);
    if (attribute.getCluster() == ZclClusterType.DOOR_LOCK
        && attribute.getId() == ZclDoorLockCluster.ATTR_LOCKSTATE) {
      Integer value = (Integer) attribute.getLastValue();
      if (value != null && value == 1) {
        updateChannelState(OnOffType.ON);
      } else {
        updateChannelState(OnOffType.OFF);
      }
    }
  }
}

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

@Test
  public void getLastReportTime() {
    ZclAttribute attribute = new ZclAttribute(ZclClusterType.ON_OFF, 0, "Test Name",
        ZclDataType.UNSIGNED_8_BIT_INTEGER, false, false, false, false);

    // No value has been set, so should always be false
    assertFalse(attribute.isLastValueCurrent(Long.MAX_VALUE));

    Calendar start = Calendar.getInstance();
    attribute.updateValue(0);
    Calendar stop = Calendar.getInstance();

    assertEquals(0, attribute.getLastValue());
    assertTrue(attribute.getLastReportTime().compareTo(start) >= 0);
    assertTrue(attribute.getLastReportTime().compareTo(stop) <= 0);

    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    assertFalse(attribute.isLastValueCurrent(50));
    assertTrue(attribute.isLastValueCurrent(Long.MAX_VALUE));
  }
}

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