HOW TO: add IOT Device data source from external broker to the platform.

    1. Click on the IOT Applications menu item on the left bar and press the “Create new” button

    1. specify the name of the IOT Application you are creating.  Confirm.

    1. When created, the IOT Application is show.

    1. Double Click to enter in the IOT App and edit. Please remember to Deploy the IOT App to save the current flow on cloud.

    1. Into the IOT App editor above, on the left side the list of Nodes/Blocks that can be used in the various flows. Those that are of interest for this example are into S4CIOT Collection as:

    1. The data input node must be selected according to the version of the IOT Orion Broker standard (v1 or v2) you have a your disposal.

    1. Once set the protocol used, drag the correct Node with the mouse over the Node-red background editor and double click on it.
    2. The configuration panel opens:

    1. You can add the address of the Orion Broker by clicking on the pencil next to the list of the Service field, i.e.:

 

    1. Enter the data of your IOT Orion Broker (in this case we are using one of the our accessible brokers) and press the red button to Add.

    1. It is mandatory to enter the name (on field Device NameID) and type (on field Device type) of the device for which you want to retrieve data. The data will arrive at the Node only when the value of the recorded data changes (according to Push model). For example, if the device measures a temperature of 20 degrees when the flow is executed, the Node on the IOT App will receive data if the temperature takes a value other than 20 (this depends on how the IOT Device has  been set).
    1. You can connect the IOT App node (subscribe your Node/App) to the IOT Orion Broker by using different authentication approaches (in all the following cases, the information, keys, certificates, etc., has to be provided by how is providing access to the IOT Broker at which you are connecting):
      1.  Two keys: key 1, key 2 (similar to SigFOX) (they can be called username and password in some cases)
        • Inserting the keys in the fields:

      1. Certificates
        • The second field can be used for authentication through certificates,

        • by entering the certificate, key and certificate of the platform (CA Certificate):

      1. API Key: Inserting API Key in the field:

      1. Basic Authentication: Inserting Basic Authentication in the field:

      1. No Authentication: selecting this case, means that Node will be capable to subscribe without using any kind of authentication mechanism.
    1. In the attributes field you can choose one of the possible data of the registered device to have only that data output and not the list of all attributes (just an option). 

    1. Example of configuration:

    • Once the configuration information has been entered, press the red "DONE" button and, after closing the configuration panel, press the red "DEPLOY" button.
    • In order to see the data coming. You have to connect the Node of ingestion “Fiware Orion” to a debug Node obtaining

    1. The JSON that is returned from the Orion Broker on the “debug” tab at your right:

    1. Please see that all the attributes in an array are returned, with all the values recorded on the Orion Broker for that particular device, the full message. In the above example only one came because it was filtered on temperature. To this end, you need to insert a function node at the output of this just done you can retrieve the single value and clean it from all the JSON:

    1. Where function node has been set as:

    1. The IOT Orion Broker does not save your data. If you want to save the data to create the trend and  history of them to analyse/show them any time from your portal you must create a KPI. (please note that the IOT Broker is a Snap4City broker this activity is performed automatically)
    1. To create a new KPI container of your data you can access the KPI Editor from the main menu item "My Data, KPI, POI".

               

    1. Thus accessing to the "KPI Editor". In this editor you can see your own MyKPI Data, you can make them public, and delegate, etc. (see HOW TO ...................... for details ).

    1. Select “Add My KPI” from the yellow button on top to add a KPI, then fill in at least the required fields in the form that is shown. Choose Nature and SubNature according to the value you want to record, name that value in the ValueName field, indicate a unit of measure for that value in the ValueType field and select a format in DataType. In addition to these mandatory values, you can add additional information that the user wants to add to this data. An example:

    1. Once you have filled in the desired fields you can Save  get a new line in the KPI Editor:

    1. Having created a KPI it is possible to save the data collected from the IOT Broker into MyKPI using nodes of the  S4CKPI Data (please remind that this process is not needed to manage data that are on Snap4City IOT broker  since they are set automatically):

    1. And in particular the node:

    1. Clicking twice on this node you can see the configuration and in the initial list you should choose the KPI on which to send the data that must show the one just created in the KPI Editor.

    1. Remember to click the red button “DONE” to save the configuration.
    2. Between the Orion and KPI nodes we need to insert a function node:

    1. Containing a remapping on a JSON containing a field called “value”:

    1. You can add a debug node to follow the KPI node to check that the entry is successful.

    1. If everything worked in the "DEBUG" tab, you must have a message similar to the following one that repeats the input data with the id that was given to it.
    2. It is also possible to see the data entered in the KPI Editor by pressing the "VALUES" button of the KPIs used.