{"info":{"_postman_id":"a0361f79-2e44-4465-bdb2-80e2a0aac0e0","name":"NGSI-LD IoT Sensors","description":"<html><head></head><body><p>This tutorial is an introduction to IoT devices and the usage of the\n<a href=\"https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a>\nProtocol for constrained devices. The tutorial introduces a series of dummy agricultural IoT devices which are displayed\nwithin the browser and allows a user to interact with them. A complete understanding of all the terms and concepts\ndefined in this tutorial is necessary before proceeding to connect the IoT devices to an NGSI-LD context broker via a\nreal IoT Agent.</p>\n<p>The tutorial uses <a href=\"https://ec.haxx.se/\">cUrl</a> commands throughout, but is also available as\n<a href=\"https://fiware.github.io/tutorials.IoT-Sensors/\">Postman documentation</a></p>\n<p>The <code>docker-compose</code> files for this tutorial can be found on GitHub: </p>\n<p><img src=\"https://fiware.github.io/tutorials.Historic-Context/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/Fiware/tutorials.IoT-Sensors\">FIWARE 201: Introduction to IoT Sensors</a></p>\n<h1 id=\"what-are-iot-devices\">What are IoT devices?</h1>\n<blockquote>\n<p>\"A farm is a manipulative creature. There is no such thing as finished. Work comes in a stream and has no end. There\nare only the things that must be done now and things that can be done later..\"</p>\n<p>— Kristin Kimball, The Dirty Life: On Farming, Food, and Love</p>\n</blockquote>\n<p>The <a href=\"https://www.linux.com/news/who-needs-internet-things\">Internet of Things</a> (IoT) is a network of physical devices\nwhich are able to connect to a network and exchange data. Each \"thing\" or \"smart device\" is a gadget with embedded\nelectronics and software which can act as a sensor or actuator. Sensors are able to report the state of the real-world\naround them. Actuators are responsible for altering the state of the system, by responding to a control signal.</p>\n<p>Each device is uniquely identifiable through its embedded computing system but is able to inter-operate within the\nexisting internet infrastructure.</p>\n<p>FIWARE is a system for managing context information. For a smart solution based on the internet of Things, the context\nis provided by the array of attached IoT devices. Since each IoT device is a physical object which exists in the real\nworld, it will eventually be represented as a unique entity within the context.</p>\n<p>IoT devices can range from simple to complex. Here are some examples of agricultural IoT devices which will be used\nwithin this tutorial:</p>\n<ul>\n<li>A <strong>Soil Sensor</strong> can report on the amount of moisture in the ground</li>\n<li>A <strong>Temperature Sensor</strong> can be queried to return current air or soil temperature</li>\n<li>A <strong>Filling Sensor</strong> can report the amount of feed left in a silo</li>\n<li>An <strong>Irrigation System</strong> can be sent a command to activate and turn on for a short period</li>\n<li><strong>Animal Collars</strong> can be used to track the location, health and stress-levels of livestock</li>\n<li><strong>Farm Management Information Systems</strong> placed in agricultural machinery can be used send and receive instructions\nto labourers, track the state of tasks and follow the progress of them.</li>\n</ul>\n<p>As you can see, the <strong>Irrigation System</strong> is an example of a pure actuator, as it only reacts to the given commands.\nMeanwhile the <strong>Soil Sensor</strong> is an example of a pure sensor, since it will only report on the state of the world as it\nsees it. Some devices such as an <strong>FMIS</strong> are able to both respond to commands and report on state in a meaningful way.</p>\n<p>The state information held within each device, as it will eventually be seen within the Context Broker is defined in the\ndiagram below:</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/entities-ld.png\" alt=\"\"></p>\n<h1 id=\"what-is-ultralight-20\">What is Ultralight 2.0?</h1>\n<p><a href=\"https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> is a\nlightweight text based protocol for constrained devices and communications where bandwidth and device memory resources\nare limited. The payload for measurement requests is a list of key-value pairs separated by the pipe <code>|</code> character.</p>\n<p>e.g.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;key&gt;|&lt;value&gt;|&lt;key&gt;|&lt;value&gt;|&lt;key&gt;|&lt;value&gt; etc..\n</code></pre><p>For example a payload such as:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>t|15|k|abc\n</code></pre><p>Contains two attributes, one named \"t\" with value \"15\" and another named \"k\" with value \"abc\" are transmitted. Values in\nUltralight 2.0 are not typed (everything is treated as a string).</p>\n<p>Ultralight 2.0 defines a payload describing measures and commands to share between devices and servers but, does not\nspecify a single transport protocol. Instead, different transport protocol bindings (such as HTTP, MQTT and AMQP) can be\nused for different scenarios. For this tutorial we will be using HTTP as a transport protocol.</p>\n<h2 id=\"southbound-traffic-commands\">Southbound Traffic (Commands)</h2>\n<p>HTTP requests generated by the from the Context Broker and passed downwards towards an IoT device (via an IoT agent) are\nknown as southbound traffic. Southbound traffic consists of <strong>commands</strong> made to actuator devices which alter the state\nof the real world by their actions. For example a command to alter the state of a lamp to <code>ON</code> would switch on the lamp\nin real life. This in turn could alter the readings of other sensors nearby.</p>\n<h3 id=\"push-command-using-http-post\">Push Command using HTTP POST</h3>\n<p>Setting up the southbound communication between an IoT Agent and IoT devices is known as provisioning. This ensures that\nthe IoT Agent holds sufficient information to be able to contact each IoT device. In other words it knows where to send\ncommands and which commands are supported. In order to send a command to a device, the IoT Agent sends a POST request to\nthe endpoint supplied by the device. The body of the POST request holds the command.</p>\n<p>The payload for Ultralight commands has the following format:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;device name&gt;@&lt;command&gt;|&lt;param|&lt;param&gt;\n</code></pre><p>Where <code>&lt;device_name&gt;</code> is the entity <code>id</code> as held in the context broker, <code>&lt;command&gt;</code> is one of the supported commands and\nany additional required values are passed in subsequent parameters for example</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>urn:ngsi-ld:Robot:001@turn|left|30\n</code></pre><p>Will tell a device <em>\"I am known as <code>id=\"urn:ngsi-ld:Robot:001\"</code> within the Context Broker. I would like the device\nlistening on this endpoint to perform the <code>turn</code> command. I have supplied the parameters <code>left</code> and '<code>30</code> (degrees) as\nrequired for the device to be able to perform the maneuver\"</em>.</p>\n<p>The defined Northbound response to an IoT Agent is as follows:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>urn:ngsi-ld:Robot:001@turn|Turn ok\n</code></pre><p>Which is saying <em>\"I have complied with a request from the entity known as <code>id=\"urn:ngsi-ld:Robot:001\"</code> within the\nContext Broker. The command I have performed was a <code>turn</code> command. The result was <code>Turn ok</code>\"</em>.</p>\n<p>As you can see, because the Southbound command defines the <code>id</code> used within the interaction, and the same data is also\nreturned, every response can always be associated to the appropriate entity held within the Context Broker.</p>\n<p>Push commands can only be used if the device is able to supply a separate endpoint for listening to southbound traffic,\nan alternative polling mechanism can be used when all interactions are initiated from the device itself, but this is\nbeyond the scope of this tutorial.</p>\n<h2 id=\"northbound-traffic-measurements\">Northbound Traffic (Measurements)</h2>\n<p>Requests generated from an IoT device and passed back upwards towards the Context Broker (via an IoT agent) are known as\nnorthbound traffic. Northbound traffic consists of <strong>measurements</strong> made by sensor devices and relays the state of the\nreal world into the context data of the system. For example a measurement from a humidity sensor could be relayed back\ninto the context broker to indicate that the moisture level of the entity has changed. A subscription could be made to\nbe informed of such changes and there provoke further actions (such as turning on a sprinkler)</p>\n<h3 id=\"measurement-using-http-get\">Measurement using HTTP GET</h3>\n<p>A device can report new measures to an IoT Agent using an HTTP GET request to a \"well-known\" endpoint (the path\n<code>/iot/d</code>) along with the following query parameters:</p>\n<ul>\n<li><code>i</code> (device ID): Device ID (unique for the API Key).</li>\n<li><code>k</code> (API Key): API Key for the service the device is registered on.</li>\n<li><code>t</code> (timestamp): Timestamp of the measure. Will override the automatic IoTAgent timestamp (optional).</li>\n<li><code>d</code> (Data): Ultralight 2.0 payload.</li>\n</ul>\n<p>The <code>i</code> and <code>k</code> parameters are mandatory.</p>\n<p>For example the request:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>&lt;iot-agent&gt;/iot/d?i=humidity001&amp;d=h|12\n</code></pre><p>Would indicate that the device <code>id=motion001</code> wishes to inform the IoT Agent that is has made a real-world measurement\n<code>h</code> with the value <code>12</code>. This would eventually be passed up into the Context Broker.</p>\n<h3 id=\"measurement-using-http-post\">Measurement using HTTP POST</h3>\n<p>HTTP POST can also be used. Again the path will be <code>/iot/d</code>, but in this case, <code>d</code> (Data) is not necessary - the\nkey-value pairs of the measurement are passed as the body of the request. <code>i</code> and <code>k</code> query parameters are still\nmandatory:</p>\n<ul>\n<li><code>i</code> (device ID): Device ID (unique for the API Key).</li>\n<li><code>k</code> (API Key): API Key for the service the device is registered on.</li>\n<li><code>t</code> (timestamp): Timestamp of the measure. Will override the automatic IoTAgent timestamp (optional).</li>\n</ul>\n<p>Once again the <code>i</code> and <code>k</code> parameters are mandatory.</p>\n<h4 id=\"device-monitor\">Device Monitor</h4>\n<p>For the purpose of this tutorial, a series of dummy IoT devices have been created, which will eventually be attached to\nthe context broker. The state of each device can be seen on the UltraLight device monitor web page found at:\n<code>http://localhost:3000/device/monitor</code></p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/farm-devices.png\" alt=\"FIWARE Monitor\"></p>\n<h1 id=\"architecture\">Architecture</h1>\n<p>The demo application will only make use of a single custom component acting as a set of dummy IoT devices. Every IoT\ndevice will be using the\n<a href=\"https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a>\nprotocol running over HTTP. Since all interactions are initiated by HTTP requests, the entities can be containerized and\nrun from exposed ports.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/architecture-ld.png\" alt=\"\"></p>\n<p>The necessary configuration information can be seen in the services section of the associated <code>docker-compose.yml</code> file:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">tutorial:\n    image: fiware/tutorials.ngsi-ld\n    hostname: iot-sensors\n    container_name: fiware-tutorial\n    networks:\n        - default\n    expose:\n        - \"3000\"\n        - \"3001\"\n    ports:\n        - \"3000:3000\"\n        - \"3001:3001\"\n    environment:\n        - \"DEBUG=tutorial:*\"\n        - \"PORT=3000\"\n        - \"IOTA_HTTP_HOST=iot-agent\"\n        - \"IOTA_HTTP_PORT=7896\"\n        - \"DUMMY_DEVICES_PORT=3001\" # Port used by the dummy IOT devices to receive commands\n        - \"DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov\"\n</code></pre>\n<p>The <code>tutorial</code> container is listening on two ports:</p>\n<ul>\n<li>Port <code>3000</code> is exposed so we can see the web page displaying the Dummy IoT devices.</li>\n<li>Port <code>3001</code> is exposed purely for tutorial access - so that cUrl or Postman can make UltraLight commands without\nbeing part of the same network.</li>\n</ul>\n<p>The <code>tutorial</code> container is driven by environment variables as shown:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>DEBUG</td>\n<td><code>tutorial:*</code></td>\n<td>Debug flag used for logging</td>\n</tr>\n<tr>\n<td>WEB_APP_PORT</td>\n<td><code>3000</code></td>\n<td>Port used by web-app which displays the dummy device data</td>\n</tr>\n<tr>\n<td>IOTA_HTTP_HOST</td>\n<td><code>iot-agent</code></td>\n<td>The hostname of the missing IoT Agent - used in a later tutorial</td>\n</tr>\n<tr>\n<td>IOTA_HTTP_PORT</td>\n<td><code>7896</code></td>\n<td>The port that the missing IoT Agent will be listening on. <code>7896</code> is a common default for UltraLight over HTTP</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_PORT</td>\n<td><code>3001</code></td>\n<td>Port used by the dummy IoT devices to receive commands</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_API_KEY</td>\n<td><code>4jggokgpepnvsb2uv4s40d59ov</code></td>\n<td>Random security key used for UltraLight interactions - this will be used in a later tutorial to ensure the integrity of interactions between the devices and the missing IoT Agent</td>\n</tr>\n</tbody>\n</table>\n</div><p>The other <code>tutorial</code> container configuration values described in the YAML file are not used in this tutorial.</p>\n<p>When describing the messages being passed through a working smart solution we will refer to two further components which\nare not used in this tutorial, but will be needed to complete the system subsequently.</p>\n<ul>\n<li>The <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a> is used for holding the context data of\nthe smart solution. As you know all interactions with the context broker must be made using\n<a href=\"https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/spec/updated/full_api.json\">NGSI-LD</a></li>\n<li>An IoT Agent acts as a middleware component converting\n<a href=\"https://forge.etsi.org/swagger/ui/?url=https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/raw/master/spec/updated/full_api.json\">NGSI-LD</a>\nrequests (from the context broker) into a protocol (such as\n<a href=\"https://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a>)\nusable by the IoT devices themselves.</li>\n</ul>\n<p>It is therefore necessary to understand a sample device protocol first, and fully comprehend how messages are passed\nthrough the system to subsequently understand the purpose of the IoT Agent middleware. In this tutorial you will be\nplaying the role of an IoT Agent making commands to devices and receiving measurements from them.</p>\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker\">Docker</h2>\n<p>To keep things simple all components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a container\ntechnology which allows to different components isolated into their respective environments.</p>\n<ul>\n<li>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></li>\n<li>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></li>\n<li>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></li>\n</ul>\n<p><strong>Docker Compose</strong> is a tool for defining and running multi-container Docker applications. A\n<a href=\"https://raw.githubusercontent.com/Fiware/tutorials.Entity-Relationships/master/docker-compose.yml\">YAML file</a> is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and Docker for Mac, however Linux users\nwill need to follow the instructions found <a href=\"https://docs.docker.com/compose/install/\">here</a></p>\n<p>You can check your current <strong>Docker</strong> and <strong>Docker Compose</strong> versions using the following commands:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker-compose -v\ndocker version\n</code></pre>\n<p>Please ensure that you are using Docker version 18.03 or higher and Docker Compose 1.21 or higher and upgrade if\nnecessary.</p>\n<h2 id=\"cygwin\">Cygwin</h2>\n<p>We will start up our services using a simple bash script. Windows users should download <a href=\"http://www.cygwin.com/\">cygwin</a>\nto provide a command-line functionality similar to a Linux distribution on Windows.</p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>All services can be initialized from the command-line by running the bash script provided within the repository. Please\nclone the repository and create the necessary images by running the commands as shown:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">git clone https://github.com/FIWARE/tutorials.IoT-Sensors.git\ncd tutorials.IoT-Sensors\ngit checkout NGSI-LD\n\n./services start;\n</code></pre>\n<p>This command will also import seed data from the previous\n<a href=\"https://github.com/FIWARE/tutorials.Context-Providers\">Farm Management example</a> on startup.</p>\n<blockquote>\n<p>:information_source: <strong>Note:</strong> If you want to clean up and start over again you can do so with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services stop\n</code></pre>\n</blockquote>\n<h1 id=\"communicating-with-iot-devices\">Communicating with IoT Devices</h1>\n<p>To follow the tutorial correctly please ensure you have the device monitor page available in your browser and click on\nthe page to enable audio before you enter any cUrl commands. The device monitor displays the current state of an array\nof dummy devices using Ultralight 2.0 syntax</p>\n<h4 id=\"device-monitor-1\">Device Monitor</h4>\n<p>The device monitor can be found at: <code>http://localhost:3000/device/monitor</code></p>\n<p>Within this tutorial you will be playing the role of the missing IoT Agent component, making Southbound commands to the\nattached IoT devices and receiving Northbound measurements as the environment changes within the store. All the commands\nare made as HTTP POST requests using Ultralight syntax and therefore are very simple. It is worthwhile keeping an eye on\nthe device monitor page as it shows all the Northbound traffic generated by the devices themselves.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"What are IoT devices?","slug":"what-are-iot-devices"},{"content":"What is Ultralight 2.0?","slug":"what-is-ultralight-20"},{"content":"Architecture","slug":"architecture"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Start Up","slug":"start-up"},{"content":"Communicating with IoT Devices","slug":"communicating-with-iot-devices"}],"owner":"513743","collectionId":"a0361f79-2e44-4465-bdb2-80e2a0aac0e0","publishedId":"TVK76LPh","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"5DC0CF"},"publishDate":"2020-09-14T11:01:56.000Z"},"item":[{"name":"Irrigation System Commands","item":[{"name":"Turn on the Irrigation System","id":"cfa10837-85a8-44cf-b1bc-e5a9e2905a8a","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Device:water001@on"},"url":"localhost:3001/iot/water001","description":"<p>The body of the request is in Ultralight syntax and consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Device:water001</code>)\nas held in the Context Broker and the name of the command (<code>on</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>If you are viewing the device monitor page, you can see the state of the water sprinkler change.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/water-on.png\" alt /></p>\n","urlObject":{"path":["iot","water001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"cfa10837-85a8-44cf-b1bc-e5a9e2905a8a"},{"name":"Turn off the Irrigation System","id":"33979914-cc4e-4438-a878-b66147bb78e0","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Device:water001@off"},"url":"localhost:3001/iot/water001","description":"<p>This example shows how to turn off the  irrigation system. In this case, the device is also listening for multiple commands off a single endpoint and interpreting the payload body.</p>\n","urlObject":{"path":["iot","water001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"33979914-cc4e-4438-a878-b66147bb78e0"}],"id":"b1c71b15-3bb7-430d-a062-1c5fdbedcb3c","description":"<p>An <strong>Irrigation System</strong> water sprinkler is an example of an actuator. It can respond to commands, but the device does\nnot supply any measurements from the real world.</p>\n","event":[{"listen":"prerequest","script":{"id":"d856a054-7166-4e9a-b2fd-16ffb3199be8","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"98833aee-4d64-4a0f-ba2c-85403ac36649","type":"text/javascript","exec":[""]}}],"_postman_id":"b1c71b15-3bb7-430d-a062-1c5fdbedcb3c"},{"name":"Tractor Commands","item":[{"name":"Send an order to start the tractor","id":"f3c041aa-0d82-464f-97ac-86aede8f9ed8","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Device:tractor001@start"},"url":"localhost:3001/iot/tractor001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Tractor</strong> FMIS to move it from an idle\nto an active state. The unit with the <strong>Tractor</strong> itself has already supplied an endpoint <code>/iot/tractor001</code> where it is\nlistening for commands.</p>\n<p>The body of the request consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Device:tractor001</code>) as held in the Context\nBroker and the name of the command (<code>start</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>Once the tractor is activated,  the location and activity of the tractor will alter dependent upon whether the internal GPS\ndetects movement. The measurement is actively reported and requests to the IoT Broker can be seen on the device monitor\npage.</p>\n<p>The body of the request consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Lamp:001</code>)\nas held in the Context Broker and the name of the command (<code>on</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>Once the lamp is switched the luminocity level will alter dependent upon whether the internal\nmotion sensor detects movement. The measurement is actively reported and requests to the\nIoT Broker can be seen on the device monitor page.</p>\n","urlObject":{"path":["iot","tractor001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"f3c041aa-0d82-464f-97ac-86aede8f9ed8"},{"name":"Send an order to stop the tractor","id":"8f093565-5ef0-4280-a6a4-5f4628e3037f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Device:tractor001@stop"},"url":"localhost:3001/iot/tractor001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Tractor</strong> FMIS to return the vehicle to\nan idle state. The <strong>Tractor</strong> has already supplied an endpoint <code>/iot/tractor001</code> where it is listening for commands.</p>\n<p>The body of the request consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Device:tractor001</code>) as held in the Context\nBroker and the name of the command (<code>stop</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n","urlObject":{"path":["iot","tractor001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"8f093565-5ef0-4280-a6a4-5f4628e3037f"}],"id":"5796042d-3de7-4afa-b95d-07abfcd8f874","description":"<p>An <strong>FMIS System</strong> on the dashboard of a tractor is an example of a combined actuator and sensor.</p>\n","event":[{"listen":"prerequest","script":{"id":"9005f80d-3aed-4c31-8d1c-552d4c0f91b2","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d87ab942-53eb-48d2-8d4b-0c2a115cdd47","type":"text/javascript","exec":[""]}}],"_postman_id":"5796042d-3de7-4afa-b95d-07abfcd8f874"},{"name":"Filling Station Commands","item":[{"name":"Remove hay from the barn","id":"adceee10-6f43-4b14-912e-a6d9e4dadc77","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Device:filling001@remove"},"url":"localhost:3001/iot/filling001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Filling Station</strong> to unload the barn. The\n<strong>Filling Station</strong> has already supplied an endpoint <code>/iot/filling001</code> where it is listening for commands.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>Once the command is sent, some time will pass and the level of the filling station will change. The changes of state are\nactively reported to the IoT Broker when they occur, and the updated state of the <strong>FillingStation</strong> can be seen on the\ndevice monitor page.</p>\n<p>The body of the request consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Device:filling001</code>) as held in the Context\nBroker and the name of the command (<code>remove</code>) to invoke on the device.</p>\n","urlObject":{"path":["iot","filling001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"adceee10-6f43-4b14-912e-a6d9e4dadc77"},{"name":"Add hay to the barn","id":"90976240-04b8-4d7c-9aa8-59687b4ca96b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Door:001@open"},"url":"localhost:3001/iot/door001","description":"<p>This example shows how a real IoT Agent would send a command to a <strong>Smart Door</strong> to open the door.\nThe <strong>Smart Door</strong> has already supplied an endpoint <code>/iot/door001</code> where it is listening for commands.</p>\n<p>The body of the request consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Door:001</code>)\nas held in the Context Broker and the name of the command (<code>open</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>The state of the <strong>Smart Door</strong> can be seen on the device monitor page. Customers may now enter and\nthe <strong>motion sensor</strong> may pick up movement and send measurements to the IoT Broker.</p>\n<p>The Northbound HTTP requests generated by the <strong>motion sensor</strong> can also be viewed on the device monitor page.</p>\n","urlObject":{"path":["iot","door001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"90976240-04b8-4d7c-9aa8-59687b4ca96b"}],"id":"44e2c0a6-932c-4b69-904b-ab5b2b2e4771","description":"<p>The <strong>Filling Station</strong> is an electronic device which can be sent a command to request that feed is added or removed\nfrom the silo. It can also report on its load level. In reality such a device would be connected to the FMIS to request\nthat a worker fills the silo when it gets too low, but in this case we are treating the device as both a sensor and and\nactuator.</p>\n<p>Measurements will be sent to the IoT Agent as the state changes.</p>\n","event":[{"listen":"prerequest","script":{"id":"759642ba-f5ab-471f-8d17-c9bc837c85a5","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"0f7159a3-07fe-45fa-a9ea-e07e379bf400","type":"text/javascript","exec":[""]}}],"_postman_id":"44e2c0a6-932c-4b69-904b-ab5b2b2e4771"},{"name":"Sending Measures","item":[{"name":"Humidity Sensor - Measurement","id":"b54db858-36f1-4b85-b624-bfff9911099b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"text/plain"}],"body":{"mode":"raw","raw":"c|1"},"url":"http://localhost:7896/iot/d?k=4jggokgpepnvsb2uv4s40d59ov&i=humidity001","description":"<p>This example simulates a request coming from the device <code>humidity001</code></p>\n<p>The request to the previously provisioned resource <code>iot/d</code> is in UltraLight 2.0 format and identifies the device\n<code>humidity</code> and passes a known API key.</p>\n<p>The example as written won't work unless the IoT Agent exists and is listening on the appropriate endpoint (<code>/iot/d</code>) to\nprocess the measure. However this measure is the class of request generated by all Ultralight 2.0. sensors.</p>\n","urlObject":{"protocol":"http","path":["iot","d"],"host":["localhost:7896"],"query":[{"key":"k","value":"4jggokgpepnvsb2uv4s40d59ov"},{"key":"i","value":"humidity001"}],"variable":[]}},"response":[],"_postman_id":"b54db858-36f1-4b85-b624-bfff9911099b"}],"id":"bf074217-9349-4cb1-bcc7-17e9aa7110a5","description":"<p>The <strong>SoilSensor</strong>, <strong>AnimalCollars</strong> and <strong>TemperatureSensors</strong> found on the farm are not actuators since they do not\nrespond to commands, however they does actively monitor and measures the state of things in the real world. If any of\nthe other commands have been sent, the various dummy sensors will also start to respond.</p>\n<p>The Northbound HTTP requests generated by the sensors can be also viewed on the device monitor page.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/device-measures.png\" alt /></p>\n","_postman_id":"bf074217-9349-4cb1-bcc7-17e9aa7110a5"}],"event":[{"listen":"prerequest","script":{"id":"5166080f-3e24-4cfb-b0e6-44808dfdb246","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a3643edc-c623-41b8-94b8-beeda0882dd5","type":"text/javascript","exec":[""]}}],"variable":[{"key":"ultralight","value":"localhost:3001"},{"key":"iot-agent-southport","value":"localhost:7896"}]}