Bosch IoT Device Management - will be discontinued by mid 2024

Create a task to auto-adjust the led color to green

In this section you will learn the first steps towards mass management.

You will send the "setColor" message to devices belonging to a specified device scope.

images/confluence/download/thumbnails/2232980470/led-info.png

Create a task

The task will set the LED on the virtual demo device to green.

  1. Open the Tasks view

  2. Click the + icon to create a new task.

images/confluence/download/attachments/2232980470/tasks-new.png

Fill in the Settings

  1. A name is required and could describe in human readable form what the task will do.

  2. The type can be Device or System (in our example select Device).

  3. The device selection by offers to choose a device set and filer conditions, ID, or a Groovy script. Choose the ID.

  4. The list with all devices registered for your subscription will be displayed at the right side. Check the box for your demo device.

  5. The ID is now listed as "Selected device".

  6. For the concurrency limit you can set a number.

  7. For the concurrency timeout you can set a number. These are the seconds upon which a non-confirmed execution will expire and will stop occupying room in the concurrency limit.

  8. Optionally you can define a time constraint.

  9. Continue with Next.

images/confluence/download/attachments/2232980470/demo-task.png

Fill in the Action

  1. Click the Groovy DI API to get assistance on the available methods.

  2. Search for the method to send the message you have applied to the LED feature of the demo device.

  3. Copy the method signature to the main field.

  4. Adjust it respectively to match the LED feature of the demo device.

    import groovy.json.JsonSlurper
     
    def color = '{"r":0,"g":255,"b":0}'
    target.exec('led', 'setColor', new JsonSlurper().parseText(color))
  5. Click Finish to launch the task.
    images/confluence/download/attachments/2232980470/tasks-action.png


In case your device is disconnected, you can connect it now and see if the task is executed.


Read the Tasks details


Retry the Tasks details

In case the device was not listening at the time the action was triggered, make sure the demo device is reported online and trigger the action again, manually.

images/confluence/download/attachments/2232980470/demo-task-retry.png

Check the Executions view

In case of errors, you will find details in the Executions view

images/confluence/download/attachments/2232980470/Snag_3178516.png

If your task shows "Finished with success" the log will look similar to this screenshot.

images/confluence/download/attachments/2232980470/tasks-success.png

Check the result on the demo device

The LED should be green. If you filter for the incoming messages you will see how the full message looks like.

images/confluence/download/attachments/2232980470/led-green.png

Further reading

  • Concepts > Device management concepts > Mass Management > Rules

  • How-to guides > Device Management > User interface > Create a task