Archives: Wikis

Content Model

Overview

The IoTEntity XML content model is a representation of an IoTEntity and its properties, a serialization that can be used as payload in an Event and as result and body of the RESTful API‘s GET and POST operations. The content model is formally defined as an XML Schema that is available for download.

When used as part of the RESTful API, the IoTEntity model can be accessed on five different levels:

  1. IoTEntity – Represents an entity as a whole. This level is also used in Event messages.
  2. IoTProperty – An individual property of an entity identified by the URI in the request.
  3. ArrayOfIoTEntity – A list, or collection, of IoTEntity elements.
  4. ArrayOfIoTProperty – A list, or collection, of IoTProperty elements of an entity identified by the URI in the request.
  5. ArrayOfStateObservations – A list, or collection, of IoTStateObservation elements of a property of an entity, identified by the URI in the request

Each level is represented as a root element in the corresponding XML document and is described in detail below. Note that IoTProperty will also be present as a child element to IoTEntity.

Element: IoTEntity

Entity objects are represented by IoTEntity elements with the following content model:

Figure: The IoTEntity content model

The IoTEntity is using a set of RDFa attributes @about, @prefix, @xml:base and @typeof where all attributes except @xml:base are required. The @about attribute MUST be used for providing a globally unique identifier of the entity. See the RDFa in LinkSmart section for general usage guidelines for RDFa attributes.

The optional Name and Description elements can be used to provide human readable descriptions of the entity. They are not intended to hold any machine interpretable data.

The optional and repeatable Meta element can be used to record any additional metadata about an entity. The type of metadata MUST be recorded using the RDFa attribute @property.

The repeatable IoTProperty element represents all properties of the entity, its content model is described below.

Finally, the content of an IoTEntity is open for extension by any other element provided that it is defined within an namespace that differs from the target namespace of the IoTEntity schema.

Element: IoTProperty

The IoTProperty element describes a particular property of an entity in an IoT system, including both metadata and often actual observations of state conditions, data values or measurements.

Figure: The IoTProperty content model

Similar to the IoTEntity, also IoTProperty is using the same set of RDFa attributes @about, @prefix, @xml:base and @typeof.

The @about attribute MUST be used for providing a unique identifier of the property within the scope of its parent entity, i.e. the id space for properties is locally scoped in contrast to the IoTEntity id space that should provide globally unique identifiers. The concatenation of IoTEntity and IoTProperty identifiers will then together form a globally unique identifier of the property.

The @prefix attribute is optional but MUST be used to define any CURIE prefix used by any child element of IoTProperty and not defined by any other @prefix attribute of the parent IoTEntity element.

The IoTProperty element does also include an optional @datatype attribute that SHOULD be used to record the datatype of the data value of the property recorded within the child IoTStateObservation/Value element. It is RECOMMENDED to use XML Schema datatypes such as ‘xs:datetime’ where the prefix ‘xs’ must be defined using the @prefix attribute.

See the RDFa in LinkSmart section for general usage guidelines for RDFa attributes.

The optional Name and Description elements can be used to provide human readable descriptions of the property. They are not intended to hold any machine interpretable data.

The optional UnitOfMeasure element can be used to record the unit of measurement for the data value provided in the child IoTStateObservation/Value element, such as “kW” or “ppm”. The type of data MUST be recorded using the RDFa attribute @typeof.

The optional and repeatable Meta element can be used to record any additional metadata about an entity. The type of metadata MUST be recorded using the RDFa attribute @property.

The values of the property, a time-series based data set is represented by the optional and repeatable IoTStateObservation element, that includes the Value element recording the data as a string,  and time stamps for both PhenomenonTime and ResultTime (see Glossary for definition of these terms). Also IoTStateObservation includes an optional extension point that can hold additional complex data structures representing property values using elements from another namespace than used as target namsespace by the IoTEntity schema.

Finally, the content of an IoTProperty is open for extension by any other element provided that it is defined within an namespace that differs from the target namespace of the IoTEntity schema.

Example: A Farm Field entity

An example of a Farm Field entity is provided below. The entity has two properties temperature and humidity which are measured regularly and reported to the Storage Manager

iotentityXMLexample

The IoTEntity default namespace is declared on the root element to ‘http://linksmart.org/IoTEntity/1.0’.  The globally unique identifier for the entity is provided in the @about attribute as “D77EC6B0F0394734925E0A90CE7D1B5B018671A3”.

The entity is typed as a ‘Farm Field’ referencing an ontology via the prefix ‘cnet’ using the CURIE notation. The prefix ‘clafis’ is defined using the @prefix attribute to the URI ‘http://ns.cnet.se/ontologies’.

The two properties have locally scoped identifiers recorded in the @about attributes, ‘Temperature’ and “Humidity”. Both properties are also typed, referencing the previously defined ‘clafis’ prefix,  using the @typeof attribute. The datatypes of the property values are recorded in the @datatype attributes referencing XML Schema datatypes via the ‘xs’ prefix.

The ‘Temperature’ property use the UnitOfMeasurement element to record the unit of the value, “C”. The @typeof attribute is used to reference a type system, again using a “clafis:UoM”.

Finally, the data values and associated phenomenom and result times for the two properties are provided within IoTStateObservation elements.

Collections of objects – The arrays

Lists, or collections, of objects are provided within a wrapper element at the root level.

Each collection wrapper can have an arbitrary number of child elements of the specific type. The wrappers do not have any additional elements or attributes.

 

Retrieving IoTEntity Data

