What is Sense&Control?
The idea behind Sense&Control is to allow users to program a small amount of functionality into a Smartspot. This functionality will then continue to run, even when the connection to Brain server is lost.
Components
Sense&Control is based on three components: Senses, Function Blocks and Controls. Using these three components it's possible to create Flows. Sense&Control configuration supports multiple Flows at the same time. All component types and basic Flow design principles will be explained in this section.
Senses
A Sense can be seen as a probe or sensor that senses the state of hard- or software components in a Smartspot device. The output of a Sense represents the current state and updates each time a change has been detected.
A few examples:
- What is the Smartspot GPIO hardware input state (high/low)?
- Is the Smartspot connected with a Brain server?
- How many Items are there currently present (in range)?
- A clock generator that outputs a signal at a specified frequency (0,1,0,1...).
- Constant values.
Function Blocks
A Function Block implements a specific function. This can be a basic mathematical operator or a more complex implementation. Depending on their type, Function Blocks can accept one or multiple inputs and have at least one output. Function Blocks are optional components and are not required to create a simple and basic Sense&Control Flow.
A few examples:
- Mathematical operators.
- Binary operators.
- Compare two inputs.
- Timers.
- Delays.
- Counters.
Controls
The Control component can be seen as an output or endpoint in Sense&Control logic and it usually changes something in the hard- or software of the Smartspot device based on input state.
A few examples:
- GPIO hardware output.
- LEDs
- Sounds.
Links and Flows
The figures below show how Sense&Control components are connected to each other in a Flow. Each connection between components, as represented in the figure by an arrow, is called a Link.
The first figure shows a basic and simple Flow without any Function Blocks. There is one Link that connects the Sense directly to the Control.
An example for this flow can be a LED that is directly linked by the GPIO hardware input Sense of Smartspot device. In this example scenario: The LED will turn on as soon as the GPIO hardware input is activated. It turns off when the GPIO hardware input is deactivated.
The second figure shows a Flow with some functionality. There are two Links. The first Link connects the Sense to a Function Block. This block processes the input and outputs it's result. The second Link connects the output of the Function Block with the input of the Control.
For example, in the scenario that the Sense is a Smartspot GPIO hardware input, the Function Block a Delay and the Control a LED: The LED will be turned on when the GPIO hardware input is activated and Delay has timed out.
Control Schema
To configure Sense&Control for your Smartspot, all the Links for each Flow need to be stored in a configuration. This configuration is called the Control Schema and uses JSON encoding.
Component short code or Identifier
Each component has it's own short code. This identifier is used to keep the control schema as compact as possible.
Most of basic components use a fixed representation, for example, GPIO hardware input 1 has identifier in1
, GPIO hardware input 2 has in2
and the Front Green LED Control has identifier ledfg
. Others may use a template variant to allow for unique references among flows or dedicated in- / output designation.
References of all component identifiers, short and full descriptions can be found here:
- Link to Sense Reference
- Link to Function Block Reference
- Link to Control Reference
Encoding Format
The code blocks below show how the control schema looks like. Links are added as key, value inside the links object. This section explains two formats that can be used as a base to construct any possible Flow. Each format has an example to explain how to encode the component identifiers.
Single Link in a Flow
The code block below shows the base format for how to link a Sense to a Control.
{
"control_schema": {
"links": {
"<Control-Id>" : "<Sense-Id>"
}
}
}
Example Scenario
This basic example gives a scenario that links a Sense to a Control using GPIO Hardware Input 1 (Sense) to control LED Front Green (Control). If Hardware Input 1 is set, LED Front Green is activated.
How to resolve components step-by-step:
- Find the component Identifiers:
- GPIO Hardware Input 1:
in1
- LED Front Green:
ledfg
- GPIO Hardware Input 1:
- Fill in using the base formatting for how to link a Sense to a Control.
- <Control-Id>:
ledfg
- <Sense-Id>:
in1
- <Control-Id>:
{ "control_schema": { "links": { "ledfg": "in1" } } }
Multiple Links in a Flow
The code block below shows the base format for how to link a Sense via Function Block to a Control. This format can be extended to the number of additional components that may be required to complete your Flow.
{
"control_schema": {
"links": {
"<Function-Block-Id><Reference-Id><Input-Id>" : "<Sense-Id>" ,
"<Control-Id>" : "<Function-Block-Id><Reference-Id><Output-Id>"
}
}
}
Example Scenario
This example explains a scenario with a Function Block (AND). In this scenario both GPIO Hardware Inputs 1 and 2 need to be set to enable LED Front Green.
How to resolve Function Blocks step-by-step:
- The component Identifier starts with
&
, - Because it is first AND in our configuration, the Reference-Id is
1
, - The inputs for an AND are
a
andb
, - The output for AND is
o
, - <Function-Block-Id><Reference-Id><Input-Id> are resolved to
&1a
and&1b
, - <Function-Block-Id><Reference-Id><Output-Id> are resolved to
&1o
{ "control_schema": { "links": { "&1a": "in1", "&1b": "in2", "ledfg": "&1o" } } }
To update your new Sense Control schema, request a Smartspot config_request
in Brain Web API or use Intellifi Dashboard to update the control_schema
setting.
For more detailed example scenarios and how to process them into Sense&Control see Examples.
Comments
0 comments
Article is closed for comments.