SlideShare a Scribd company logo
IoT in the FIWARE Platform - 2:
Context Information Management in IoT-enabled Smart Systems:
The basics
Fernando López Aguilar
FIWARE Cloud and Platform Senior Expert
fernando.lopez@fiware.org
@flopezaguilar
• Orion Context Broker
• Creating and pulling data
• Pushing data and notifications
• Batch operations
• STH - Comet
2
Outline
Orion Context Broker
3
Orion Context Broker
• Main functions:
– Context management
– Context availability management (advanced topic)
• HTTP and REST-based
– JSON payload support
• Context in NGSI is based in an entity-attribute model:
Attributes
• Name
• Type
• Value
Entity
• EntityId
• EntityType
1 n
“has”
4
Orion Context Broker in a nutshell
Orion Context Broker
Context
Producers
Context
Consumers
subscriptions
update
query
notify
notify
update
update
DB
1026
1026
5
GET <cb_host>:1026/version
{
"orion" : {
"version" : "1.6.0",
"uptime" : "7 d, 21 h, 33 m, 39 s",
"git_hash" : "aee96414cc3594bba161afb400f69d101978b39c",
"compile_time" : "Mon Dec 5 08:38:58 CET 2016",
"compiled_by" : "fermin",
"compiled_in" : "centollo"
}
}
6
Orion Context Broker – check health
Two “flavours” of NGSI API
• NGSIv1
– Original NGSI RESTful binding of OMA-NGSI
– Implemented in 2013
– Uses the /v1 prefix in resource URL
• NGSIv2
– A revamped, simplified binding of OMA-NGSI
– Enhanced functionality compared with NGSIv1 (eg. filtering)
– Stable, ready for production, version already available
• Current NGSIv2 version is Release Candidate 2016.10
http://telefonicaid.github.io/fiware-orion/api/v2/stable
• New features coming (http://telefonicaid.github.io/fiware-orion/api/v2/stable)
– Uses the /v2 prefix in resource URL
• Introduction to NGSIv2
– https://docs.google.com/presentation/d/1_fv9dB5joCsOCHlb4Ld6A-
QmeIYhDzHgFHUWreGmvKU/edit#slide=id.g53c31d7074fd7bc7_0
7
Orion Context Broker Basic Operations
Entities
• GET /v2/entities
• Retrieve all entities
• POST /v2/entities
• Creates an entity
• GET /v2/entities/{entityID}
• Retrieves an entity
• [PUT|PATCH|POST] /v2/entities/{entityID}
• Updates an entity (different “flavours”)
• DELETE /v2/entities/{entityID}
• Deletes an entity
8
Orion Context Broker Basic Operations
Attributes
• GET /v2/entities/{entityID}/attrs/{attrName}
• Retrieves an attribute’s data
• PUT /v2/entities/{entityID}/attrs/{attrName}
• Updates an attribute’s data
• DELETE /v2/entities/{entityID}/attrs/{attrName}
• Deletes an attribute
• GET /v2/entities/{entityID}/attrs/{attrName}/value
• Retrieves an attribute’s value
• PUT /v2/entities/{entityID}/attrs/{attrName}/value
• Updates an attribute’s value
9
Create & Pull data
10
Context Broker operations: create & pull data
• Context Producers publish data/context elements by invoking the update
operations on a Context Broker.
• Context Consumers can retrieve data/context elements by invoking the query
operations on a Context Broker
Context
Consumer
query
Context
Producer
update
Context
Broker
11
Quick Usage Example: Car Create
201 Created
12
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Car1",
"type": "Car",
"speed": {
"type": "Float",
"value": 98
}
}
Quick Usage Example: Car Speed Update (1)
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed
Content-Type: application/json
...
{
"type": "Float",
"value": 110
}
204 No Content
…
13
In the case of id ambiguity, you can use
"?type=Car" to specify entity type
Quick Usage Example: Car Speed Query (1)
200 OK
Content-Type: application/json
...
{
"type": "Float",
"value": 110,
"metadata": {}
}
14
You can get all the attributes of the entity using the
entity URL:
GET/v2/entities/Car1/attrs
GET <cb_host>:1026/v2/entities/Car1/attrs/speed
Quick Usage Example: Car Speed Update (2)
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Content-Type: text/plain
...
115
204 No Content
…
15
Quick Usage Example: Car Speed Query (2)
16
200 OK
Content-Type: text/plain
...
115.000000
GET <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Accept: text/plain
201 Created
...
Quick Usage Example: Room Create (1)
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Room1",
"type": "Room",
"temperature": {
"type": "Float",
"value": 24
},
"pressure": {
"type": "Integer",
"value": 718
}
}
17
204 No Content
…
Quick Usage Example: Room Update (1)
PATCH <cb_host>:1026/v2/entities/Room1/attrs
Content-Type: application/json
...
{
"temperature“: {
"type": "Float",
"value": 25
},
"pressure": {
"type": "Integer",
"value": 720
}
}
18
Quick Usage Example: Room Query (1)
19
200 OK
Content-Type: application/json
...
{
"pressure": {
"type": "Integer",
"value": 720,
"metadata": {}
},
"temperature": {
"type": "Float",
"value": 25,
"metadata": {}
}
}
GET <cb_host>:1026/v2/entities/Room1/attrs
Quick Usage Example: Room Query (2)
20
200 OK
Content-Type: application/json
...
{
"pressure": 720,
"temperature": 25
}
GET <cb_host>:1026/v2/entities/Room1/attrs?options=keyValues
201 Created
...
Quick Usage Example: Room Create (2)
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Room2",
"type": "Room",
"temperature": {
"type": "Float",
"value": 29
},
"pressure": {
"type": "Integer",
"value": 730
}
}
21
Quick Usage Example: Filters (1)
22
200 OK
Content-Type: application/json
...
[
{
"id": "Room2",
"pressure": 730,
"temperature": 29,
"type": "Room"
}
]
GET <cb_host>:1026/v2/entities?options=keyValues&q=temperature>27
Quick Usage Example: Filters (2)
23
200 OK
Content-Type: application/json
...
[
{
"id": "Room1",
"pressure": 720,
"temperature": 25,
"type": "Room"
}
]
GET <cb_host>:1026/v2/entities?options=keyValues&q=pressure==715..725
The full description of the Simple
Query Language for filtering can be
found in the NGSIv2 Specification
document
Push data
24
Context Broker operations: push data
• Context Consumers can subscribe to receive context information that satisfy
certain conditions using the subscribe operation. Such subscriptions may have
an expiration time.
• The Context Broker notifies updates on context information to subscribed
Context Consumers by invoking the notify operation they export
subId = subscribeContext (consumer, expr, expiration)
Context
Consumer
notify (subId, data/context)
Context
Broker
Application
25
Quick Usage Example: Subscription
POST <cb_host>:1026/v2/subscriptions
Content-Type: application/json
…
{
"subject": {
"entities": [
{
"id": "Room1",
"type": "Room"
}
],
"condition": {
"attrs": [ "temperature" ]
}
},
"notification": {
"http": {
"url": "http://<host>:<port>/publish"
},
"attrs": [ "temperature" ]
},
"expires": "2026-04-05T14:00:00.00Z"
}
201 Created
Location: /v2/subscriptions/51c0ac9ed714fb3b37d7d5a8
...
26
POST /publish HTTP/1.1
Content-type: application/json; charset=utf-8
Ngsiv2-AttrsFormat: normalized
…
{
"subscriptionId": "574d720dbef222abb860534a",
"data": [
{
"id": "Room1",
"type": "Room",
"temperature": {
"type": "Float",
"value": 19,
"metadata": {}
}
}
]
}
Quick Usage Example: Notification
27
25
19
List existing subscriptions
28
200 OK
Content-Type: application/json
…
[{
"id": " 51c0ac9ed714fb3b37d7d5a8 ",
"expires": "2026-04-05T14:00:00.00Z",
"status": "active",
"subject": {
"entities": [{
"id": "Room1",
"type": "Room"
}],
"condition": {
"attrs": ["temperature"]
}
},
"notification": {
"timesSent": 3,
"lastNotification": "2016-05-31T11:19:32.00Z",
"lastSuccess": "2016-05-31T11:19:32.00Z",
"attrs": ["temperature"],
"attrsFormat": "normalized",
"http": {
"url": "http://localhost:1028/publish"
}
}
}]
The full description of the
subscription object (including all its
fields) can be found in the NGSIv2
Specification
GET <cb_host>:1026/v2/subscriptions
Batch operations
29
Orion Context Broker batch operations
30
• Batch query and batch update
• They are equivalent in functionality to previously described RESTful
operations
• All them use POST as verb and the /v2/op URL prefix, including
operation parameters in the JSON payload
• They implement extra functionality that cannot be achieved with
RESTful operations, e.g. to create several entities with the same
operation
• They are not a substitute but a complement to RESTful operations
201 Created
...
Batch Operation Example: Create Several Rooms
POST <cb_host>:1026/v2/op/update
Conten-Type: application/json
...
{
"actionType": "APPEND",
"entities": [
{
"type": "Room",
"id": "Room3",
"temperature": {
"value": 21.2,
"type": "Float"
},
"pressure": {
"value": 722,
"type": "Integer"
}
},
…
31
…
{
"type": "Room",
"id": "Room4",
"temperature": {
"value": 31.8,
"type": "Float"
},
"pressure": {
"value": 712,
"type": "Integer"
}
}
]
}
32
Pagination
Metadata
Compound attribute/metadata values
Type
browsing
Geo-location
Query filters
DateTime support
Custom notifications
Notification status
Attribute/metadata filtering
Special attribute/metadata
Registrations & context providers
Multitenancy
Orion advanced functionality… next class!
Creating & pulling data
Pushing data
Subscriptions & Notifications
Batch operations
Comet
33
STH-COMET: Why?
34
▪ The Context Broker only stores
the latest attribute values:
• Event-driven action-oriented
paradigm
▪ The Short Time Historic adds
memory into the equation:
• Continuous improvement
paradigm
STH-COMET: What?
35
▪ Time series database:
• Optimized to deal with values
indexed in time
• Raw data vs. Aggregated data
• Basic aggregation concepts:
□ Range
□ Resolution
□ Origin
□ Offset
STH – Comet : How
(birds-eye functioning: minimal)
36
update
query (raw & aggregated)
Client
Orion
Context
Broker
Help project
37
Help project content
38
Context Broker
IoT Agent
Ultralight 2.0
STH - COMET
MongoDB
7896
4041
1026 8666
Virtual Machine Instance
▪ Ansible and docker-compose file to deploy a Virtual Machine with
Orion, IoT Agent Ultralight and Comet.
https://github.com/flopezag/fiware-iot-hackathon
▪ Instruction to send data from sensor and recover them from Orion or
Comet (data aggregation)
• The easy way
– Orion User Manual: google for “Orion FIWARE manual” and use the first hit
– Orion Catalogue page: google for “Orion FIWARE catalogue” and use the first hit
• References
– NGSIv2 Specification
• http://fiware.github.io/specifications/ngsiv2/stable
• http://fiware.github.io/specifications/ngsiv2/latest
– NGSIv2 for NGSIv1 developers
• http://bit.ly/ngsiv2-vs-ngsiv1
– Orion Catalogue:
• http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-
broker
– Orion support though StackOverflow
• Ask your questions using the “fiware-orion” tag
• Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion
39
Would you like to know more?
Question & Answer
fiware-tech-help@lists.fiware.org
fiware-lab-help@lists.fiware.org
40
Thank you!
http://fiware.org
Follow @FIWARE on Twitter
41
Thank you!
http://fiware.org
Follow @FIWARE on Twitter
Backup slides
• Used by /v2/op/update (batch operation)
• Conventional actionTypes
– APPEND: append (or update if the attribute already
exists)
– UPDATE: update
– DELETE: delete
• Special actionTypes
– APPEND_STRICT: strict append (returns error if some of
the attributes to add already exists)
– REPLACE: delete all the entity attributes, next append
the ones in the update request
Special update action types
44
NGSIv2 status (AKA the “NGSIv2 disclaimer”)
• NGSIv2 is in “release candidate” status
– By "release candidate" we mean that the specification is quite stable,
but changes may occur with regard to new release candidates or the
final version. In particular changes may be of two types:
• Extensions to the functionality currently specified by this document.
Note that in this case there isn't any risk of breaking backward
compatibility on existing software implementations.
• Slight modifications in the functionality currently specified by this
document, as a consequence of ongoing discussions. Backward
compatibility will be taken into account in this case, trying to
minimize the impact on existing software implementations. In
particular, only completely justified changes impacting backward
compatibility will be allowed and "matter of taste" changes will not
be allowed.
45
So… when should I use NGSIv1 or NGSIv2?
• In general, it is always preferable to use NGSIv2
• However, you would need to use NGSIv1 if
– You need register/discovery operations (context management
availability functionality)
• Not yet implemented in NGSIv2 (in roadmap)
– Zero tolerance to changes in software interacting with Orion
• Even if you use NGSIv1, you can still use NGSIv2 advanced
functionality
– See “Considerations on NGSIv1 and NGSIv2 coexistence” section
at Orion manual
• For a NGSIv1-based version of this presentation have a look
to
– http://bit.ly/fiware-orion-ngsiv1
46

