semantic and the internet of things

47
Semantics and the Internet of Things

Upload: david-janes

Post on 16-Feb-2017

1.044 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: Semantic and the Internet of Things

Semantics and the Internet of Things

Page 2: Semantic and the Internet of Things

David Janes@dpjanes

[email protected]://iotdb.org/social/imadeit/

January 2016

Page 3: Semantic and the Internet of Things

Introduction

Page 4: Semantic and the Internet of Things

Why Semantics?

• Inter-stack Interoperability

• In use today

• …but can be improved

• Can be used for control

• Fits with REST (and HATEOAS) Model

Page 5: Semantic and the Internet of Things

Actuators

• How do I tell something “turn on”

• I don’t care how it does it, just that that it does it

• the concept of "turn on" is basically universal / standard independent

Page 6: Semantic and the Internet of Things

Sensors

• What does { t: 24.0 } mean?

Page 7: Semantic and the Internet of Things

Learning from the Web

• The Web works

• Use URIs

• Use REST

• Use JSON (-like data)

Page 8: Semantic and the Internet of Things

Classes v Composition

• Composition is better!

• Things do what they say they do

• Things are what they say they are

Page 9: Semantic and the Internet of Things

Goals

• Simplicity!

• Understandability!

• Orthogonality!

Page 10: Semantic and the Internet of Things

Semantics Today

Page 11: Semantic and the Internet of Things

CoAP / LWM2M

• RFC 6690 rt

• e.g. temperature could be http://sweet.jpl.nasa.gov/2.0/phys.owl#Temperature

Page 12: Semantic and the Internet of Things

Shortcomings

• We want to be able to easily create specify more powerful semantics

• e.g. max temperature, what is being measured, etc.

• We want to use semantics for control too

Page 13: Semantic and the Internet of Things

Proposed Model

Page 14: Semantic and the Internet of Things

N.B.

• We are leaving out some details to keep this high level

Page 15: Semantic and the Internet of Things

Key concept: Bands

• Bands are JSON-like dictionaries

• Bands have a URI

• Bands fully elucidate Things:

• A Thing has multiple bands: model, istate, ostate, meta, …

Page 16: Semantic and the Internet of Things
Page 17: Semantic and the Internet of Things

• think as: a Thing is a collection of bands

• each band can be manipulated RESTfully

• orthogonal

Page 18: Semantic and the Internet of Things

Assertion

• Everything we need to create Interoperability can be done well with this model

• Based on URIs / API / REST / JSON - i.e. how we program the Internet today

Page 19: Semantic and the Internet of Things

Bands

• JSON-like dictionaries

• Referenced by URIs

• Manipulate in a “web standard” way

• URI (from id and band)

• PUT / PATCH / GET

Page 20: Semantic and the Internet of Things

band: istate

• The “input” (toward me) state

• The actual state of the Thing

• e.g. "the light is on", "the light is off"

Page 21: Semantic and the Internet of Things

band: ostate

• The “output” state (toward the Thing)

• What we want the state to become

• e.g. "turn the light on", "turn the light off"

Page 22: Semantic and the Internet of Things

band: model

• describes terms used in istate and ostate

• "secret sauce" / HATEOAS terms

• JSON-LD

• composition not classes

Page 23: Semantic and the Internet of Things

Light Thing

Page 24: Semantic and the Internet of Things

A brief interruption

• we follow with a simple example

• we use a "little language" called IoTQL to write models

• it compiles to JSON-LD, which is what is actually in the model band

• used for brevity!

Page 25: Semantic and the Internet of Things

Light example

• A simple light which can be turned on / off

• it's currently on

• we're currently not changing anything

• note "o", the dictionary key used

Page 26: Semantic and the Internet of Things

Live Example

• http://homestar.io:20000/api/things

• coap://184.107.137.234:22001/ts

• mqtt://184.107.137.235:20001

Page 27: Semantic and the Internet of Things

Semantics

