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!

3 Respostas
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
respondido há 2 anos
0
Resposta aceita

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

respondido há 2 anos
-1

Are you unblocked?

AWS
respondido há 2 anos
  • That really should have been a comment, not an answer

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas