Reading Event Data in an Edge Action

When writing the code for an Edge Action, you will usually base your logic around the value from the incoming Event being Observed such as the value of a sensor reading.

When an Event is received in an Edge Action, the event parameter contains the Event's data:

function(event) {

}

The Event is received as a JSON object on the Octave Edge device and contains the following fields:

{
  "value": value,
  "timestamp": 1582827837.235676
}
  • value: the Event's data (e.g., a sensor reading).
  • timestamp: The date/time when the event was received.

The JavaScript in an Edge Action can read this information via the event parameter. For example, the following code reads the value of a light sensor:

function(event) {
  var lightReading = event.value;
  // ...
}

After reading the Event's value, you may then want to perform some logic and then set a value. For additional information see the Edge Action Runner Reference.