Controlling Device Properties

Overview

You can set values on an Octave edge device (e.g., the reporting period for a Resource, a Sensor threshold, etc.) by either:

  • permanently setting the Octave edge device's default configuration state; or
  • issuing Commands to temporarily change values that override the default configuration state, but revert back to the defaults when the device is rebooted.

The following methods can be used for changing values:

The following subsections use the example of setting the LCD value on the LCD screen included with the mangOH Red, to illustrate the two methods for setting a Resource value.

Permanently Changing a Resource via the Configured Value

Follow the steps below to permanently change a Resource value via the configured value (i.e., via the Resources Screen):

  1. Navigate to Build > Device > Resources.
  2. Locate an example lcd/.
  3. Click the edit button to the right of the txt1 property, change the text value, and click Set and then Apply.
    The text on the LCD will change and this value will persist when the device is power cycled.

The change is actually a change to the device configuration.
You can determine if the configuration has been processed on the device and/or if there was an error, looking for PUSH_CONFIGURATION_START / PUSH_CONFIGURATION_COMPLETE in the Stream :inbox of your device; they also appear in the Recent changes widget of the Device details screen:

553

Temporarily Changing a Value via the Command Button

Follow the steps below to temporarily change a value on the edge using the command button:

  1. Navigate to Build > Device > Resources.
  2. Locate an example lcd/.
  3. Click the command button to the right of the txt1 property, enter a new text, and click Send. The text on the LCD will change but this value will not persist to the device reboot.
1389 766

The command has been sent to the device sending an Event with the new value into the Stream :command of the device.
You can check the Event you just sent:

  1. Navigate to Build > Device > Streams, click on it to select it.
  2. Locate the :command Stream.
  3. Check the last Event sent in the Stream:
1355

You can determine if the command has been processed on the device and/or if there was an error, looking for COMMAND_START / COMMAND_COMPLETE or COMMAND_FAULT in the Stream :inbox of your device; they also appear in the Recent changes widget of the Device details screen:

540

Temporarily Changing a Value via an Event in the Command Stream

Follow the steps below to temporarily change a value by creating an Event in the Command Stream:

  1. Navigate to Build > Device > Streams.
  2. Locate the :command Stream and select it.
  3. Click on New event button.
  4. Populate the elems object with the Event you want to send; the format is "resource path": Resource value. In the example below we change the txt1 of the LCD on the mangOH red:
{  
  "elems": {
    "lcd/txt1": "Pong !"
  },
  "hash": null,
  "location": null,
  "metadata": null
}

πŸ“˜

Note

The maximum payload (JSON) size is 50000 characters.

  1. You will see the Event added to the :command Stream of your device.

Like in previous example, you can determine if the command has been processed on the device and/or if there was some error by looking for COMMAND_START / COMMAND_COMPLETE or COMMAND_FAULT in the Stream :inbox of your device; they also appear in the Recent changes widget of the Device details screen.

πŸ“˜

Resource Path

Most of the time you will need to change the sub Resource value of a Resource, in this case you add value to the Resource path (e.g., /app/NAME/value).

The following example shows the Event to send in order to update a Virtual Resource named lightThreshold :

{  
  "elems": {
    "virtual/lightThreshold/value": 1200
  }
}

It is possible to add a timeout or ttl: time to live parameter to the Event you are sending to the :command Stream of a device. When this parameter is set, Octave will attempt to deliver the command to the device until it succeeds, or the timeout is exceeded. Timeout and TTL are defined as optional attributes of the Event metadata field, parameter is milliseconds.

In the example below the command will timeout after 1 minute:

{  
  "elems": {
    "lcd/txt1": "Pong !"
  },
  "metadata": { 
    "ttl": 60000
  }
}

πŸ“˜

Note

You can programmatically set values in the Command Stream as described here.