It is possible to access IoTEntity properties via a RESTful API. The REST interface provides a data-oriented interface for the IoTEntity that enhances usability for some types of clients including end-user browser access.

Access to the latest status and other property values of an IoTEntity is provided using GET request method over HTTP. Similarly, new entities, properties and state observation values can be added using the POST request method. The PUT request method is used for setting property values, and is thus an enabler for control actions. For these update functions see Updating IoTEntity Data REST.

Object identification – the URI structure

The URI structure for identification of resources follows the model described in IoTEntity – Content Model. The full URI template use a combination of collection names and instance identifiers in the following way:

{base}/IoTEntities/{IoTEntityID}/properties/{IoTPropertyID}/observations

“IoTEntities”, “properties” and “observations” denotes collections on the respective levels. Explicitly naming collections and types in the URI is helpful to make the semantics of the service clear to both developers and users.

Retrieving data – The GET request method

The GET method will, depending on if the URI identifies a collection or a resource, retrieve all resources in a collection or a single resource. The URI can be cut on all levels, enabling addressing components and collections on all levels. The full URI as expressed above used in a GET request would return a collection of IoTStateObservation elements for the property “IoTPropertyID” within the “IoTEntityID” entity. The following shortened URI would accordingly return a collection of all properties for the “IoTEntityID” entity:

{base}/IoTEntities/{IoTEntityID}/properties

Below is a complete list of what is returned when the corresponding URI is used in a GET request:

{base}/IoTEntities

Returns a collection of all IoTEntities within the scope of the {base}. These will be wrapped in the parent element ArrayOfIoTEntity.

The collection supports filters based on query string parameters in the following way:

?take=x : include up to x IoTEntities in the collection. Not supplying this parameter may result in an implicit limit set by the interface implementation (e.g. 500 elements) to enhance responsiveness.

?skip=x : given the other filter parameters and ordering, skip the first x elements in the collection. The parameter take will be applied to the subsequent elements.

?after=x : all elements after this xsd:dateTime. In the case of IoTEntity, this applies to creation date.

?before=x : all elements beforethis xsd:dateTime. In the case of IoTEntity, this applies to creation date.

?like=x : include all IoTEntities with the substring ‘x’ in the @about value (the identifier of the IoTEntity) or in the Name element. x is a regular expression which will be evaluated with the case-insensitive flag set.

{base}/IoTEntities/{IoTEntityID}

Returns the IoTEntity identified by {IoTEntityId}. The @about attribute will be equal to {IoTEntityId}.

{base}/IoTEntities/{IoTEntityID}/properties

Returns a collection of all IoTProperties for the  IoTEntity identified by {IoTEntityId}. These will be wrapped in the parent element ArrayOfIoTProperty.

{base}/IoTEntities/{IoTEntityID}/properties/{IoTPropertyID}

Returns the IoTProperty identified by {IoTEntityId} and {IoTPropertyID}. The @about attribute will be equal to {IoTPropertyId}.

{base}/IoTEntities/{IoTEntityID}/properties/{IoTPropertyID}/observations

Returns a collection of all IoTStateObservations identified by {IoTEntityId} and {IoTPropertyID}. These will be wrapped in the parent element ArrayOfIoTStateObservation. Default order is by descending PhenomenonTime, then ResultTime.

The collection supports filters based on query string parameters in the following way:

?take=x : include up to x elements in the collection. Not supplying this parameter may result in an implicit limit set by the interface implementation (e.g. 500 elements) to enhance responsiveness.

?skip=x : given the other filter parameters and ordering, skip the first x elements in the collection. The parameter take will be applied to the subsequent elements.

?after=x : all elements with PhenomenonTime after this xsd:dateTime.

?before=x : all elements with PhenomenonTime before this xsd:dateTime.

IoTEntity

An IoTEntity is a software representation a physical entity, e.g. a house, a car or a door. IoTEntity corresponds to the IoT-A concept of Virtual Entity. An IoTEntity has properties: a house may have indoor temperature and energy consumption, a door may be locked or unlocked and opened or closed. The state of these properties at different points in time – typically generated by an IoTResource connected to a physical sensor – are represented by IoTStateObservations.

State observations of an IoTEntity, typically readings or measurements, can be acquired by two different methods:

In both cases, a common content model for representations of IoTEntity objects is used. It is described in detail in:

Basic IoTConcepts

Linksmart.net provides a straightforward model for representing objects in the physical world and their properties and map them to software resources that allow control and reading of data about the physical objects. The three main concepts are IoTEntity, IoTResource and IoTWorld.

IoTEntity

The entity of interest for observations in an IoT system, the things in the physical world we want to observe and perform actions on. Examples of IoTEntity instances can be rooms, an household appliance or a person. The IoTEntities have properties that can be observed.

See also IoTEntity

IoTResource

IoTResources are software objects that provide IoT Services for applications and end-users for retrieving and analyzing data about the physical world as well as invoking actions like switching of a light. Some examples of IoTResources are software objects representing actuators, sensors, data streams, databases, et c.

See also IoTResource

IoTWorld

A subset of the physical world, a set of IoTEntities that belong together and the associated IoTResources for  observing and acting on this part of physical world. It could represent physical, functional or organizational units in some application domain. For instance you can model your house as one IoTWorld, or an office, a complete building or even a whole city, it depends on the need ofyour Application. The IoTWorld is accessed through a Linksmart .net software defined gateway.

An IoTWorld Gateway UI provides an user interface to an IoTWorld.