Trigger Example: Data Conversion

A data property is published in imperial units (miles) but the data is required in metric units (kilometers).

To solve this requirement, the data property published in imperial units is converted to the equivalent metric units and stored in an additional property.

The thing's thing definition has a property for the imperial units data. An additional property for the metric units data is defined:

  • Property key for Miles per Hour: mph

  • Property key for Kilometers per Hour: kph

  • $(event.thing.key) - The key of the thing that initiated the cloud trigger.

  • $(event.prop.value) - The data value of the Publish Property action (or property.publish API) that initiated the cloud trigger.

  • $(action.X.value) - The result value for action block X.

A cloud trigger is executed when a property change occurs for the mph property for all things that have this thing definition and are tagged acme.

The value from the math expression action stored in $(action.0.value) is then published to the kph property key for the thing that originally had the mph property published. The thing key is known by using the event variable $(event.thing.key).