Skip to content

Application Deployment Context

When your application connects to Kelvin, it receives runtime information about its deployment environment. The KelvinApp instance provides access to:

Attribute Description
app.app_configuration Application-specific configuration settings.
app.inputs Input datastreams configured for your application.
app.outputs Output datastreams configured for your application.
app.assets The assets your application is deployed to (most important).

Working with Configuration

Note

You will also need to setup the app.yaml properly for this feature to function properly.

You can read the full documentation on App Configurations in the Develop SmartApps section here.

This an example on how to access the global configuration variables in a Kelvin SmartApp™:

Get Configuration Values Python Example
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
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"]

Working with Assets

The app.assets dictionary contains all assets available to your application. Each asset provides access to its properties, parameters, and datastreams:

Working with Assets Python Example
from kelvin.application import KelvinApp

app = KelvinApp()

async def on_connect():
    # Access all available assets
    for asset_name, asset in app.assets.items():
        print(f"Asset: {asset_name}")

        # Access asset properties
        print(f"  Properties: {asset.properties}")

        # Access asset parameters
        for param_name, param_value in asset.parameters.items():
            print(f"  Parameter {param_name}: {param_value}")

        # Access asset datastreams
        for ds_name, datastream in asset.datastreams.items():
            print(f"  Datastream {ds_name}: {datastream}")

app.on_connect = on_connect
app.run()

Assets are the core resources in Kelvin, representing physical or logical entities (machines, sensors, systems, etc.). Your application interacts with assets by reading from their datastreams and publishing data or control changes back to them.