More Related Content

PPTX
Introduction to FIWARE IoT
PPTX
FIWARE IoT Introduction 1
PPTX
Context-aware application development with FIWARE #CPBR8
PPTX
Fiware Developers Week Iot exercises (Advanced)
PPTX
Fiware Developers Week IoT Agents (Advanced)
PPTX
Cosmos, Big Data GE implementation in FIWARE
PPTX
Fiware, the future internet
PDF
FIWARE Developers Week_BootcampWeBUI_presentation1
Introduction to FIWARE IoT
FIWARE IoT Introduction 1
Context-aware application development with FIWARE #CPBR8
Fiware Developers Week Iot exercises (Advanced)
Fiware Developers Week IoT Agents (Advanced)
Cosmos, Big Data GE implementation in FIWARE
Fiware, the future internet
FIWARE Developers Week_BootcampWeBUI_presentation1

What's hot (20)

PPTX
FIWARE: Managing Context Information at large scale
PPTX
FIWARE Primer - Learn FIWARE in 60 Minutes
PDF
FIWARE Internet of Things
PPT
Fiware io t_ul20_cpbr8
PPT
FIWARE Developers Week_FIWARE IoT: Beginner's tutorial_conference
PPTX
Introduction to FIWARE Cloud & Context Broker
PPTX
Setting up your virtual infrastructure using FIWARE Lab Cloud
PPTX
Fiware IoT_IDAS_intro_ul20_v2
PPTX
Developing your first application using FI-WARE
PDF
FIWARE Developers Week_BootcampWeBUI_presentation2
PPTX
Fiware, the future internet
PPTX
FIWARE Developers Week_IoT basic exercises
PDF
Connecting to the internet of things (IoT)
PDF
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
PPTX
Io t basic-exercises
PPTX
FIWARE NGSI: Managing Context Information at Large Scale
PPTX
IoT Agents (With Lightweight M2M)
PPTX
A Complete IoT Backend Infrastructure in FIWARE
PPTX
Orion Context Broker
PDF
FIWARE Tech Summit - FIWARE IoT Agents
FIWARE: Managing Context Information at large scale
FIWARE Primer - Learn FIWARE in 60 Minutes
FIWARE Internet of Things
Fiware io t_ul20_cpbr8
FIWARE Developers Week_FIWARE IoT: Beginner's tutorial_conference
Introduction to FIWARE Cloud & Context Broker
Setting up your virtual infrastructure using FIWARE Lab Cloud
Fiware IoT_IDAS_intro_ul20_v2
Developing your first application using FI-WARE
FIWARE Developers Week_BootcampWeBUI_presentation2
Fiware, the future internet
FIWARE Developers Week_IoT basic exercises
Connecting to the internet of things (IoT)
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
Io t basic-exercises
FIWARE NGSI: Managing Context Information at Large Scale
IoT Agents (With Lightweight M2M)
A Complete IoT Backend Infrastructure in FIWARE
Orion Context Broker
FIWARE Tech Summit - FIWARE IoT Agents
Ad

