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:
- Permanently Change a Value by Updating the Device Configuration: Typically used to set a default configuration such as with a Blueprint when the device is being set up.
- Temporarily Change a Value via the Command Button: Typically used to send a command or configure a specific parameter on a device as you also could do from an Edge Action or Cloud Action.
- Temporarily Change a Value via an Event in the Command Stream: Typically used to replicate or slightly modify an Event and send it to the device.
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):
- Navigate to Build > Device > Resources.
- Locate an example lcd/.
- 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:
Temporarily Changing a Value via the Command Button
Follow the steps below to temporarily change a value on the edge using the command button:
- Navigate to Build > Device > Resources.
- Locate an example lcd/.
- 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.
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:
- Navigate to Build > Device > Streams, click on it to select it.
- Locate the :command Stream.
- Check the last Event sent in the Stream:
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:
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:
- Navigate to Build > Device > Streams.
- Locate the :command Stream and select it.
- Click on New event button.
- Populate the elems object with the Event you want to send; the format is
"resource path": Resource value
. In the example below we change thetxt1
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.
- 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 addvalue
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.
Updated almost 4 years ago