Data tag messages
Insights & Data Tags¶
In the Kelvin UI, Data Tags are now known as Insights.
Data Tags may be depreciated in the Kelvin SDK and Kelvin API in future releases.
Keep an eye on future releases for updated announcements.
Insights Management¶
You can also manage your insights using the Kelvin SDK and Kelvin API.
You can read all the details in the Platform Administration in the Insights section.
Data Tag Messages¶
Kelvin SmartApps™ can receive DataTag messages published by other SmartApps or created manually through the Kelvin UI. This allows your SmartApp to react to labeled events on Asset time series data.
Live¶
Receive insights in real time as they are published. Use this for event-driven reactions within a running SmartApp.
app.yaml setup¶
To consume insights, declare the tag names your SmartApp should receive in the data_tags.inputs section of your app.yaml. Each entry is the tag name as a string:
Decorator (Preferred)¶
The preferred method is to use the @app.on_data_tag decorator. You can filter by tag name using app.app_configuration to limit processing to only the tags your SmartApp cares about.
Callback¶
For advanced scenarios, assign a handler function directly to app.on_data_tag:
| on_data_tag Callback Example | |
|---|---|
Historical¶
Query insights over a past time range using the Kelvin API. Use this for catching events that occurred before your SmartApp started, or for periodic reconciliation.
Historical Data Tag Queries¶
In addition to receiving live insights via on_data_tag, you can query historical insights over a time range using app.api.data_tag.list_data_tag(). This is useful for catching events that occurred before your SmartApp started, or for periodic reconciliation.
API permission required
You must declare the required read permission for data_tag in your app.yaml. Confirm the exact permission string from the method docstring in kelvin.api.client.api.data_tag before setting it.
See the API Integration page for full details on using app.api.
The example below fetches all "Temperature Too High" tags for a specific Asset over the past 3 days:
Recommended architecture
- Use
on_data_tagfor live events. - Add a startup task or scheduled job (for example, running every hour) to call the historical fetch. This ensures you do not miss events caused by downtime or redeployments.
See Background Tasks for how to schedule periodic work in a Kelvin SmartApp™.