/**
   * {@inheritDoc}
   *
   * @throws ZWaveSerialMessageException
   */
  @Override
  public void handleApplicationCommandRequest(SerialMessage serialMessage, int offset, int endpoint)
      throws ZWaveSerialMessageException {
    logger.trace("Handle Message Sensor Binary Request");
    logger.debug(
        "NODE {}: Received SENSOR_BINARY command V{}", getNode().getNodeId(), getVersion());
    int command = serialMessage.getMessagePayloadByte(offset);
    switch (command) {
      case SENSOR_BINARY_REPORT:
        logger.trace("Process Sensor Binary Report");
        int value = serialMessage.getMessagePayloadByte(offset + 1);

        SensorType sensorType = SensorType.UNKNOWN;
        if (getVersion() > 1 && serialMessage.getMessagePayload().length > offset + 2) {
          logger.debug(
              "Processing Sensor Type {}", serialMessage.getMessagePayloadByte(offset + 2));
          // For V2, we have the sensor type after the value
          sensorType = SensorType.getSensorType(serialMessage.getMessagePayloadByte(offset + 2));
          logger.debug("Sensor Type is {}", sensorType);
          if (sensorType == null) {
            sensorType = SensorType.UNKNOWN;
          }
        }

        logger.debug(
            "NODE {}: Sensor Binary report, type={}, value={}",
            getNode().getNodeId(),
            sensorType.getLabel(),
            value);

        ZWaveBinarySensorValueEvent zEvent =
            new ZWaveBinarySensorValueEvent(getNode().getNodeId(), endpoint, sensorType, value);
        getController().notifyEventListeners(zEvent);

        dynamicDone = true;
        break;
      case SENSOR_BINARY_SUPPORTEDSENSOR_REPORT:
        logger.trace("Process Sensor Binary Supported Sensors Report");

        int numBytes = serialMessage.getMessagePayload().length - offset - 1;

        for (int i = 0; i < numBytes; ++i) {
          for (int bit = 0; bit < 8; ++bit) {
            if (((serialMessage.getMessagePayloadByte(offset + i + 1)) & (1 << bit)) == 0) {
              continue;
            }

            int index = (i << 3) + bit;
            if (index >= SensorType.values().length) {
              continue;
            }

            // (n)th bit is set. n is the index for the sensor type enumeration.
            // sensor type seems to be supported, add it to the list if it's not already there.
            types.add(SensorType.getSensorType(index));
            logger.debug(
                "NODE {}: found binary sensor {}",
                getNode().getNodeId(),
                SensorType.getSensorType(index));
          }
        }

        initialiseDone = true;
        break;
      default:
        logger.warn(
            String.format(
                "NODE %d: Unsupported Command 0x%02X for command class %s (0x%02X).",
                getNode().getNodeId(),
                command,
                getCommandClass().getLabel(),
                getCommandClass().getKey()));
    }
  }
 public void testGetValidLetters() {
   String codes = SensorType.getValidLetters();
   assertNotNull(codes);
   assertEquals(SensorType.values().length, codes.length());
   System.out.println(codes);
 }