Sensor simulation agent

sensor sim flow

This project is designed for testing purposes of FIWARE Orion broker and other services and implementations available on FIWAREbox product. Example is meant to work in correlation with Graphical user interface available at: https://fiwarebox-node-red.<cloud_instance>.sandbox.engineering/fiwarebox/sensor_sim.html for cloud, or http://<sandbox_ip>:50015/fiwarebox/sensor_sim.html for Hardware version of FIWAREbox.

Project is controlled by the user through GUI. Main communication between Node-RED script and Front end is websocket connection. Example is configurable to work with both FIWARE’s Orion and Orion linked data brokers. Among functionalities are: display broker version, existing entites and subscriptions (with or without query parameter). Create, simulate and delete entities. Create and delete subscriptions.

Services Used

  • FIWARE Orion – Context broker

  • FIWARE Orion Linked data – Context broker

For details, see Node-RED Documentation

List of used nodes

  • Inject/Timestamp – Triggers flow execution

  • Function – Adds custom logic using JavaScript

  • HTTP Request – Sends HTTP requests to external services

  • Debug – Displays messages in the debug console

  • Switch – Routes messages based on conditions

  • JSON – Converts data between JSON and object format

  • Change - Reasigns value to another attribute of msg object

For more information consult official Node-REDs documentation: (TODO: add link to docs)

GROUP: websocket handler

group websocket handler

FLOW: incoming messages

Listening to incoming websocket messages.

FLOW: output messages

Sending output websocket messages.

For more information about configuring Websocket communication in Node-RED: (provide reference to configuring websocket communication in node-red)

GROUP: developer settings

developer settings in GUI
developer settings in GUI

Purpose of this group is to handle developer settings messages from front end. Switch node is implemented to direct messages to correct flows based on msg.flag property.

FLOW: set global variables for Orion instance and Orion broker url

Purpose of this flow is to set broker instance (Orion or Orion-LD) and Orion URL. This is achived through the use of variables set in flows context using flow.set and get. Information is sent back to front end with ws connection.

FLOW: return orion instance data

Flow is used to return orion instance data to front end acquired through flow context with flow.get() method. Data message is sent through websocket connection.

FLOW: ping pong message

For sending back and forth messages with front end, to keep ws connection alive.

GROUP: ws switch

developer settings in GUI

Group is used to handle incoming ws messages and direct them to correct flows based on msg.flag attribute with the use of switch node.

GROUP: switch based on orion instance

group switch based on orion instance

Group is used to direct metadata messages forward based on flow set orion instance, this is done through switch node, which acquires orion instance through flow.get() method. In case no instance is selected error message is returned to front-end. This group is through the use of link nodes connected to return metadata group. Based on the result of this group different actions from return metadata group are used.

GROUP: return metadata

developer settings in GUI

Group is used to handle metadata returns, entity and subscriptions queries for both versions of Orion broker. Input to this group is fed from the previous group named switch based on orion instance. for Both sub groups switch node is implemented which redirects message based on payload value.

FLOW: get Orion version

Demonstrates how to get Orion context broker version using RESTful API call and then return this value to front end for display in user interface.

FLOW: get Orion entities

Demonstrates how to get Orion context broker entities using RESTful API call, entities can be filtered using query parameter which is sent from the front end. Acquired value is returned to front end for display in tables

FLOW: get Orion subscriptions

Demonstrates how to get Orion context broker subscriptions using RESTful API call, subscriptions can be filtered using query parameter which is sent from the front end. Acquired value is returned to front end for display in tables

FLOW: get Orion-LD version

Demonstrates how to get Orion-LD context broker version using RESTful API call and then return this value to front end for display in user interface.

FLOW: get Orion-LD entities

Demonstrates how to get Orion-LD context broker entities using RESTful API call, entities can be filtered using query parameter which is sent from the front end. Acquired value is returned to front end for display in tables

FLOW: get Orion-LD subscriptions

Demonstrates how to get Orion-LD context broker subscriptions using RESTful API call, subscriptions can be filtered using query parameter which is sent from the front end. Acquired value is returned to front end for display in tables

GROUP: Orion entities

developer settings in GUI

Group consists of 2 flows. One flow is used to simply just create Orion entity, other one creates entity and saves information about entity for simulation purposes.

FLOW: create Orion entity

Message from front end already has viable structure to be body of HTTP POST request for entity creation in Orion context broker. Only flag attribute and HTTP request headers are reasigned to another property.

FLOW: create Orion entity with simulation

Payload of message from front end holds structure of entity to be created. Random values for entity attributes are generated based on passed limits. HTTP request for creating entity is made.

Entity data is sent forward to GROUP: Orion entity value updates for further processing.