Similar to Context Information Management in IoT enabled smart systems - the basics (20)

PDF
Core Context Management
PPTX
FIWARE: Managing Context Information at Large Scale (NGSIv1)
PPTX
Orion Context Broker 20210602
PPTX
Orion Context Broker 20210412
PPTX
Orion Context Broker 20190214
PPTX
Orion Context Broker 2020-03-25
PPTX
Orion Context Broker 20181218
PPTX
Orion Context Broker 20191021
PPTX
Orion Context Broker 20180928
PPTX
Orion Context Broker 2020-10-28
PPTX
Orion Context Broker 2020-10-29
PPTX
Orion Context Broker 20220526
PPTX
Orion Context Broker 20211209
PPTX
Orion Context Broker 20210907
PPTX
Orion Context Broker 20220127
PPTX
Orion Context Broker 20211022
PPTX
Orion Context Broker 20220301
PPTX
FIWARE Developers Week_ Introduction to Managing Context Information at Large...
PPTX
Orion Context Broker 20210309
PPTX
Orion Context Broker introduction 20250509
Core Context Management
FIWARE: Managing Context Information at Large Scale (NGSIv1)
Orion Context Broker 20210602
Orion Context Broker 20210412
Orion Context Broker 20190214
Orion Context Broker 2020-03-25
Orion Context Broker 20181218
Orion Context Broker 20191021
Orion Context Broker 20180928
Orion Context Broker 2020-10-28
Orion Context Broker 2020-10-29
Orion Context Broker 20220526
Orion Context Broker 20211209
Orion Context Broker 20210907
Orion Context Broker 20220127
Orion Context Broker 20211022
Orion Context Broker 20220301
FIWARE Developers Week_ Introduction to Managing Context Information at Large...
Orion Context Broker 20210309
Orion Context Broker introduction 20250509
Ad

