Pass Value from SmartApp to Device Tile

Hello.
I want to pass a dynamic variable from a smart app to a device and display the value on a tile.

SmartApp:
The app gets a dynamic value from a website every 5 minutes. I store the value to “webvalue”
variable.

DeviceHander:
I want to create a virtual device in order to represent the data from smart app.

The problem is that I don’t know how to pass the “webvalue” to the virtual device in order to display it on a tile

Any suggestion please?

Hi, @Panos

To create a dynamic SmartApp page, you can implement the Simple SmartApp Tutorial and update the SmartApp’s definition as following:

/* Defines the SmartApp */
app
    //.enableEventLogging()  // Log and pretty-print all lifecycle events and responses
    .disableCustomDisplayName(true)
    .permissions(['r:devices:*', 'x:devices*'])
    .appId('Example SmartApp')
    .page('mainPage', (context, page, configData) => {
        // Random value - This value should be replaced
        // by the Web Service's value you want to use.
        let randValue = (() => Math.round(Math.random()*10))
        // String to display the value.
        let paragraph = '\n- Dynamic value: '+ randValue() +'\n'
        // SmartApp's paragraph sertting.
        page.complete(true)
          .name('WebValue Example')
          .section('Web Value', section => {
            section.paragraphSetting('')
              .name('Example SmartApp that capture reading from X Web Service.')
              .description(paragraph)
        });
    })
    .updated(async (context, updateData) => {
    ...

Note: The value will be updated every time you open the SmartApp. Also, the randValue and paragraph variables shoud be handled according to your needs.

To push this values from the SmartApp to a Virtual Device, follow the next steps:

  • Implement the first part of the Schema Custom Capabilities tutorial to create the virtual device.
  • Get the device Id from the SmartThings API.
  • Implement command handlers to push these values to the device (Notice that certain capabilities do not support for commands.).

If you find this information useful, please let me know by setting this response as a Solution, otherwise feel free to share your questions with me.