TC2.5 - IOT application; IOT Discovery of sensors and actuators for reading observations


Warning message

  • You can't delete this newsletter because it has not been sent to all its subscribers.
  • You can't delete this newsletter because it has not been sent to all its subscribers.

Test Case Title

TC2.5 - IOT application; IOT Discovery of sensors and actuators for reading observations


I can:

  • Use of the IOT Directory for discovery devices, sensors and actuators, selecting them and generating the flows for reading data. We remark that also actuators can deliver notification of actions they have done.
  • select devices, sensors and actuators retrievable from different Context Brokers (Orion, Mosquitto, RabbitMQ…) independently if they work on different protocols (NGSI, MQTT and AMQP)
  • discover IOT devices on MAP located near to a point independently on their Broker and protocol
  • on the map, it is possible to select a geographic area by using a point, a circle, a polyline or a polygon


IOT application IOT Discovery of sensors and actuators for reading

The following functionalities are available only for a specific Snap4City account with specific privileges.

Expected successful result

Generation of flows of data corresponding to the selected sensors. The sensors is retrieved from the context brokers in which they are registered. The obtained flow is the base for the creation of IoT applications that need to read data from heterogeneous devices




In this test case we present the two kinds of discovery that are made available for reading the data from devices (other modules have been developed for the discovery of devices to which commands should be sent – see TC1.11):

  • Retrieving devices (named device-based search).
  • Retrieving sensors and actuators (named value-based search) .


Discovery of devices: device-based search


  1. Open a Flow in your cloud (TC2.1a) or local (TC2.1b) IotApplication
    1. Look in the left side bar for the following two functions:
    2. They are the blocks for receiving events from sensors and actuators and for sending commands to actuators, respectively.
    3. Drag and drop in the main canvas “IOT Directory” (the first one). You can see on the right side the help for the block.
  2. Open the setting form (as depicted in the following figure) by double clicking on the block. Two kinds of retrieval can be carried out:
    1. The first one for retrieving devices (named device-based search).
    2. The second one for retrieving values coming from sensors and actuators (named value-based search) .
      Here we concentrate on the device-based search.

      In the device-based search, it is possible to initially specify whether we are interested in producing a flow that is “aggregated by device type” or not. If this check box is not clicked, a single output is produced by the generated flow in which all the events produced by the selected devices appears.  By contrast, when it is clicked (which is the default option), the selected devices is aggregated relying on their device_type and a number of outputs corresponding to the different device_type is generated. This concept is made clearer in the remainder of the presentation.
  3.  By using the device-based search tab as you can see it is possible to retrieve the devices on a map. In this case, a map is shown to the user that can create a point, a circle, a polyline or a polygon on the map for identifying the devices available in such an area. When you draw point or a circle you are looking for devices within 100 meters far from the point or the line. When you draw a circle or a polygon you are looking for devices within the drawn area, when you draw a polyline or specify a point you are looking for devices within 5km far from the point or the line.


 The devices contained in the selection area (depicted in blue in the figure) are reported in the following list that the user can further refine:



Note that, it is possible to click on a specific device and you can see some information about the selected device. Note also that public devices are reported in blueblue, whereas private devices owned by the current user are reported in red. Note also that in left side, there are different options according to which it is possible to select the devices on the map: along a polyline , within a polygon , within a circle, closer to a point . Whenever the selection is not appropriate, it is possible to remove it by clicking t .


The following is an example of retrieval along a polyline: you click on  and draw a polyline as shown in the figure below, by double clicking on the last point of the polyline you finish the drawing, and you can see that in the list of devices, only the ones that are within 5km distance from your polyline is selected.



  1. In addition to the map retrieval, devices can be retrieved according to different parameters: device type (humidity, temperature …), kind (sensors or actuators), and Context Broker (Orion, Mosquitto, Rabbit). Depending on the selected parameters and selection, the list of devices is filtered and you can identify the devices needed for a given analysis. It is also possible to search devices by inserting the name (or part of it) in the text label "Search". The available retrieval parameters are shown in the following figure:




  1. By using the drop-down menu “Type” select “thermometer” then select the device “test_sensor02” and thermometer_mqtt01 “”. Moreover, select “all” from the field “Type” and by using the drop-down menu “Context broker” select the “mqttUNIFI” and then by scrolling down you can select the sensor: “fan02” as depicted in the following figure:



