This article lists a few basic examples to help you design Flows for Sense&Control. The reader of this article should have basic understanding of how Sense&Control works, the available Senses, Controls and Function Blocks. If not, visit the Sense&Control Introduction article first.
Examples:
Flow 1: Enable a LED if an Item is in immediate range
For this example we would like to enable the LED Red Front when a RFID Item is in immediate range. If the Items changes proximity to near or far, the LED should be disabled. In this example we'll use a basic Flow approach as shown by the figure below and won't add any Function Blocks.
Sense
To know that one or more Items are in immediate range of a Smartspot device we can use a number of options that are default available in Sense&Control. For this example we'll use the Total Items matching an Item Set based on Requirement Sense. See the detailed description in Sense Reference for more information about this Sense.
This Sense type offers multiple options that can be used to implement this example:
- Wildcard set0. All types of Items will match this Item Set.
- Technology based Item Sets:
- set101 matches all RFID Items.
- set102 matches all Bluetooth Items.
For the purpose of this example we'll use Item Set set101. This set counts RFID items which is a requirement in this example.
Note: If you would like to trigger based on a different technology or all technologies, you can simply replace set101 with one of the options listed above.
The Short Code Id for this Sense type is a template which means that we have to enter a value for each argument before it can be used in our configuration set{setid}{stat}
.
- We choose to use set101, so the value of argument
setid
is 101. - To get the total of immediate Items, we'll use
i
as value for thestat
argument. - The final Sense short code identifier including the values for arguments
setid
andstat
isset101i
.
Control
For the Control we use the LED Front Red. This LED is located on the cover near the Intellifi logo of the Smartspot device. The Short Code Id for this Control is ledfr
and is not a template. For the detailed description of this Control see Control Reference.
Finalize Flow Design
The Sense&Control Flow now looks like the figure above. To configure this Flow for the Smartspot, we have to encode the figure to Links in the JSON format. The result of this encode step is shown in the code block below.
{
"control_schema": {
"links": {
"ledfr" : "set101i"
}
}
}
Update Smartspot Configuration
Dashboard
Update the Smartspot configuration control_schema with the JSON content below.
{
"links": {
"ledfr" : "set101i"
}
}
Brain
Post a config_request to the Smartspot resource and paste the JSON content in the request body.
{
"control_schema": {
"links": {
"ledfr" : "set101i"
}
}
}
Flow 2: Using a LED, Hardware Input and Timer
For this example we would like to control LED Front Red using the following conditions:
- Turn the LED on immediately if Hardware Input 1 has been activated.
- When Hardware Input 1 is deactivated, keep the LED on for 5 seconds, then turn it off.
Flow Links
The figure below shows our initial Flow design using the given scenario. All the individual parts are explained below.
GPIO Hardware Input 1
The GPIO Hardware Input 1 in1
as described by Sense Reference is accessible via the external connector near the Ethernet connector and can be used to connect external wiring to the Smartspot device to trigger Sense&Control Flows. The Short Code Id of this Sense is not a template and therefore doesn't require any additional argument values.
Timer
The Short Code Ids for the Timer Function Block are a template and require some additional arguments for the operation as indicated by the description given in Function Block Reference. The Timer needs three inputs and has one output. The Short Code Id of this Timer Function Block is given as t{num}{x}
. Because this is the first Timer component in Sense&Control, the argument num
can be set to 1. This results in t1{x}
.
Timer Set
In this example, Timer Set t1s
should be linked with GPIO Hardware Input 1 in1
to set the Timer and initiate the delayed turn off for LED Front Red.
Timer Ticks
In this example, Timer Ticks t1t
input will be linked with the 5Hz Clock Generator Sense. This generator generates a 0,1,0,1 signal using a frequency of 5 times per second.
Timer Value
In this example, Timer Value t1v
needs to be linked with a Constant Value Sense to set the maximum duration of the Timer. Because we use 5 Hz Clock Generator Sense to generate the input for Timer Tick, and the Timer counts all changes (rising and falling) on this input, the operating frequency of the Timer is 10 Hz. To get our delayed turn off time of 5 seconds, this means that the Constant Value needs to be set 50. The identifier of the Constant Value will be #50o
.
Timer Output
In this example we use the LED Front Red. This LED is located on the cover near the Intellifi logo of the Smartspot device. The name for this Control is ledfr
. Find the detailed description in Control Reference. The input of LED Front Red needs to be linked with Timer Output t1o
.
Finalize Flow Design
Now that we found and established all components and determined their identifiers, we can finalize the Flow by replacing the names from our earlier Flow design with the component identifiers. The figure below shows the result of this process.
The Sense&Control Flow now looks like the figure above. To configure this Flow for the Smartspot, we have to encode the figure to Links in the JSON format. The result of this encode step is shown in the code block below.
{
"control_schema": {
"links": {
"t1s" : "in1",
"t1v" : "#50",
"t1t" : "tick",
"ledfr": "t1o"
}
}
}
Update Smartspot Configuration
Dashboard
Update the Smartspot configuration control_schema with the JSON content below.
{
"links": {
"t1s" : "in1",
"t1v" : "#50",
"t1t" : "tick",
"ledfr": "t1o"
}
}
Brain
Post a config_request to the Smartspot resource and paste the JSON content in the request body.
{
"control_schema": {
"links": {
"t1s" : "in1",
"t1v" : "#50",
"t1t" : "tick",
"ledfr": "t1o"
}
}
}
Comments
0 comments
Please sign in to leave a comment.