4 Create and Manage Device Policies

Oracle has simplified edge computing implementation on Oracle Internet of Things Cloud Service by letting you create and modify policies externally from the device application. You do not need to write or compile any code. Instead, you create policies on the Management Console that define the data to collect, the data computation(s) to perform, and the frequency of data transmission.

After you create your policy, it is transferred to the client library. Moving policies out of the device application to the client library reduces the size and complexity of the device application and reduces the amount of data sent by the device. With policies, data no longer needs to be sent over the network as it is generated. The policy instructs the edge device to compile the data and send it to the central server at a defined interval. By only sending important data, edge computing significantly reduces network traffic.

What is Edge Computing?

With edge computing, data computations are processed at the edge of the cloud as close to the originating source as possible. Instead of sending raw data to a central server for computation, basic data computations are done at the collection point. Moving basic computations closer to the originating source reduces the amount of data that is sent to a central server, reduces the computing power needed by the central server, and improves the speed of data computations.

Edge computing is an ideal solution if your IoT devices have poor or intermittent connectivity to the cloud, or your data processing is latency-sensitive. With edge computing, devices do not need to be constantly connected to the cloud and latency is reduced or eliminated by performing data processing at the source. More importantly, edge computing lets you respond to local events in near real-time and helps you resolve issues quickly.

A Use Case for Edge Computing

Consider a manufacturing enterprise with factories and machines. Sensors installed on production machinery help a manufacturing facility determine when production line equipment requires maintenance or replacement.

A critical component of the production line is a labelling machine. The labelling machine must have a constant supply of ink and the ink must be kept at a specific temperature. Sensors installed in the labelling machine liquid storage containers and the valves and pumps that move the ink constantly send sensor data to a central server. When the sensor data arrives at the central server, computations are performed on the data to determine if any action is required. A lot of data is constantly communicated back and forward from the labelling machine to the central server. A loss in communication can shut the labelling machine down and disrupt production.

With edge computing, the labelling machine is equipped with a local computing solution that performs all of the computations that are typically performed by the central server. All decision making is performed locally and a package of collated data is sent to the central server daily where it can be monitored and human intervention can occur as required.

Edge computing prevents a preventative shutdown of the labelling machine when a communication error occurs. Manufacturing operations continue for a much longer period and the likelihood of a production disruption is significantly reduced.

Before You Create and Use Device Policies

Useful information before you start creating device policies for your devices.

About Device Policies

Device policies filter and process device data that was earlier done by applications. Take a note of these points before you create and use a device policy:
  • Make sure that the device policies when processing data validates that the data adheres to the device model rules, such as checking whether the range of the device data is valid.
  • For accurate assigning of a device policy to a device, make sure that you have associated the device with the correct device model.
  • A device can be associated with only one device policy at a time, which means that assigning a new policy to a device may remove the previously assigned policy.
  • Using device policies may change the data transmitting from the device to the Cloud Service. It may stop and alter the data flow such as in filter and summary device policies. It may change the original data such as in summary device policies.
  • Device policies may affect IoT analytics data by:
    • Changing the timing of the device data coming into the server. For example, the Eliminate Duplicates function of a policy will eliminate duplicate device values.
    • Changing the device data completely. For example, the Mean function of policy will send a calculated mean value of device values.
    • Preventing device data from coming into the server. For example, the Filter Condition function of a policy will filter values, preventing some device values from coming into the server.

Create a Device Policy

Create a device policy to define the data to collect, to filter unimportant data, to perform data computation(s), and to specify the frequency of data transmission.

