This document outlines exercises for learning how to use the Orion Context Broker. It includes exercises to:
1. Create, query, and update entities using standard operations.
2. Create, query, and update entities using convenience operations.
3. Browse entity types and subscribe to notifications.
More advanced exercises cover pagination, geolocation queries, compound attributes, custom metadata, and querying/updating entities with compound attributes. Contact information is provided for questions.
2. Outline
CB-1. Create entities using standard ops
CB-2. Query entities using standard ops
CB-3. Update entity using standard ops
CB-4. Create entities using conv ops
CB-5. Query entities using conv ops
CB-6. Update entity using conv ops
CB-7. Browsing entity types
CB-8. Basic subscription/notifications
2
3. CB-1. Create entities using standard ops
Steps
Create the following entities in your Orion
instance
See table in next slide
Hints
Orion User Manual section 3.3.1.1
(UpdateContext & APPEND)
Easy
4. CB-1 . Create entities using standard ops Easy
Entity Entity Type
Bedroom1 Room
Bedroom2 Room
Kitchen Room
Frontdoor Door
Backdoor Door
Entity Type Attr. Name Attr. Type Example value
Room Temperature float 27.8
Presence boolean true
Status string OK
Door Locked boolean false
Closed boolean false
5. CB-2. Query entities using standard ops
Prerequisites
Exercise CB-1
Steps
Write a program (or web/mobile application) that does
the following queries and prints the result
Obtain all attributes of Bedroom1 entity
Obtain only the Temperature attribute of Kitchen entity
Obtain all attributes of Kitchen and Bedroom2 entities in one
query
Obtain all attributes of entities that match the pattern
Bedroom.*
Find out whether the doors are closed using the pattern
.*door and the Closed attribute
Run and test your program/application
Hints
Orion User Manual section 3.3.1.2
(queryContext)
Easy
6. CB-3. Update entity using standard ops
Prerequisites
Exercise CB-2
Steps
Write a program (or web/mobile application)
that
Asks for user input (one value)
Updates Looked attribute of Frontdoor entity using
that input
Queries the entity and check the result
Run and test your program/application
Hints
Orion User Manual section 3.3.1.2 and 3.3.1.3
(updateContext & UPDATE)
Easy
7. CB-4. Create entities using conv ops
Prerequisites
Exercise CB-3
Steps
Create the following entities in your Orion
instance
See table in next slide
Hints
Similar to exercise CB-2 in the standard ops
set
Orion User Manual section 3.3.2.1
(contextEntities/entityID)
Easy
8. CB-4. Create entities using conv ops Easy
Entity Entity Type
Garage Room
Bathroom Room
Light1 Light
Light2 Light
Light3 Light
Entity Type Attr. Name Attr. Type Example value
Room Temperature float 27.8
Presence boolean true
Status string OK
Light Intensity Percent 0.25
9. CB-5. Query entities using conv ops
Prerequisites
Exercise CB-4
Steps
Write a program (or web/mobile application) that does the
following queries using convenience operations and print the
result
Obtain all attributes of the Garage entity
Find out whether there is anyone in the Bathroom entity
Obtain all entities created so far
Obtain all entities of type Room
Obtain the temperature attribute of all entities of type Room
Run and test your program/application
Hints
Similar to exercise CB-2 in the standard ops set
To get all entities of a given type, you can use the
contextEntityType resource
Orion User Manual section 3.3.2.2
(contextEntities/entityID and contextEntities/type/XX/id/XX)
Easy
10. CB-6. Update entity using conv ops
Prerequisites
Exercise CB-5
Steps
Write a program (or web/mobile application) that
Asks for user input (one value)
Updates Intensity attribute of Light1 entity using that
input using a convenience operation
Queries the entity and check the result
Run and test your program/application
Hints
Similar to exercise CB-3 in the std ops set
Orion User Manual section 3.3.2.2 and 3.3.2.3
(contextEntities/entityID and
contextEntities/type/XX/id/XX)
Easy
11. CB-7. Browsing entity types
Prerequisites
Exercise CB-6
Steps
Write a program (or web/mobile application)
that
Lists all entity types
Provides detailed information of type Door
Run and test your program/application
Hints
Orion User Manual section 3.5.6
(contextTypes)
Easy
12. CB-8. Basic subscription/notifications
Prerequisites
Exercise CB-7
Steps
Write a program that
Starts a REST server to receive notifications from Orion
Prints the value of the Temperature attribute of Bedroom1
entity each time a notification is received
Subscribe your program to changes in the
Temperature attribute of Bedroom1 entity
Update the Temperature attribute of Bedroom1 entity
and check that your program prints the updated value
Hints
Orion User Manual section 3.3.1.4 (specially subsection
on ONCHANGE, i.e. 3.3.1.4.2)
Your program has to run in a VM to which your Orion
instance may send notifications (e.g. the same VM in
which Orion is running)
Medium
15. CB-1. Pagination
Prerequisites
Access to Orion instance running in
workshop.tidnode.cl port 1026
Steps
Check how many entities of type Sensor are
stored in that Orion instance
Write a program (or web/mobile application) that
Asks for a limit and a page number
Returns the name IDs the entities of type Sensor in the
corresponding page
Run and test your program/application
Hints
Orion User Manual section 3.5.1
(queryContext?limit=100&details=on)
Medium
16. CB-2. Geolocation (factory)
Prerequisites
Access to Orion instance running in
workshop.tidnode.cl port 1026
Steps
Write a program (or web/mobile
application) that
Gets all existing types
Gets all entities of each type in areas Red,
Green and Blue (see next slide), printing entity
IDs and their attributes which their values
Run and test your program/application
Hints
Orion User Manual section 3.5.20
Medium
19. CB-3. Compound attributes
Prerequisites
Exercise CB-1
Steps
Create the following entities in your Orion
instance
See table in next slide
Hints
Orion User Manual section 3.5.19
Medium
20. CB-3. Compound attributes
Entity Type Attr. Name Attr. Type Example value
Character Name string Fooy
Hitpoints integer 110
Class string Barbarian
Abilities compound {
"STR": "2",
"DEX": "4",
"CON": "3",
"INT": "1",
"WIS": "1",
"CHA": "2"
}
Inventory compound {
"weapons": [ "sword", "dagger" ],
"potions": { "life": "1", "mana": "0" },
"other": ["shield"]
}
Entity name Entity Type
Gandalf Character
Aragorn Character
Frodo Character
Medium
21. CB-4. Query entities with compound attributes
Prerequisites
Exercise CB-1
Steps
Write a program (or web/mobile
application) that does the following queries
and print the result
Obtain all attributes of Aragorn entity
Obtain only the Abilities attribute of Frodo
entity
Run and test your program/application
Hints
Orion User Manual section 3.5.19
Medium
22. CB-5. Update entities with compound attributes
Prerequisites
Exercise CB-1
Steps
Write a program (or web/mobile application)
that
Asks for an object name (e.g. staff, hat, etc.)
Updates Gandalf's Inventory attribute to reflect
that he now has a that object test your program
Run and test your program/application
Query the Gandalf's Inventory after that, in order
to check that the object has been successfully added
Hints
Orion User Manual section 3.5.19
Medium
23. CB-6. Custom metadata Medium
Prerequisites
Exercise CB-1
Steps
Update the Gandalf entity so that the
inventory attribute has two new metadatas:
name="Weight", type="float", value="1.2"
name="MaxWeight", type="float", value="20"
Query Gandalf again to see the new metadata
atached to the corresponding attribute
Hints
Orion User Manual section 3.5.7
24. Thanks!Thanks!
(Number to manuals sections in this presentation are valid at time of writing this March 9th 2015-, but they may
change along time)