How to attach my lambda function to IoT Analytics pipeline

0

Hello,

I created my lambda function that converts string data to temperature. I use IoT analytics for data collection and visualization in QuickSight. I also add permission ([https://docs.aws.amazon.com/iotanalytics/latest/userguide/pipeline-activities-lambda.html]) to my lambda function for IoT Analytics but when I want to use my lambda function in lambda pipeline activity there is no outgoing message. So my question is How to attach lambda function to IoT Analytics pipeline.

This is my function:

export const handler = async (event) => {
  // TODO implement
  var json = event;  // Pokud event je již objekt, není potřeba JSON.parse
  var stringMessage = event.data.rsp.rData;
  var splitMessage = stringMessage.split(".");
  var lengthString = splitMessage.length;
  //calculate
  var firstNumber = splitMessage[lengthString - 2];
  var secondNumber =  splitMessage[lengthString - 1];
  var hexNumber = secondNumber + firstNumber;
  var decimalNumber = parseFloat(hexNumber, 16);
  if (hexNumber[0] == "1") {
    hexNumber = hexNumber.slice(1);
    decimalNumber = parseFloat(hexNumber, 16) * (-1);
  }
  var temperature = decimalNumber * 0.0625;
  // Přidání hodnoty teploty k původnímu objektu JSON
  event.data.rsp.temperature = temperature;

  const response = {
    
    body: JSON.stringify(event),
  };
  return response;
};

And this is my JSON message: { "mType": "iqrfRaw", "data": { "msgId": "6e93f877-df24-4461-960d-fc172dbf2d9d", "rsp": { "rData": "03.00.20.80.0f.00.00.4e.62.01" }, "raw": [ { "request": "03.00.20.00.ff.ff", "requestTs": "2023-11-15T18:01:55.300+01:00", "confirmation": "03.00.20.00.ff.ff.ff.4f.03.08.03", "confirmationTs": "2023-11-15T18:01:55.318+01:00", "response": "03.00.20.80.0f.00.00.4e.62.01", "responseTs": "2023-11-15T18:01:56.095+01:00" } ], "insId": "iqrfgd2-default", "statusStr": "ok", "status": 0 } }

MikMar
질문됨 5달 전96회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