A device model can contain one or more policies but a device can belong to only one policy at a time. Each policy contains one or more functions that form a policy pipeline. The functions will process the device data in the order of their occurrence in the pipeline. A function can filter and alter some or all of the device data before the subsequent function in the pipeline processes that data.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console:
    1. Open a web browser and browse to the URL of your Oracle Internet of Things Cloud Service instance. Typically, the URL is https://hostname/ui.
    2. Enter your user name and password and then click Sign In.
  2. Click Menu (Menu icon) next to the Oracle Internet of Things Cloud Service title on the Management Console
  3. Select Devices and then select Model.
  4. Select a user-defined device model in the device model list.
    You cannot add a device policy to a system-defined device model.
  5. Click Device Policies (Device Policies icon).
    The Device policy page appears that can contain one or more policies.
  6. Click Add Policy.
  7. Enter a name for the policy, enter an optional description for the policy, and then click OK.
  8. Click Add Policy Pipeline (Add icon) in the Attributes area.
  9. Complete these fields:
    • Target Attribute: Select the device attribute to which the policy applies.
    • Description: (Optional) Enter a description for the device policy.
    • Function: Select one of these options:
      • Action Condition: Select this option to invoke an action when the specified condition is true. The device model should have actions defined. in it.

        Select or enter the values for the function
        • Condition: Click to insert formula and define an expression in the formula editor. See Use the Formula Editor.

        • Action: Select the action to execute when the specified condition is true

        • Filter: Enable or disable this option to make the policy behave as a filter policy. Enabling this prevents the attribute from being set to the alerted value, if the condition is met.

      • Alert Condition: Select this option to generate an alert when the specified condition is true.

        Select or enter the values for the function
        • Condition: Click to insert formula and define an expression in the formula editor. See Use the Formula Editor.

        • Alert: Select the specific alert to be raised when the specified condition is true.

        • Severity: Select the severity to be assigned to the alert, from low, normal, significant, or critical.

        • Filter: Enable or disable this option to make the policy behave as a filter policy. Enabling this prevents the attribute from being set to the alerted value, if the condition is met.

      • Computed Metric: Select this option to compute a value from the specified formula.

        Formula: Click to insert formula and define an expression in the formula editor. See Insert Formula for Attribute Functions

      • Detect Duplicates: Select this option to generate an alert when a duplicate attribute value occurs within the specified period window.

        Select the values for these fields:
        • Window: Enter a duration in milliseconds for which data is accumulated for applying the function.

        • Alert: Select the specific alert to be raised when the specified condition is true.

        • Severity: Select the severity to be assigned to the alert, from low, normal, significant, or critical.

      • Eliminate Duplicates: Select this option to delete any message containing a duplicate attribute within the specified period.

        Window: Enter a duration in milliseconds for which data is accumulated for applying the function.

      • Filter Condition: Select this option to filter data when the specified condition is true

        Condition: Click to insert formula and define an expression in the formula editor. See Use the Formula Editor.

      • Max, Mean, or Min: Select one of these functions to capture the maximum, mean, or minimum value for the specified period.

        Enter or select values for these fields:

        • Slide: Enter a value to specify the frequency of evaluating the function

        • Window: Enter a duration in milliseconds for which data is accumulated for applying the function.

      • Sample Quality: Select this option to take a data sample at the specified rate.

        Condition: Click to insert formula and define an expression in the formula editor. See Use the Formula Editor.

        Rate: Enter -1 for random, 0 for none, or a number to specify the rate

      • Standard Deviation: Select this option to calculate a standard deviation for the specified period.

        Enter or select values for these fields:

        • Slide: Enter a value to specify the frequency of evaluating the function

        • Window: Enter a duration in milliseconds for which data is accumulated for applying the function.

  10. Click OK.
  11. Click Device Selection (Device Selection icon) and assign the policy to one or more devices.

    Note:

    You can only assign those devices that have the selected device model. A device can only be assigned one policy at a time. Assigning a device to this policy will remove any other policy that may have been assigned to the device.

  12. Click Save.

    The saved policy is sent to the client side immediately if possible. It depends on how often the clients connect to Oracle IoT Cloud Service. For some clients, the policy is received immediately and for clients that don't connect to the server frequently, may receive the policy later. The clients start processing the updated policy immediately after receiving it.

  13. (Optional) Click Back to return to the device model list.