More from Fernando Lopez Aguilar (20)

PDF
Introduction to FIWARE technology
PDF
DW2020 Data Models - FIWARE Platform
PPTX
FIWARE and Smart Data Models
PPTX
How to deploy a smart city platform?
PPTX
Building the Smart City Platform on FIWARE Lab
PDF
Data Modeling with NGSI, NGSI-LD
PDF
FIWARE and Robotics
PDF
Big Data and Machine Learning with FIWARE
PDF
Operational Dashboards with FIWARE WireCloud
PDF
Creating a Context-Aware solution, Complex Event Processing with FIWARE Perseo
PDF
FIWARE Identity Management and Access Control
PDF
Data persistency (draco, cygnus, sth comet, quantum leap)
PDF
How to debug IoT Agents
PDF
What is an IoT Agent
PDF
FIWARE Overview
PDF
Overview of the FIWARE Ecosystem
PPTX
Cloud and Big Data in the agriculture sector
PDF
Berlin OpenStack Summit'18
PPTX
How to deploy spark instance using ansible 2.0 in fiware lab v2
PPTX
Simple docker hosting in FIWARE Lab
Introduction to FIWARE technology
DW2020 Data Models - FIWARE Platform
FIWARE and Smart Data Models
How to deploy a smart city platform?
Building the Smart City Platform on FIWARE Lab
Data Modeling with NGSI, NGSI-LD
FIWARE and Robotics
Big Data and Machine Learning with FIWARE
Operational Dashboards with FIWARE WireCloud
Creating a Context-Aware solution, Complex Event Processing with FIWARE Perseo
FIWARE Identity Management and Access Control
Data persistency (draco, cygnus, sth comet, quantum leap)
How to debug IoT Agents
What is an IoT Agent
FIWARE Overview
Overview of the FIWARE Ecosystem
Cloud and Big Data in the agriculture sector
Berlin OpenStack Summit'18
How to deploy spark instance using ansible 2.0 in fiware lab v2
Simple docker hosting in FIWARE Lab

