Applying Contexts and Devices to Flows
This sections consists of the following:
Replication Overview
Once a flow is created and deployed, it can be applied to a context or multiple contexts – this process is referred to as replication. Replication allows you to create a single flow template and then re-use that flow multiple times. Doing so reduces the number of tasks and time needed to deploy a site that has common steps.
For example: a building can have 30 floors with 30 rooms, each with a temperature sensor that needs to provide the local temperature to an air conditioning unit. In order to program each room individually, you would need to repeat the same steps 900 times. The replication feature within the Sequencing widget allows you to create a single flow template and then apply it to all the rooms with one step.
Replication is based on the concept of relative datapoints for the IAP Input and Output nodes, which was discussed in the previous section. When you apply contexts to a flow template that contains IAP nodes with relative datapoints, a matching algorithm (described in the following section) running in the background matches all possible datapoints in that context to the relative datapoint in the flow. Multiple contexts can be selected and applied to the flow template. The result is one or more flow(s) that get automatically created depending on the number of contexts being replicated.
Flows that are replicated are called service flows. All replicated contexts appear the service flow, which is added to the Sequencing widget in a new tab with the [S] designation as shown in the example below. You will need to use the scroll bar to view all of the flow in the workspace.
SmartServer 4.0 Update 1 and prior example
For SmartServer 4.1 (Beta) and higher, the Sequencing widget buttons appear as shown below.
Recall that a device type is used to achieve a desired behavior from a device. This functionality is also true with Node-RED flows. Therefore, if there are two physically identical devices in a context and you only want one of them to be matched to the flow template, you have to create and assign the devices to two different device types and select the relative datapoint for the desired device type.
Matching Algorithm
Since contexts are hierarchical, every context has at most one parent and can have any number of children (zero or more). And, it is recursive in that the parent may have its own parent, and the children may have their own children.
For example: a room or area context belongs to a single floor, that belongs to a building, that belongs to a campus. Resolution of relative references is strictly limited to the context’s hierarchy, which is done in search phases. There are two separate search phases. The first phase is the descent and the second is the ascent.
During the descent, the context being applied and all its children are visited recursively until all the leaf nodes (no more children) are hit. If there is a flow target, then the descent only operates on contexts defined by the flow target.
During the ascent, the traversal goes to the parent, then its parent, and so on, until the root node is hit. During the descent, each visited context is conditionally applied to the flow. The application to the flow is conditional because a flow may not qualify for a particular context.
In order for a flow to qualify, the following conditions must be true:
- At least one relative IAP Input node or IAP Output node must be resolved at that level.
- All the inputs feeding into the flow must be resolvable using datapoints at that level, or by those found during the ascent.
Considerations for Area Context Types
When applying area context types to flows, consider the following:
- When an area is applied to a flow, all datapoints that are located within the boundaries of the area are matched to that flow regardless of whether those datapoints belong to other contexts at that level.
- When a room context encompassing an area, overlapping an area, or contained within an area is applied to a flow, the area is ignored and all applicable datapoints from that room are matched. Other potential matches are found through hierarchical ascents and descents.
- When a floor or campus with area context types are applied to a flow, there is an option for selecting an area context as a flow target.
See Defining and Using Contexts for more information.
Applying Contexts to Flows – Replication
To apply contexts to a flow, perform the following steps:
- Open the SmartServer CMS.
- From the flow menu (see Using the Flow Menu in the Creating Sequence of Operations section), click the Apply to Flow button () for the desired flow.
The Apply contexts to flow view appears for the selected flow. - Click the checkmark for the context(s) to be applied to the flow. (The checkmark changes from blue to yellow.)
Or, click the Select All button () to select all contexts. - Click APPLY. The Sequencing widget appears.
Applying Devices to Flows
To apply devices to a flow, perform the following steps:
- Open the SmartServer CMS.
- From the flow menu (see Using the Flow Menu in the Creating Sequence of Operations section), click the Apply to Flow button () for the desired flow.
The Apply contexts to flow view appears for the selected flow. - Select the APPLY DEVICES TO FLOW tab.
The APPLY DEVICES TO FLOW view appears. - Click the checkmark for the device(s) to be applied to the flow. (The checkmark changes from blue to yellow.)
Or, click the Select All button () to select all devices. - Click APPLY. The Sequencing widget appears.
Removing Associated Contexts from Flows
To remove associated contexts from a flow, perform the following steps:
- Open the SmartServer CMS.
- From the flow menu (see Using the Flow Menu in the Creating Sequence of Operations section), click the Remove from Flow button () for the desired flow.
The Remove contexts from flow view appears for the selected flow. - Click the checkmark for the context(s) to be removed from the flow. (The checkmark changes from blue to yellow.)
Or, click the Select All button () to select all contexts. - Click APPLY. The Sequencing widget appears.
Removing Associated Devices from Flows
To remove associated devices from a flow, perform the following steps:
- Open the SmartServer CMS.
- From the flow menu (see Using the Flow Menu in the Creating Sequence of Operations section), click the Remove from Flow button () for the desired flow.
The Remove contexts from flow view appears for the selected flow. - Select the REMOVE DEVICES TO FLOW tab.
The REMOVE DEVICES FROM FLOW view appears. - Click the checkmark for the device(s) to be applied to the flow. (The checkmark changes from blue to yellow.)
Or, click the Select All button () to select all devices. - Click APPLY. The Sequencing widget appears.