Assign a Policy to a Device

Assign a policy to a device to make the device return the data specified in the policy.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Device Selection Filter (Device Selection Filter icon) and then select one of these options:
    • All: Assigns the policy to all devices using the selected device model.
    • Specific: Assigns the policy to a specific device using the search parameters you specify.

    Note:

    You can only assign the devices which have the selected device model. A device can only be assigned one policy at a time. Assigning a device to this policy will remove any other policy that may have been assigned to it.

  8. Click OK.
  9. Click Save.
  10. (Optional) Click Back to return to the device model list.

Add a Policy Function

Add a policy function to perform an additional data computation on the device to which the policy is assigned.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Add Device Function (Add icon) in the Function area.
  8. Select one of these functions in the Function list:
    • Action Condition: Select this option to invoke an action when the specified condition is true.

    • Alert Condition: Select this option to generate an alert when the specified condition is true.

    • Computed Metric: Select this option to compute a value from the specified formula.

    • Detect Duplicates: Select this option to generate an alert when a duplicate attribute value occurs within the specified period.

    • Eliminate Duplicates: Select this option to delete any message containing a duplicate attribute within the specified period.

    • Filter Condition: Select this option to filter data when the specified condition is true.

    • Max: Select this option to capture the maximum value for the specified period.

    • Mean: Select this option to capture the average value for the specified period.

    • Min: Select this option to capture the minimum value for the specified period.

    • Sample Quality: Select this option to take a data sample at the specified rate.

    • Standard Deviation: Select this option to calculate a standard deviation for the specified period.

  9. To insert a formula for the Condition field of the functions, see Use the Formula Editor.
  10. Click OK.
  11. Click Save.
  12. (Optional) Click Back to return to the device model list.

Add Attributes to a Policy

Add attributes to a policy to request additional data from the device to which the policy is assigned.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Add Policy Pipeline (Add icon) in the Attributes area.
  8. Complete these fields:
    • Target Attribute: Select the device attribute to which the policy applies.
    • Description: (Optional) Enter a description for the device policy.
    • Function: Select one of these options:
      • Action Condition: Select this option to invoke an action when the specified condition is true.

      • Alert Condition: Select this option to generate an alert when the specified condition is true.

      • Computed Metric: Select this option to compute a value from the specified formula.

      • Detect Duplicates: Select this option to generate an alert when a duplicate attribute value occurs within the specified period.

      • Eliminate Duplicates: Select this option to delete any message containing a duplicate attribute within the specified period.

      • Filter Condition: Select this option to filter data when the specified condition is true.

      • Max: Select this option to capture the maximum value for the specified period.

      • Mean: Select this option to capture the average value for the specified period.

      • Min: Select this option to capture the minimum value for the specified period.

      • Sample Quality: Select this option to take a data sample at the specified rate.

      • Standard Deviation: Select this option to calculate a standard deviation for the specified period.

    To insert a formula for the Condition field of the functions, see Use the Formula Editor.
  9. Click OK.
  10. Click Save.
  11. (Optional) Click Back to return to the device model list.

Duplicate a Policy

Duplicate a policy to quickly copy existing policy settings to a new policy.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Identify the policy you want to duplicate and click Duplicate Policy (Duplicate Policyicon) for that policy.
  7. Enter a name for the policy, enter an optional description for the policy, and then click OK.
  8. (Optional) Add a policy pipeline.
  9. (Optional) Edit the device function for the policy, or add a new device function.
  10. Click Device Selection (Device Selection icon) and then select one of these options:
    • All: Assigns the policy to all devices using the selected device model.
    • Specific: Assigns the policy to a specific device using the search parameters you specify.

    Note:

    You can only assign the devices which have the selected device model. A device can only be assigned one policy at a time. Assigning a device to this policy will remove any other policy that may have been assigned to it.

  11. Click Save.
  12. (Optional) Click Back to return to the device model list.

Edit Policy Details

