TwinMaker: using lambda to fetch data for non-timeSeries properties
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 componentType
s, 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!
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,
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
Are you unblocked?
That really should have been a comment, not an answer
Relevant questions
When should I use IoT Core?
asked 3 months agoTwinMaker: using lambda to fetch data for non-timeSeries properties
Accepted Answerasked a month agoIoT Core pricing of basic ingest and QoS 1 combination
Accepted Answerasked a year agoPublishing messages to IoT core using an imported lambda in greengrassv2
asked a month ago3D Models added to AWS TwinMaker Scene Lost colors
Accepted Answerasked 3 months agoWhich AWS service(s) is cheaper to use to decode and view graphs corresponding to the payload emitted from Helium?
asked 5 days agoLaunch Announcement: AWS IoT TwinMaker is now generally available
asked a month agoGreengrass vs. IoT Core
asked 3 months agoIoT TwinMaker and Grafana integration where component has multiple list properties
asked 25 days agounable to Sub scribing with Mqtt data in AWS IoT core with greengrass deployment
asked 23 days ago
Thank for your reply! And yes, I arrived at the same conclusion myself. it was just a lot of hours spent looking around until I stumbled on the right function key/name to use (as it wasn't anywhere in the documentation).
I'm having a slightly different problem now with regards to components that have multiple values that are of the list datatype, and it has to do with the grafana integration. I've posted the question here: https://repost.aws/questions/QUmLmOo_qLSsWJnl9LMTUSpw/io-t-twin-maker-and-grafana-integration-where-component-has-multiple-list-properties