@Override
  public void onDeviceMessageReceived(ThingUID bridge, RFXComMessage message) {
    logger.trace("Received: bridge: {} message: {}", bridge, message);

    try {
      RFXComBaseMessage msg = (RFXComBaseMessage) message;
      String id = message.getDeviceId();
      ThingTypeUID uid = RFXComBindingConstants.packetTypeThingMap.get(msg.packetType);
      ThingUID thingUID =
          new ThingUID(uid, bridge, id.replace(RFXComBaseMessage.ID_DELIMITER, "_"));
      if (thingUID != null) {
        logger.trace("Adding new RFXCOM {} with id '{}' to smarthome inbox", thingUID, id);
        String subType = msg.convertSubType(String.valueOf(msg.subType)).toString();
        String label = msg.packetType + "-" + id;
        DiscoveryResult discoveryResult =
            DiscoveryResultBuilder.create(thingUID)
                .withLabel(label)
                .withProperty(RFXComBindingConstants.DEVICE_ID, id)
                .withProperty(RFXComBindingConstants.SUB_TYPE, subType)
                .withBridge(bridge)
                .build();
        thingDiscovered(discoveryResult);
      }
    } catch (Exception e) {
      logger.debug("Error occurred during device discovery", e);
    }
  }
Пример #2
0
  @Override
  public void encodeMessage(byte[] data) {

    super.encodeMessage(data);

    subType = SubType.fromByte(super.subType);
    sensorId = (data[4] & 0xFF) << 8 | (data[5] & 0xFF);
    count = data[6];

    // Current = Field / 10
    channel1Amps = ((data[7] & 0xFF) << 8 | (data[8] & 0xFF)) / 10.0;
    channel2Amps = ((data[9] & 0xFF) << 8 | (data[10] & 0xFF)) / 10.0;
    channel3Amps = ((data[11] & 0xFF) << 8 | (data[12] & 0xFF)) / 10.0;

    totalUsage =
        ((long) (data[13] & 0xFF) << 40
            | (long) (data[14] & 0xFF) << 32
            | (data[15] & 0xFF) << 24
            | (data[16] & 0xFF) << 16
            | (data[17] & 0xFF) << 8
            | (data[18] & 0xFF));
    totalUsage = totalUsage / TOTAL_USAGE_CONVERSION_FACTOR;

    signalLevel = (byte) ((data[19] & 0xF0) >> 4);
    batteryLevel = (byte) (data[19] & 0x0F);
  }
Пример #3
0
  @Override
  public void encodeMessage(byte[] data) {

    super.encodeMessage(data);

    subType = SubType.fromByte(super.subType);
    rawData = Arrays.copyOfRange(rawMessage, 4, rawMessage.length);
  }
  @Override
  public void encodeMessage(byte[] data) {

    super.encodeMessage(data);

    try {
      subType = SubType.values()[super.subType];
    } catch (Exception e) {
      subType = SubType.UNKNOWN;
    }

    try {
      response = Response.values()[data[4]];
    } catch (Exception e) {
      response = Response.UNKNOWN;
    }
  }
  @Override
  public void encodeMessage(byte[] data) {

    super.encodeMessage(data);

    try {
      subType = SubType.values()[super.subType];
    } catch (Exception e) {
      subType = SubType.UNKNOWN;
    }

    sensorId = (data[4] & 0xFF) << 16 | (data[5] & 0xFF) << 8 | (data[6] & 0xFF);
    unitcode = data[7];

    try {
      command = Commands.values()[data[8]];
    } catch (Exception e) {
      command = Commands.UNKNOWN;
    }

    signalLevel = (byte) ((data[9] & 0xF0) >> 4);
    batteryLevel = (byte) (data[9] & 0x0F);
  }