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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南