Skip to content

App Parameters

You can learn more about Asset Parameters in the Overview ⟶ Concepts page.

Creating Parameters

They are initially declared with default values in the Kelvin SmartApp™ app.yaml file.

The variables can then be dynamically changed by Operations for each Asset deployed to the Kelvin SmartApp™. This allows customized values for each Asset.

The keys used in the app.yaml file are;

  • parameters defines the name and type of the App Parameter.
  • ui_schemas is a link to a JSON file containing all the information about how to display App Parameters in the Kelvin UI.
  • defaults / parameters define the default values assigned to each Asset when it is first created or when a Kelvin SmartApp™ update introduces a new App Parameter to existing Assets.

Each parameter can be defined by four different data_types. Full documentation on the different data_types is in the concept overview page.

In the app.yaml file it will look like this;

app.yaml Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
parameters:
    - name: closed_loop
    data_type: boolean
    - name: speed_decrease_set_point
    data_type: number
    - name: temperature_max_threshold
    data_type: number

ui_schemas:
    parameters: "schemas/parameters.json"

defaults:
    parameters:
    closed_loop: false
    speed_decrease_set_point: 1000
    temperature_max_threshold: 59

For the parameters.json file you can define all the information for the Kelvin UI. This can be the title, type of input required and limitations of the values allowed.

It will look something like this.

sample ui_schema/parameters.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
    "type": "object",
    "properties": {
        "closed_loop": {
            "type": "boolean",
            "title": "Closed Loop"
        },
        "speed_decrease_set_point": {
            "type": "number",
            "title": "Speed Decrease SetPoint",
            "minimum": 1000,
            "maximum": 3000
        },
        "temperature_max_threshold": {
            "type": "number",
            "title": "Temperature Max Threshold",
            "minimum": 50,
            "maximum": 100
        }
    },
    "required": [
        "closed_loop",
        "speed_decrease_set_point",
        "temperature_max_threshold"
    ]
}

Which will be displayed on the Kelvin UI as:

App Parameters

Get Parameter Values

Access a single App Parameter value directly from an assets Dictionary Object embedded within KelvinApp:

Get Parameter Values Python Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import asyncio

from kelvin.application import KelvinApp


async def main() -> None:
    app = KelvinApp()
    await app.connect()

    (...)

    # Get App Parameter
    temperature_max_threshold = app.assets["my-motor-asset"].parameters["temperature_max_threshold"]

Updating Parameter Values

Writing to a single App Parameter value directly from an assets Dictionary Object embedded within KelvinApp:

Updating Parameter Values Python Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from kelvin.message import AssetParameters, AssetParameter
from kelvin.krn import KRNAppVersion

(...)

await app.publish(
  AssetParameters(
    parameters=[
      AssetParameter(resource=KRNAssetParameter(asset, "min_treshold"), value=0), 
      AssetParameter(resource=KRNAssetParameter(asset, "max_treshold"), value=50)
    ],
    resource=KRNAppVersion(target_app_name, "1.0.0")
  )
)

Upgrading Kelvin SmartApps™

When a Kelvin SmartApp™ is upgraded, Kelvin automatically propagates all matching App Parameter values from the previous version to the new version.

For any new App Parameters introduced in the upgraded Kelvin SmartApp™ version, the default values will initially apply to all Assets using the updated version.

Other Examples

Basic

In the app.yaml file, the minimum you can put is this

app.yaml Example
1
2
3
parameters:
    - name: temperature_max_threshold
      data_type: number

In the Kelvin SmartApp™ program, it can access the App Parameter values for each Asset like this.

Access a single App Parameter value directly from an assets Dictionary Object embedded within KelvinApp:

Get Parameter Values Python Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import asyncio

from kelvin.application import KelvinApp


async def main() -> None:
    app = KelvinApp()
    await app.connect()

    (...)

    # Get App Parameter
    temperature_max_threshold = app.assets["my-motor-asset"].parameters["temperature_max_threshold"]

Info

app.assets will only be available after app.connect()

The App Parameter values can be updated by Operations in the Kelvin UI through the parameters section.

SmartLift

A practical example is in the Kelvin SmartApp™ called SmartLift where the Operations can change the values for different App Parameters for each Asset.

In this example, Operations can set the following values for each Asset;

  • Maximum Drawdown rate
  • Minimum Drawdowm rate
  • Maximum Power

They can also assign whether the gauge is faulty.

Finally, they can choose whether to run the Asset in Open or Closed control mode:

  • Open Control Mode: Any data changes the Kelvin SmartApp intends to make to the Asset data values must first be approved by Operations before being applied to the Asset.
  • Closed Control Mode: Any data changes the Kelvin SmartApp intends to make are automatically applied to the Asset without requiring prior approval.