Recently uploaded (20)

PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
Digital Literacy And Online Safety on internet
PPTX
Internet___Basics___Styled_ presentation
PPTX
artificial intelligence overview of it and more
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
Introuction about ICD -10 and ICD-11 PPT.pptx
PPTX
Funds Management Learning Material for Beg
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PDF
Paper PDF World Game (s) Great Redesign.pdf
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
SAP Ariba Sourcing PPT for learning material
INTERNET------BASICS-------UPDATED PPT PRESENTATION
international classification of diseases ICD-10 review PPT.pptx
RPKI Status Update, presented by Makito Lay at IDNOG 10
Digital Literacy And Online Safety on internet
Internet___Basics___Styled_ presentation
artificial intelligence overview of it and more
Triggering QUIC, presented by Geoff Huston at IETF 123
The New Creative Director: How AI Tools for Social Media Content Creation Are...
The Internet -By the Numbers, Sri Lanka Edition
Design_with_Watersergyerge45hrbgre4top (1).ppt
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Introuction about ICD -10 and ICD-11 PPT.pptx
Funds Management Learning Material for Beg
Module 1 - Cyber Law and Ethics 101.pptx
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
Paper PDF World Game (s) Great Redesign.pdf
Decoding a Decade: 10 Years of Applied CTI Discipline
introduction about ICD -10 & ICD-11 ppt.pptx
An introduction to the IFRS (ISSB) Stndards.pdf
SAP Ariba Sourcing PPT for learning material