If you select “all” from “Context broker” and scroll down the list, you can see that the two devices have been both selected.


NEXT STEPS are WORK-IN-PROGRESS. To retrieve the ServiceURI of the IoT Device, please use ServiceMap or the Data Inspector


  1. Once selected, we can click on “Done”. At this point the system automatically generates the flow that acquires the values from the two devices belonging to two different context brokers (the context brokers are automatically configured).  The generated flow depends on the initial selection about the aggregation based on device type (see item 2 of this test case).
  2. Suppose that the “aggregate by device type” is not clicked. The flow is reported in an import menu as the following one:

  3. When you click on “current flow” and then on “import” and you can place the link block on the current canvas and in automatic way a new flow is generated in a new tab.



  1. The link block is linked to the flow created in the other tab as shown in the following figure.  


  1. As reported in the figure, the generated flow has been realized for acquiring data from the Orion context broker and from the MQTT context broker. These node-red blocks have been already configured and no action is required from the user. A block “transform” is included also in the tab for each context broker. The purpose of this function is to transform the values arriving from a broker in a common format and thus making easy its management. The transform function block (automatically generated) converts the incoming messages (that can be in JSON, XML, CSV) in a common format based on the internal Node-RED representation of data. The possibility to have the data acquisition flow in a separated tab is particularly useful, because the user has not to worry about the acquisition of the values from the devices but can focus on the generation of the flow for manipulating them. We remark that the flow in this case produce data in a single channel. Whenever the device type of the considered devices is different, the structures generated in output can be different (even if they are represented in JSON). Therefore, the developer has to take into account this fact in the generation of his IoT application. In order to face this issue, the other option “aggregate by device-type” can be chosen by the user.
  2. Suppose now that “aggregate by device type” is clicked and that the three previous devices have been selected.  When the user clicks on the “done” button, a flow is generated and when you import the flow in the current canvas, you obtain the following result:
    In this case, two links appear in the current tab corresponding to the two different device types of the selected devices. In the automatically generated tab the following flow has been reported:


The data produced by the two sensors of type thermometer are conveyed to the same link. In this way, the developer is aware of the kinds of data produced by the device and can generate applications that take this information into account.

The two modalities (aggregation by device-type and not) can thus be exploited for the development of different kinds of applications. The first one for applications that rely on the type of generated data (independently from the device that produces it) and are able to react to their events. The second one for applications that can react differently depending on the events generated by different types of devices.


Discovery of devices: value-based search

Another facility offered by the block "Iot Directory" is the retrieval of single values generated by the different devices. This retrieval capability is activated by means of the second tab of the block setting interface: “Value-based search”. In a similar way as we have shown for the device-based search, it is possible to search values relying on the map or on parametric search. Moreover, the generated flow is aggregated for value_type. The approach is similar to the one discussed at the device level and allows you to aggregate values relying on the single sensor/actuator value_type. Suppose now that you wish to identify all the measurements that are generated closer to the station “Santa Maria Novella” in Florence. For this purpose, you can use the value-based retrieve facility on map.


  1. Open a Flow in your cloud (TC2.1a) or local (TC2.1b) IotApplication
    1. Drag and drop in the main canvas “IOT Directory” (the first one). You can see on the right side the help for the block.
    2. Open the setting form by double clicking on the block and click on value-based search .
  2. By using the “Map Search” in the “Retrieval” menu you have to zoom to the center of Firenze and  to look for the “Santa Maria Novella” train station.



3. Then, you can click on the button and draw a circle around the area of the train station.