Accessing meta data in the rule

As we have seen in some of the previous examples, that a resource is a unique identifier of a ‘thing’. When a ‘thing’ pushes streaming data to the Waylay platform, it provides its unique identifier, i.e. a resource identifier. Each resource can push multiple parameters to the Waylay broker. The Waylay framework will automatically distribute the resource parameters to the tasks and nodes with the corresponding resource identifier. E.g. with the ‘execute on data’ option described below, the sensors with the corresponding resource identifier will automatically get invoked when new streamed data with the same resource identifier becomes available. Before any sensor execution, payload streaming data will be provided to the calling node. That way, sensor (𝛌 function code) will at the moment of invocation have access to the streaming data. The resource identifier can be specified at the task level and/or at the node level.

But in this example, we we will see how we can use the resource meta data as the input argument for sensors and actuators:

Accessing meta data in the rule

There is an easy way to reference resource meta data in the properties of sensors and actuators. The format is “META.$.<meta data key>“. An example is given below

Here is our rule

image

{
  "sensors": [
    {
      "label": "streamingDataSensor_1",
      "name": "streamingDataSensor",
      "version": "1.1.4",
      "dataTrigger": true,
      "tickTrigger": false,
      "resource": "$",
      "position": [
        1179,
        363
      ],
      "properties": {
        "parameter": "temperature",
        "threshold": "META.$.threshold"
      }
    }
  ],
  "actuators": [
    {
      "label": "debugDialog_1",
      "name": "debugDialog",
      "version": "1.0.4",
      "position": [
        1348,
        223
      ],
      "properties": {
        "message": "Value above {{streamingDataSensor_1.threshold}}"
      }
    }
  ],
  "relations": [],
  "triggers": [
    {
      "destinationLabel": "debugDialog_1",
      "sourceLabel": "streamingDataSensor_1",
      "invocationPolicy": 0,
      "statesTrigger": [
        "Above"
      ]
    }
  ],
  "name": ""
}

Our metadata is defined on the resource to which we will be pushing data:

image

After pushing some runtime data we can see the message in the actuator:

image

Accesing meta data of any other resource in the task

If we had more than one node in the rule, and we wanted to use the threshold of another resource as an input, we could have done it this way “META.resource2.<meta data key>“ where resource2 is the resource attached of any other node in the same template.

image