Skip to content

Kelvin SmartApps™ Configuration

You can learn more about App Configurations in the Overview ⟶ Concepts page.

Creating App Configurations

The configuration variable names and values are defined in the Kelvin SmartApp™'s app.yaml file as configuration.

Configurations can also be optionally defined in the ui_schemas that provides a link to a JSON file containing all the information about how to display Configurations in the Kelvin UI.

Note

Operations will have the option to change these at runtime from the Kelvin UI.

app.yaml Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ui_schemas:
  configurations: "schemas/configurations.json"

defaults:
  configuration:
    broker-ip: edge-mqtt-broker
    broker-port: 1883
    nest-example:
      nest1: 25
      next2: 30

For the configurations.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/configurations.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
  "type": "object",
  "properties": {
    "broker-ip": {
      "type": "string",
      "title": "Broker IP Address"
    },
      "broker-port": {
      "type": "number",
      "title": "Broker Port Number",
      "minimum": 0,
      "maximum": 65535
    }
  },
  "required": ["broker-ip", "broker-port"]
}

Get Configuration Values

This is how to access the global configuration variables in a Kelvin SmartApp™:

Get Configuration 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 IP
    ip = app.app_configuration["broker-ip"]

Info

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

You can also get nested App Configuration values;

Get Nested Configuration 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 IP
    ip = app.app_configuration["nest-example"]["nest1"]

Updating Configuration Values

Developers and Administrators can update these values through the Kelvin API without needing to re-upload the complete Kelvin SmartApp™ or Kelvin UI.

To update the configuration values dynamically, you use the Kelvin API endpoint /workloads/{workload_name}/configurations/update.

Note

The configurations values are applied directly to a workload. This will not affect the values in the App Registry.

If you have a Kelvin SmartApp™ deployed as many workloads, the updates will only affect the workload you target.

API cURL Example
 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    curl -X 'POST' \
  "https://<url.kelvin.ai>/api/v4{workloads/<workload_name}/configurations/update" \
  -H "Authorization: Bearer <Your Current Token>" \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "configuration": {
    "recommendations": [
      {
        "description": "Water level increasing, higher pump speed will lead water level to return to optimal.",
        "setpoint": {
          "name": "speed_sp",
          "variation_factor": 0.1
        },
        "type": "increase_speed"
      },
      {
        "description": "Production gain possible after step test, with higher pump speed",
        "setpoint": {
          "name": "speed_sp",
          "variation_factor": 0.1
        },
        "type": "increase_speed"
      },
      {
        "description": "Erratic Torque detected at this speed previously, lower pump speed will reduce vibrations",
        "setpoint": {
          "name": "speed_sp",
          "variation_factor": -0.1
        },
        "type": "decrease_speed"
      },
      {
        "description": "Reducing Speed will save energy and keep production levels constant",
        "setpoint": {
          "name": "speed_sp",
          "variation_factor": -0.1
        },
        "type": "decrease_speed"
      },
      {
        "description": "Above max Drawdown, parameters stable",
        "setpoint": null,
        "type": "no_action"
      },
      {
        "description": "Casing Pressure Event Detected, no changes allowed",
        "setpoint": null,
        "type": "no_action"
      },
      {
        "description": "No action - monitoring",
        "setpoint": null,
        "type": "no_action"
      }
    ]
  }
}'

Upgrading Kelvin SmartApps™

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

For any new App Configurations introduced in the upgraded Kelvin SmartApp™ version, the default values will initially applied to the Workload.