Context Information Management in IoT enabled smart systems - the basics

  • 1. IoT in the FIWARE Platform - 2: Context Information Management in IoT-enabled Smart Systems: The basics Fernando López Aguilar FIWARE Cloud and Platform Senior Expert fernando.lopez@fiware.org @flopezaguilar
  • 2. • Orion Context Broker • Creating and pulling data • Pushing data and notifications • Batch operations • STH - Comet 2 Outline
  • 4. Orion Context Broker • Main functions: – Context management – Context availability management (advanced topic) • HTTP and REST-based – JSON payload support • Context in NGSI is based in an entity-attribute model: Attributes • Name • Type • Value Entity • EntityId • EntityType 1 n “has” 4
  • 5. Orion Context Broker in a nutshell Orion Context Broker Context Producers Context Consumers subscriptions update query notify notify update update DB 1026 1026 5
  • 6. GET <cb_host>:1026/version { "orion" : { "version" : "1.6.0", "uptime" : "7 d, 21 h, 33 m, 39 s", "git_hash" : "aee96414cc3594bba161afb400f69d101978b39c", "compile_time" : "Mon Dec 5 08:38:58 CET 2016", "compiled_by" : "fermin", "compiled_in" : "centollo" } } 6 Orion Context Broker – check health
  • 7. Two “flavours” of NGSI API • NGSIv1 – Original NGSI RESTful binding of OMA-NGSI – Implemented in 2013 – Uses the /v1 prefix in resource URL • NGSIv2 – A revamped, simplified binding of OMA-NGSI – Enhanced functionality compared with NGSIv1 (eg. filtering) – Stable, ready for production, version already available • Current NGSIv2 version is Release Candidate 2016.10 http://telefonicaid.github.io/fiware-orion/api/v2/stable • New features coming (http://telefonicaid.github.io/fiware-orion/api/v2/stable) – Uses the /v2 prefix in resource URL • Introduction to NGSIv2 – https://docs.google.com/presentation/d/1_fv9dB5joCsOCHlb4Ld6A- QmeIYhDzHgFHUWreGmvKU/edit#slide=id.g53c31d7074fd7bc7_0 7
  • 8. Orion Context Broker Basic Operations Entities • GET /v2/entities • Retrieve all entities • POST /v2/entities • Creates an entity • GET /v2/entities/{entityID} • Retrieves an entity • [PUT|PATCH|POST] /v2/entities/{entityID} • Updates an entity (different “flavours”) • DELETE /v2/entities/{entityID} • Deletes an entity 8
  • 9. Orion Context Broker Basic Operations Attributes • GET /v2/entities/{entityID}/attrs/{attrName} • Retrieves an attribute’s data • PUT /v2/entities/{entityID}/attrs/{attrName} • Updates an attribute’s data • DELETE /v2/entities/{entityID}/attrs/{attrName} • Deletes an attribute • GET /v2/entities/{entityID}/attrs/{attrName}/value • Retrieves an attribute’s value • PUT /v2/entities/{entityID}/attrs/{attrName}/value • Updates an attribute’s value 9
  • 10. Create & Pull data 10
  • 11. Context Broker operations: create & pull data • Context Producers publish data/context elements by invoking the update operations on a Context Broker. • Context Consumers can retrieve data/context elements by invoking the query operations on a Context Broker Context Consumer query Context Producer update Context Broker 11
  • 12. Quick Usage Example: Car Create 201 Created 12 POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Car1", "type": "Car", "speed": { "type": "Float", "value": 98 } }
  • 13. Quick Usage Example: Car Speed Update (1) PUT <cb_host>:1026/v2/entities/Car1/attrs/speed Content-Type: application/json ... { "type": "Float", "value": 110 } 204 No Content … 13 In the case of id ambiguity, you can use "?type=Car" to specify entity type
  • 14. Quick Usage Example: Car Speed Query (1) 200 OK Content-Type: application/json ... { "type": "Float", "value": 110, "metadata": {} } 14 You can get all the attributes of the entity using the entity URL: GET/v2/entities/Car1/attrs GET <cb_host>:1026/v2/entities/Car1/attrs/speed
  • 15. Quick Usage Example: Car Speed Update (2) PUT <cb_host>:1026/v2/entities/Car1/attrs/speed/value Content-Type: text/plain ... 115 204 No Content … 15
  • 16. Quick Usage Example: Car Speed Query (2) 16 200 OK Content-Type: text/plain ... 115.000000 GET <cb_host>:1026/v2/entities/Car1/attrs/speed/value Accept: text/plain
  • 17. 201 Created ... Quick Usage Example: Room Create (1) POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Room1", "type": "Room", "temperature": { "type": "Float", "value": 24 }, "pressure": { "type": "Integer", "value": 718 } } 17
  • 18. 204 No Content … Quick Usage Example: Room Update (1) PATCH <cb_host>:1026/v2/entities/Room1/attrs Content-Type: application/json ... { "temperature“: { "type": "Float", "value": 25 }, "pressure": { "type": "Integer", "value": 720 } } 18
  • 19. Quick Usage Example: Room Query (1) 19 200 OK Content-Type: application/json ... { "pressure": { "type": "Integer", "value": 720, "metadata": {} }, "temperature": { "type": "Float", "value": 25, "metadata": {} } } GET <cb_host>:1026/v2/entities/Room1/attrs
  • 20. Quick Usage Example: Room Query (2) 20 200 OK Content-Type: application/json ... { "pressure": 720, "temperature": 25 } GET <cb_host>:1026/v2/entities/Room1/attrs?options=keyValues
  • 21. 201 Created ... Quick Usage Example: Room Create (2) POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Room2", "type": "Room", "temperature": { "type": "Float", "value": 29 }, "pressure": { "type": "Integer", "value": 730 } } 21
  • 22. Quick Usage Example: Filters (1) 22 200 OK Content-Type: application/json ... [ { "id": "Room2", "pressure": 730, "temperature": 29, "type": "Room" } ] GET <cb_host>:1026/v2/entities?options=keyValues&q=temperature>27
  • 23. Quick Usage Example: Filters (2) 23 200 OK Content-Type: application/json ... [ { "id": "Room1", "pressure": 720, "temperature": 25, "type": "Room" } ] GET <cb_host>:1026/v2/entities?options=keyValues&q=pressure==715..725 The full description of the Simple Query Language for filtering can be found in the NGSIv2 Specification document
  • 25. Context Broker operations: push data • Context Consumers can subscribe to receive context information that satisfy certain conditions using the subscribe operation. Such subscriptions may have an expiration time. • The Context Broker notifies updates on context information to subscribed Context Consumers by invoking the notify operation they export subId = subscribeContext (consumer, expr, expiration) Context Consumer notify (subId, data/context) Context Broker Application 25
  • 26. Quick Usage Example: Subscription POST <cb_host>:1026/v2/subscriptions Content-Type: application/json … { "subject": { "entities": [ { "id": "Room1", "type": "Room" } ], "condition": { "attrs": [ "temperature" ] } }, "notification": { "http": { "url": "http://<host>:<port>/publish" }, "attrs": [ "temperature" ] }, "expires": "2026-04-05T14:00:00.00Z" } 201 Created Location: /v2/subscriptions/51c0ac9ed714fb3b37d7d5a8 ... 26
  • 27. POST /publish HTTP/1.1 Content-type: application/json; charset=utf-8 Ngsiv2-AttrsFormat: normalized … { "subscriptionId": "574d720dbef222abb860534a", "data": [ { "id": "Room1", "type": "Room", "temperature": { "type": "Float", "value": 19, "metadata": {} } } ] } Quick Usage Example: Notification 27 25 19
  • 28. List existing subscriptions 28 200 OK Content-Type: application/json … [{ "id": " 51c0ac9ed714fb3b37d7d5a8 ", "expires": "2026-04-05T14:00:00.00Z", "status": "active", "subject": { "entities": [{ "id": "Room1", "type": "Room" }], "condition": { "attrs": ["temperature"] } }, "notification": { "timesSent": 3, "lastNotification": "2016-05-31T11:19:32.00Z", "lastSuccess": "2016-05-31T11:19:32.00Z", "attrs": ["temperature"], "attrsFormat": "normalized", "http": { "url": "http://localhost:1028/publish" } } }] The full description of the subscription object (including all its fields) can be found in the NGSIv2 Specification GET <cb_host>:1026/v2/subscriptions
  • 30. Orion Context Broker batch operations 30 • Batch query and batch update • They are equivalent in functionality to previously described RESTful operations • All them use POST as verb and the /v2/op URL prefix, including operation parameters in the JSON payload • They implement extra functionality that cannot be achieved with RESTful operations, e.g. to create several entities with the same operation • They are not a substitute but a complement to RESTful operations
  • 31. 201 Created ... Batch Operation Example: Create Several Rooms POST <cb_host>:1026/v2/op/update Conten-Type: application/json ... { "actionType": "APPEND", "entities": [ { "type": "Room", "id": "Room3", "temperature": { "value": 21.2, "type": "Float" }, "pressure": { "value": 722, "type": "Integer" } }, … 31 … { "type": "Room", "id": "Room4", "temperature": { "value": 31.8, "type": "Float" }, "pressure": { "value": 712, "type": "Integer" } } ] }
  • 32. 32 Pagination Metadata Compound attribute/metadata values Type browsing Geo-location Query filters DateTime support Custom notifications Notification status Attribute/metadata filtering Special attribute/metadata Registrations & context providers Multitenancy Orion advanced functionality… next class! Creating & pulling data Pushing data Subscriptions & Notifications Batch operations
  • 34. STH-COMET: Why? 34 ▪ The Context Broker only stores the latest attribute values: • Event-driven action-oriented paradigm ▪ The Short Time Historic adds memory into the equation: • Continuous improvement paradigm
  • 35. STH-COMET: What? 35 ▪ Time series database: • Optimized to deal with values indexed in time • Raw data vs. Aggregated data • Basic aggregation concepts: □ Range □ Resolution □ Origin □ Offset
  • 36. STH – Comet : How (birds-eye functioning: minimal) 36 update query (raw & aggregated) Client Orion Context Broker
  • 38. Help project content 38 Context Broker IoT Agent Ultralight 2.0 STH - COMET MongoDB 7896 4041 1026 8666 Virtual Machine Instance ▪ Ansible and docker-compose file to deploy a Virtual Machine with Orion, IoT Agent Ultralight and Comet. https://github.com/flopezag/fiware-iot-hackathon ▪ Instruction to send data from sensor and recover them from Orion or Comet (data aggregation)
  • 39. • The easy way – Orion User Manual: google for “Orion FIWARE manual” and use the first hit – Orion Catalogue page: google for “Orion FIWARE catalogue” and use the first hit • References – NGSIv2 Specification • http://fiware.github.io/specifications/ngsiv2/stable • http://fiware.github.io/specifications/ngsiv2/latest – NGSIv2 for NGSIv1 developers • http://bit.ly/ngsiv2-vs-ngsiv1 – Orion Catalogue: • http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context- broker – Orion support though StackOverflow • Ask your questions using the “fiware-orion” tag • Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion 39 Would you like to know more?
  • 44. • Used by /v2/op/update (batch operation) • Conventional actionTypes – APPEND: append (or update if the attribute already exists) – UPDATE: update – DELETE: delete • Special actionTypes – APPEND_STRICT: strict append (returns error if some of the attributes to add already exists) – REPLACE: delete all the entity attributes, next append the ones in the update request Special update action types 44
  • 45. NGSIv2 status (AKA the “NGSIv2 disclaimer”) • NGSIv2 is in “release candidate” status – By "release candidate" we mean that the specification is quite stable, but changes may occur with regard to new release candidates or the final version. In particular changes may be of two types: • Extensions to the functionality currently specified by this document. Note that in this case there isn't any risk of breaking backward compatibility on existing software implementations. • Slight modifications in the functionality currently specified by this document, as a consequence of ongoing discussions. Backward compatibility will be taken into account in this case, trying to minimize the impact on existing software implementations. In particular, only completely justified changes impacting backward compatibility will be allowed and "matter of taste" changes will not be allowed. 45
  • 46. So… when should I use NGSIv1 or NGSIv2? • In general, it is always preferable to use NGSIv2 • However, you would need to use NGSIv1 if – You need register/discovery operations (context management availability functionality) • Not yet implemented in NGSIv2 (in roadmap) – Zero tolerance to changes in software interacting with Orion • Even if you use NGSIv1, you can still use NGSIv2 advanced functionality – See “Considerations on NGSIv1 and NGSIv2 coexistence” section at Orion manual • For a NGSIv1-based version of this presentation have a look to – http://bit.ly/fiware-orion-ngsiv1 46

Editor's Notes

  • #6: Orion Context Broker is an implementation of a context information broker with persistent storage It implements OMA NGSI9/10 specification NGSI9 is about context information availability (i.e. sources of context information) management NGSI10 is about context information itself
  • #39: - "7896" - "4041"