• e.g. the concept of "turning on / off" is: iot-purpose:on

• https://iotdb.org/pub/iot-purpose#on

• unconstrained "infinite" vocabulary

Page 28: Semantic and the Internet of Things

IoTQL model

CREATE MODEL Light WITH schema:name = "Light", iot:facet = iot-facet:lighting ATTRIBUTE "o" WITH schema:name = "on", iot:purpose = iot-purpose:on, iot:type = iot:type.boolean ;

Page 29: Semantic and the Internet of Things

JSON-LD model{ "@type": "iot:Model", "schema:name": "Light", "iot:facet": [ "iot-facet:lighting" ], "iot:attribute": [ { "@type": "iot:Attribute", "@id": "#o", "schema:name": "on", "iot:purpose": "iot-purpose:on", "iot:type": "iot:type.boolean", "iot:read": true, "iot:write": true, "iot:sensor": true, "iot:actuator": true } ] }

Page 30: Semantic and the Internet of Things

JSON istate

{ "o": true }

Page 31: Semantic and the Internet of Things

JSON ostate

{ "o": null }

Page 32: Semantic and the Internet of Things

How it works

Page 33: Semantic and the Internet of Things

Step 1

• the user "says" turn on the light

• as code, e.g: { "iot-purpose:on": true }

Page 34: Semantic and the Internet of Things

Step II

• Look in the model for

• an iot:Attribute

• with iot:purpose = iot-purpose:on

Page 35: Semantic and the Internet of Things

JSON-LD model{ "@type": "iot:Model", "schema:name": "Light", "iot:facet": [ "iot-facet:lighting" ], "iot:attribute": [ { "@type": "iot:Attribute", "@id": "#o", "schema:name": "on", "iot:purpose": "iot-purpose:on", "iot:type": "iot:type.boolean", "iot:read": true, "iot:write": true, "iot:sensor": true, "iot:actuator": true } ] }

Page 36: Semantic and the Internet of Things

Step III

• Look in the iot:Attribute found

• look at the "@id"

• this will tell us what to manipulate

• in this case "o"

Page 37: Semantic and the Internet of Things

JSON ostate

{ "o": null }

Page 38: Semantic and the Internet of Things

Step IV

• Change the ostate band in the usual RESTful way

• e.g. PATCH { "o": true }

Page 39: Semantic and the Internet of Things

Step V

• Actually turn on the light

• It's an implementation detail

• we don't care if it's a WeMo, a Hue, a LIFX, a homemade Arduino Light, …

Page 40: Semantic and the Internet of Things

Additional Notes

Page 41: Semantic and the Internet of Things

why istate / ostate?

• we need to know when things are transitioning - the interstitial state.

• we often want to use the same terms, e.g. "o" to describe both reading and writing

• it's a modelling concept, Things can "actually" do their own whatever

Page 42: Semantic and the Internet of Things

why complicated attributes?

• consider measuring temperature

• we may also need to describe:

• the units (celsius, fahrenheit), what is being measured, the accuracy, the minimum, the maximum, &c

Page 43: Semantic and the Internet of Things

Reference Implementation

Page 44: Semantic and the Internet of Things

Semantics

• https://iotdb.org/pub

• iot: core definitions

• iot-purpose: sensor and actuators

• iot-unit: units of measure

• iot-facet: facets (what does it do)

• https://github.com/dpjanes/iotdb-vocabulary

Page 45: Semantic and the Internet of Things

IOTDB

• https://homestar.io/about

• https://github.com/dpjanes/iotdb-homestar

• complete reference implementation

• https://github.com/dpjanes/homestar-coap/tree/master/docs/plugfest

Page 46: Semantic and the Internet of Things

Code

• https://github.com/dpjanes/node-iotdb

• https://github.com/dpjanes/iotdb-iotql

• (and many more)

Page 47: Semantic and the Internet of Things

Get in touch! David Janes

@[email protected]

http://iotdb.org/social/imadeit/