{"info":{"_postman_id":"4d0c5bf7-9f5d-42aa-b11d-c8994b5bc26e","name":"FIWARE IoT Sensors","description":"<html><head></head><body><p>This tutorial is an introduction to IoT devices and the usage of the \n<a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> Protocol for \nconstrained devices. The tutorial introduces a series of dummy IoT devices  which are displayed within the browser and\nallows a user to interact with them. A complete understanding of all the terms and concepts defined in this\ntutorial is necessary before proceeding to connect the IoT devices to the Orion Context Broker via a real IoT Agent. </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>\"All our knowledge begins with the senses.\"</p>\n<p>— Immanuel Kant (Critique of Pure Reason)</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\ndevices which are able to connect to a network and exchange data. Each \"thing\"  or \"smart device\" is a gadget\nwith embedded electronics and sofware which can act as a sensor or actuator. Sensors are able to report the\nstate of the real-world around them. Actuators are responsible for altering the state of the system, by responding\nto 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,\nthe context is provided by the array of attached IoT devices. Since each IoT device is a physical object which\nexists in the real world, 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 IoT devices which will be used within this tutorial:</p>\n<ul>\n<li>A <strong>Smart Door</strong> is an electronic door which can be sent commands to be locked or unlocked remotely.\nIt can also report on its current state (<code>OPEN</code>, <code>CLOSED</code> or <code>LOCKED</code>), </li>\n<li>A <strong>Bell</strong> can be sent a command to activate and ring for a short period</li>\n<li>A <strong>Motion Sensor</strong> can be queried to return the number of people who have passed by since it was last reset</li>\n<li>A <strong>Smart Lamp</strong> can be switched on or off remotely. It can also report on its current state (<code>ON</code> or <code>OFF</code>).\nWhen switched on, a motion sensor within the device checks to see if light is is needed and will dim if no-one is nearby.\nFurthermore the device can be report on the current luminocity of the bulb.</li>\n</ul>\n<p>As you can see, the <strong>Bell</strong> is an example of a pure actuator, as it only reacts to the given commands. Meanwhile the \n<strong>Motion Sensor</strong> is an example of a pure sensor, since it will only report on the state of the world as it sees it.\nThe other two devices 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 in the diagram below:</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/entities.png\" alt=\"\"></p>\n<h1 id=\"what-is-ultralight-20\">What is Ultralight 2.0?</h1>\n<p><a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> is a lightweight text based protocol for constrained devices and communications where\nbandwidth and device memory resources are limited. The payload for measurement requests is\na 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. \nValues in Ultralight 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, \ndoes not specify a single transport protocol. Instead, different transport protocol bindings (such as  HTTP,\nMQTT and AMQP) can be used 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\nan IoT agent) are known as southbound traffic. Southbound traffic consists of <strong>commands</strong> made to \nactuator devices which alter the state of the real world by their actions. For example a command\nto alter the state of a lamp to <code>ON</code> would switch on the lamp in real life. This in turn could alter\nthe 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.\nThis ensures that the IoT Agent holds sufficient information to be able to contact each IoT device.\nIn other words it knows where to send commands and which commands are supported. In order to send a\ncommand to a device, the IoT Agent sends a POST request to the 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&gt;|&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 any 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 listening on this\nendpoint to perform the <code>turn</code> command. I have supplied the parameters <code>left</code> and <code>30</code> (degrees) as required for the device to be able to perform the manuever\"</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 Context Broker.\nThe 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, any response can always be associated to an entity\nheld 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, an alternative polling mechanism\ncan be used when all interactions are initiated from the device itself, but this is beyond 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 \nIoT agent) are known as northbound traffic. Northbound traffic consists of <strong>measurements</strong> made\nby sensor devices and relays the state of the real world into the context data of the system.\nFor example a measurement from a humidity sensor could be relayed back into the context broker\nto indicate that the moisture level of the entity has changed. A subscription could be made\nto be 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 the IoT Platform using an HTTP GET request to a \"well-known\" endpoint\n(the path <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=motion001&amp;d=c|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 <code>c</code> with\nthe 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 - \nthe key-value pairs of the measurement are passed as the body of the request. '<code>i</code> and <code>k</code> query parameters are\nstill mandatory:</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 the context broker.\nThe state of each device can be seen on the UltraLight device monitor web-page found at: <code>http://localhost:3000/device/monitor</code></p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/device-monitor.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\ndummy IoT devices. Every IoT device will be using the <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> protocol running over HTTP.\nSince all interactions are initiated by HTTP requests, the entities can be containerized and run from exposed ports. </p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors/img/architecture.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\">  context-provider:\n    image: fiware/cp-web-app:latest\n    hostname: context-provider\n    container_name: context-provider\n    networks:\n        - default\n    expose:\n        - \"3000\"\n        - \"3001\"\n    ports:\n        - \"3000:3000\"\n        - \"3001:3001\"\n    environment:\n        - \"DEBUG=proxy:*\"\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>context-provider</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\nwithout being part of the same network.</li>\n</ul>\n<p>The <code>context-provider</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>proxy:*</code></td>\n<td>Debug flag used for logging</td>\n</tr>\n<tr>\n<td>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 host name 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>context-provider</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 Orion Context Broker server is used for holding the context data of the smart solution. As you know all \ninteractions with the context broker must be made using <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a></li>\n<li>An IoT Agent acts as a middleware component converting <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a> \nrequests (from the context broker) into a protocol \n(such as <a href=\"http://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 comprehend how \nmessages are  passed through the system to subsequently understand the purpose of the IoT Agent\nmiddleware. In this tutorial you will be playing the role of an IoT Agent making commands to\ndevices 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 technology\nwhich 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 sevices can be brought up in a single \ncommmand. 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<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> to provide a\ncommand line functionality similar to a Linux distribution on Windows. </p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>All services can be initialised from the command line by running the bash script provided within the repository:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services create; ./services start;\n</code></pre>\n<p>This command will also import seed data from the previous <a href=\"https://github.com/Fiware/tutorials.Context-Providers\">Stock 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 the page to enable audio\nbefore you enter any cUrl commands. The device monitor displays the current state of an array of 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, \nmaking Southbound commands to the attached IoT devices and  receiving Northbound measurements\nas the environment changes within the store. All the commands are made as HTTP POST requests\nusing Ultralight syntax and therefore are very simple. It is worthwhile keeping an eye on the \ndevice monitor page as it shows all the Northbound traffic generated\nby 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":"4d0c5bf7-9f5d-42aa-b11d-c8994b5bc26e","publishedId":"RW84ts7D","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"4C4C4C","highlight":"45D3DD"},"publishDate":"2020-01-02T11:01:41.000Z"},"item":[{"name":"Bell Commands","item":[{"name":"Ring a bell","id":"e3fbe45b-4d73-41d4-818a-41c94f42a4d8","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Bell:001@ring"},"url":"localhost:3001/iot/bell001","description":"<p>This example shows how a real IoT Agent would send commands to an actuator. The <strong>Bell</strong> has supplied an endpoint\n<code>/iot/bell001</code> where it is listening for commands.</p>\n<p>The body of the request is in Ultralight syntax and consists of the <code>id</code> of the device (<code>urn:ngsi-ld:Bell:001</code>)\nas held in the Context Broker and the name of the command (<code>ring</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 bell change.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors//img/bell-ring.gif\" alt /></p>\n","urlObject":{"path":["iot","bell001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"e3fbe45b-4d73-41d4-818a-41c94f42a4d8"}],"id":"fea791c1-f652-4a07-a8a5-cd2535d0be62","description":"<p>A <strong>bell</strong> is an example of an actuator. It can respond to commands, but the device does not supply \nan measurements from the real world.</p>\n","event":[{"listen":"prerequest","script":{"id":"bc8f4f9a-ae81-400f-b1a4-8e48296614aa","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"aff17d91-f510-4436-af77-b0232b6f1d01","type":"text/javascript","exec":[""]}}],"_postman_id":"fea791c1-f652-4a07-a8a5-cd2535d0be62"},{"name":"Smart Lamp Commands","item":[{"name":"Switch on a Smart Lamp","id":"6b6cbc65-5c82-4903-ac6d-718f29ad0f64","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Lamp:001@on"},"url":"localhost:3001/iot/lamp001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Smart Lamp</strong> to switch it on.\nThe <strong>Smart Lamp</strong> has already supplied an endpoint <code>/iot/lamp001</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: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","lamp001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"6b6cbc65-5c82-4903-ac6d-718f29ad0f64"},{"name":"Switch off a Smart Lamp","id":"42708a3f-e6d8-4efc-8282-9649d7b17f3a","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Lamp:001@off"},"url":"localhost:3001/iot/lamp001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Smart Lamp</strong> to switch it off.\nThe <strong>Smart Lamp</strong> has already supplied an endpoint <code>/iot/lamp001</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:Lamp:001</code>)\nas held in the Context Broker and the name of the command (<code>off</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 off the luminocity level does not alter. The latest Ultralight measurement (<code>s|OFF|l|0</code>) as\nsent to the IoT Broker can be seen on the device monitor page.</p>\n","urlObject":{"path":["iot","lamp001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"42708a3f-e6d8-4efc-8282-9649d7b17f3a"}],"id":"3cce131f-6b20-493d-9f03-838888d55d8e","description":"<p>The <strong>Smart Lamp</strong> can be switched on and off remotely - it also registers luminocity.\nIt contains a motion sensor wtihin it and will slowly dim as time passes (provided \nno movement is detected)</p>\n<p>Measurements will be sent to the IoT Agent as the state and/or luminocity changes.</p>\n","event":[{"listen":"prerequest","script":{"id":"802c632d-fc4c-4cbe-998e-96a46a38d041","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"7d215fac-dcf6-4457-9a75-5713851d0764","type":"text/javascript","exec":[""]}}],"_postman_id":"3cce131f-6b20-493d-9f03-838888d55d8e"},{"name":"Smart Door Commands","item":[{"name":"Unlock a Door","id":"9b27f5a5-aaaf-4f1e-aec2-b79e8889124f","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Door:001@unlock"},"url":"localhost:3001/iot/door001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Smart Door</strong> to unlock 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>unlock</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 <strong>Smart Door</strong> is unlocked, it will automatically open and close as customers enter. The changes\nof state are actively reported to the IoT Broker, and the sate of the <strong>Smart Door</strong> can be seen on the\ndevice monitor page.</p>\n<p>The <strong>motion sensor</strong> within the store is not an actuator - it does not respond to commands, however\nit does actively measure the number of customers passing by. If the door is unlocked, the motion\nsensor will detect movement and send an Ultralight measurements back up to the IoT Broker.</p>\n<p>The Northbound HTTP requests generated by the <strong>motion sensor</strong>  can be also viewed on the device monitor page.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors//img/door-open.gif\" alt /></p>\n","urlObject":{"path":["iot","door001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"9b27f5a5-aaaf-4f1e-aec2-b79e8889124f"},{"name":"Open a Door","id":"3892cd0b-efef-4b9b-ada2-6f8d7557c457","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":"3892cd0b-efef-4b9b-ada2-6f8d7557c457"},{"name":"Close a Door","id":"45dcedaa-4ec1-417f-a248-b169c3748d58","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Door:001@close"},"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 close 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>close</code>) to invoke on the device.</p>\n<p>The response returns the command and the result of the action.</p>\n<p>Since the door is currently unlocked, customers can still enter, and re-open the door themselves.\nIf motion is detected, the <strong>motion sensor</strong> will 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":"45dcedaa-4ec1-417f-a248-b169c3748d58"},{"name":"Lock a Door","id":"da07cb16-7fd4-4401-b836-f70e4b47e0dd","request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"urn:ngsi-ld:Door:001@lock"},"url":"localhost:3001/iot/door001","description":"<p>This example shows how a real IoT Agent would send an Ultralight command to a <strong>Smart Door</strong> to lock 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>lock</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 door is locked, no further customers may enter. The <strong>Motion Sensor</strong> will report no\nfurther movement detected, the door cannot be opened manually and the <strong>Smart Lamp</strong> will\nslowly return to the ambient lighting level.</p>\n<p>The Northbound HTTP requests generated by the <strong>Smart Lamp</strong> can be viewed on the device monitor page.</p>\n<p><img src=\"https://fiware.github.io/tutorials.IoT-Sensors//img/door-lock.gif\" alt /></p>\n","urlObject":{"path":["iot","door001"],"host":["localhost:3001"],"query":[],"variable":[]}},"response":[],"_postman_id":"da07cb16-7fd4-4401-b836-f70e4b47e0dd"}],"id":"99ce65e9-7745-43c4-9f06-ff1ea99ffd82","description":"<p>A <strong>Smart Door</strong> is an electronic door which can be sent commands to be locked or unlocked remotely.\nIt can also report on its current state (<code>OPEN</code>, <code>CLOSED</code> or <code>LOCKED</code>),</p>\n<p>Measurements will be sent to the IoT Agent as the state changes.</p>\n","event":[{"listen":"prerequest","script":{"id":"9440e43e-b668-4012-9b00-b67cfa285688","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"8d00da62-cf31-492b-9e79-13a8482e691c","type":"text/javascript","exec":[""]}}],"_postman_id":"99ce65e9-7745-43c4-9f06-ff1ea99ffd82"},{"name":"Motion Sensor - Measurement","id":"ddadb98a-f08a-4021-bad1-b77f8f04ed9c","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=motion001","description":"<p>This example simulates a request coming from the device <code>motion001</code></p>\n<p>The request to the previously provisioned resource <code>iot/d</code> is in UltraLight 2.0 format\nand identifies the device <code>motion001</code> and passes a known API key.</p>\n<p>A similar request was made in the previous tutorial (before the IoT Agent was connected)\nwhen the door was unlocked, you will have seen the state of each motion sensor changing\nand a Northbound request will be logged in the device monitor.</p>\n","urlObject":{"protocol":"http","path":["iot","d"],"host":["localhost:7896"],"query":[{"key":"k","value":"4jggokgpepnvsb2uv4s40d59ov"},{"key":"i","value":"motion001"}],"variable":[]}},"response":[],"_postman_id":"ddadb98a-f08a-4021-bad1-b77f8f04ed9c"}],"event":[{"listen":"prerequest","script":{"id":"a0054544-01fb-4022-abd3-00a1125d9bca","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d5080300-3a8f-4e79-9cb0-3109d21f78df","type":"text/javascript","exec":[""]}}],"variable":[{"key":"ultralight","value":"localhost:3001"},{"key":"iot-agent-southport","value":"localhost:7896","type":"string"}]}