Use the Edit Policy dialog to change the policy name and description.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Edit (Edit icon).
  8. Enter a name or an optional description for the policy, and then click OK.
  9. Click Save.
  10. (Optional) Click Back to return to the device model list.

Edit Policy Function Settings

Edit policy function settings to update the settings for the policy. For example, you can change the severity setting or the alert trigger.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Edit (Edit icon) in the Function area.
  8. Update the policy function settings.
  9. Click OK.
  10. Click Save.
  11. (Optional) Click Back to return to the device model list.

Increase or Decrease Device Policy Priority

Increase the device policy priority to assign the selected device policy precedence over the device policies that follow it. Decrease a device policy to reduce its precedence over the device policies that precede it.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Select one of these options:
    • Click Decrease Priority (Decrease Priority icon) to decrease the priority of the device policy.
    • Click Increase Priority (Increase Priority icon) to increase the priority of the device policy.
  8. Click Save.
  9. (Optional) Click Back to return to the device model list.

Delete a Policy Function

Delete a policy function when it is no longer required.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy.
  7. Click Delete Device Function (Delete icon) in the Function area.
  8. Update the policy function settings.
  9. Click Delete.
  10. Click Save.
  11. (Optional) Click Back to return to the device model list.

Delete a Policy

Delete a policy when it is no longer required. When a policy is deleted, the device that used the policy is assigned the next available policy in the order defined on the Device Policies dashboard.

  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select the policy that you wish to delete and click Delete (Delete icon).
  7. To confirm, click Delete.
  8. (Optional) Click Back to return to the device model list.

Enable Device Policies

Use the Disabled slider button to enable a device policy to which device filters have been added. When required, you can use the same slider button to disable the device policy.

After creating a device policy, you must associate it with one or more devices using the Device Selection Filter button. Only after you've applied a device filter to a device policy, you can enable it. Until then, the device policy remains disabled.
  1. Sign in to the Oracle Internet of Things Cloud Service Management Console.
  2. Click Menu (Menu icon) next to Oracle Internet of Things Cloud Service.
  3. Select Devices and then select Model.
  4. Select a device model in the device model list.
  5. Click Device Policies (Device Policies icon).
  6. Select a device policy. Ensure that the policy has a device filter.

    You can apply a device filter by using the Device Selection Filter (Device Selection Filter icon) button.

  7. To enable the device policy, click Disabled (Disabled icon).
  8. Click OK.

    Note:

    If two or more device policies are applied and enabled on the same device, then the policy whose device filter includes the particular device at a higher level, takes precedence. If you disable a device policy, the devices that match it's filter may be re-assigned to another policy, which is enabled.
  9. Click Save.
  10. (Optional) Click Back to return to the device model list.

Use the Formula Editor

Use the formula editor to define an expression that evaluates a condition for a function of a device attribute. The function becomes a part of the policy pipeline.

The formula editor appears with a function associated with a device attribute. You can build your expression using the elements of the formula editor.

The following example shows a condition that validates if an attribute value is not equal to a specific number. In this example, the formula editor was used to select humidity as the attribute, != as the operator, and 13 as the numeric value.

Add Policy Pipeline dialog box for a function of a device policy

Start building your formula by selecting properties, functions or operators from the formula menu.

The image displays the elements of the formula editor explained after the image.Elements of the Formula Editor

Your expression can contain the following elements:
  • Parenthesis: Use parenthesis to group operations and indicate precedence.
  • Boolean: Use boolean to select true or false in the expression.
  • Number: Use number to enter a numeric value.
  • Text: Use text to enter alphabetic characters.
  • Property: A list of attributes that you can use to build your own expression. This list is based on the device model attributes and function that you selected. Click property to select an attribute from a list of attributes.
  • Functions: Use functions to select the UPPER or LOWER functions.
  • Operators: You can use arithmetic (
    +, -, *, /
    ), relational (
    =, <, >, <=, >=, !=
    ), and logic (
    AND, OR,
              LIKE
    ) operators.