TwinMaker: using lambda to fetch data for non-timeSeries properties

0

Hello! I've been trying to use IoT RoboRunner + IoT TwinMaker + AWS Grafana to create a dashboard. As one of the most basic things to show is a list of the current workers/robots.

Take the following componentTypes: (parent, to be inherited from, to keep the lambda function common) Ideally, the lambda function would be able to see the event, and the associated telemetryAssetId, and reply with an appropriate payload.

{
  "componentTypeId": "com.example.lambda_reader",
  "workspaceId": "MyWorkspace",
  "functions": {
    "dataReader": {
      "implementedBy": {
        "lambda": {
          "arn": "arn:aws:lambda:us-east-1:<account>:function:RoboRunnerWorkerInfo"
        }
      }
    }
  },
  "propertyDefinitions": {
    "telemetryAssetId": {
      "dataType": {
        "type": "STRING"
      },
      "isExternalId": true,
      "isStoredExternally": false,
      "isTimeSeries": false,
      "isRequiredInEntity": true
    }
  }
}

and the child, which inherits from the above

{
    "componentTypeId": "com.example.myworkspace.worker_list",
    "extendsFrom": [
        "com.example.lambda_reader"
    ],
    "propertyDefinitions": {
        "telemetryAssetId": {
            "defaultValue" : { "stringValue": "WorkerList" }
        },
        "workerList": {
            "dataType": {
              "type": "LIST",
              "netstedType": {
                "type": "STRING"
              }
            },
            "isTimeSeries": false,
            "isStoredExternally": true
        }
    }
}

When adding these two componentTypes, the latter shows up as abstract unless isTimeSeries is set to true. Is this intended behavior? Seems like I should be able to do this? Any help is appreciated!

질문됨 2년 전540회 조회
3개 답변
1

Hi, to explain little bit more into the detail, if a property is marked as IsStoredExternally means TwinMaker will only keep the property schema but not the value. So to access the property value you'll need to invoke the unified data access APIs with a defined connector.

For time-series property, you can use GetPropertyValueHistory API to access the property value, you need to define dataReader connector and while querying the property value in runtime, TwinMaker will forward the request to your connector to resolve it.

For non-time-series property, you can use GetPropertyValue API to access, and as you already found out, you need to define attributePropertyValueReaderByEntity connector for that.

We'll continue polishing our documentation to make it clear. Let us know if you are interested in more details on the topic.

Best,

AWS
Hao
답변함 2년 전
0
수락된 답변

I was able to fetch non-timeseries properties by specifying a function under a different name than dataReader.

So, instead of

  "functions": {
    "dataReader": {
      "implementedBy": {
        "lambda": {
          "arn": "arn:aws:lambda:us-east-1:<account>:function:RoboRunnerWorkerInfo"
        }
      }
    }

for non-timeseries properties, it should be

  "functions": {
    "attributePropertyValueReaderByEntity": {
      "implementedBy": {
        "lambda": {
          "arn": "arn:aws:lambda:us-east-1:<account>:function:RoboRunnerWorkerInfo"
        }
      }
    }

Which is absolutely nowhere in the documentation. I arrived at it by sifting through github and finding https://github.com/aws-samples/aws-iot-twinmaker-samples/blob/main/src/modules/s3/component-types/s3_component_type.json

답변함 2년 전
-1

Are you unblocked?

AWS
답변함 2년 전
  • That really should have been a comment, not an answer

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

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

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

관련 콘텐츠