Skip to content

Asset parameter messages

App Parameter Messages

Applications can publish an App Parameter Message in order to (asynchronously) update a given App Parameter for a given Asset.

The App Parameter update will persist as soon as this message is synced with the Kelvin Cloud.

Note

A user can also change the App Parameter value through the Kelvin UI.

Any changes done automatically by an application will be updated on the Kelvin UI screen.

You can see the configuration options for a Application for an Asset in Application section of the Kelvin UI.

The AppParameter Object supports the following attributes:

Attribute Required Description
resource required The KRNAssetParameter that this update is meant for.
value required App Parameter value (Boolean, Integer, Float or String).
comment optional Detailed description of the App Parameter update.

Examples

Basic Usage

This is how an App Parameter can be created and published in a Application:

Create and Publish App Parameter Python Example
from datetime import timedelta, datetime

from kelvin.application import KelvinApp
from kelvin.message import AppParameter, AppParameters
from kelvin.krn import KRNAssetParameter, KRNAppVersion

app = KelvinApp()

@app.timer(interval=10)
async def publish_data():

    # Create and Publish App Parameter
    await app.publish(
      AppParameters(
        parameters=[
          AppParameter(resource=KRNAssetParameter(asset, "min_treshold"), value=0)
        ],
        resource=KRNAppVersion(target_app_name, "1.0.0")
      )
    )

app.run()

App to App Usage

App Parameters can also be automatically updated from one Application to another Application.

There needs to be an Internet connection to the Kelvin Cloud even if both Applications are deployed to the same Cluster.

In the Application program, it can produce an update App Parameter value(s) to another Application like this;

Create and Publish Multiple App Parameters Python Example
from kelvin.message import AppParameters, AppParameter
from kelvin.krn import KRNAppVersion

app = KelvinApp()

@app.timer(interval=10)
async def publish_data():

    # Create and Publish Multiple App Parameters
    await app.publish(
      AppParameters(
        parameters=[
          AppParameter(resource=KRNAssetParameter(asset, "min_treshold"), value=0), 
          AppParameter(resource=KRNAssetParameter(asset, "max_treshold"), value=50)
        ],
        resource=KRNAppVersion(target_app_name, "1.0.0")
      )
    )

app.run()