WebThingsIO / api

Web Thing API Specification
http://iot.mozilla.org/wot/
Other
164 stars 24 forks source link

Support for multiple @context (aka support for Linked Data) #157

Open Martinocom opened 3 years ago

Martinocom commented 3 years ago

The status

The W3C standard for the Thing Description, as of the status on 06/01/2021, describe that it is possible to use multiple context value, passing an array of values.

"@context": [
  "https://www.w3.org/2019/wot/td/v1", {
    "v": "http://www.example.org/versioningTerms#",
    "saref": "https://w3id.org/saref#",
    "om": "http://www.ontology-of-units-of-measure.org/resource/om-2/"
   }
]

Specification can be found in 5.3.1.1 - Thing . An example of this can be found here and here.

The problems

  1. Specification of the WebThing API is different from the official recommendation of W3C, but is very simple to read and understand: please keep it simple!

  2. This project (like others linked in the official source) has a hard-coded @context to "https://iot.mozilla.org/schemas" that is also no more maintained and prompt to switch into the "https://webthings.io/schemas/". The site says:

    Note: This document is no longer maintained and has been replaced by a new specification at webthings.io/schemas.

  3. As a student of University of Bologna I'm doing a small research about WoT and Linked Data. Giving me the possibility to utilize more @context in the Thing Description opens a standardized way to describe ALL the data I have inside a Thing, but this is not possible due this limitation. I cannot indicate more @context and I'm forced to do all referenced to the hard-coded "https://iot.mozilla.org/schemas" that allows me to use only that one hard-coded (not supported) ontology.

To point out better, the Example 28 is NOT compatible with WebThings API, since implements more than one @context.

Without this ability, I'm not able to proceed in my project: I need to contextualize my data in ontologies like SAREF, IoT-Lite, IoT-S and even the less significant ones like ontology-of-units-of-measure or DBpedia to give more opportunities to get ALL the possible data of the system. Why? With that many knowledge it's possible to understand the system, where the things are, and try to create actions that was not originally planned, but can be achieved mixing behaviors of different things.

I don't know if it's planned or not, but I really need this feature. If not, I'm planning to "wrap" the requested Thing Description into a bigger one with all the ontologies I need to use, and then indicate for the WebThing library the "minimized" version of it.

mrstegeman commented 3 years ago

(Moved from webthing-java repo)

@Martinocom I've fixed your second point via https://github.com/WebThingsIO/webthing-java/commit/14ea1c717180ae6b18da4685188a9e2e8c7000b1

benfrancis commented 3 years ago

@Martinocom Is the issue that you need to expose multiple contexts in the Thing Description, or that you need to consume multiple contexts from the Thing Description? I'm assuming it's the former given you originally filed this issue on the Java web thing library. Consuming multiple contexts using the WebThings Gateway's web thing adapter probably doesn't emit an error, but isn't explicitly supported yet.

This is one of the many differences between the Mozilla and W3C specifications that I intend to fix in a future version, potentially later this year, but I'm afraid it's going to take a long time to make these changes across all the WebThings libraries and gateway.

@mrstegeman In the meantime is there an easy way for Marcin to override the @context of a thing using the Java web thing library so that Marcin can add this feature for specific devices?

mrstegeman commented 3 years ago

@mrstegeman In the meantime is there an easy way for Marcin to override the @context of a thing using the Java web thing library so that Marcin can add this feature for specific devices?

No, it's hard-coded to use our schema URL.

Martinocom commented 3 years ago

If can be useful for someone, I made some researches about current libraries and what they can achieve. I still think that WebThings has the bigger potential (also 'cos I wanted to use some Kotlin to develop my apps), but for my purposes, as said, I cannot have one hardcoded URL for schema. Alternatives that I found are:

I switched currently on ThingWeb and I'm figuring out how use a raw REST API for it.