2

I want to use Schema.org (with JSON-LD) to label the value in the temperature sensor / to describe the temperature attribute (unit).

I can not find an explanation of the temperature at Schema.org. I get the sensor value through MQTT, here is the data output by MQTT.

{
  "@context": "http://example/temperature.jsonld",
  "_UTC_timestamp": "2017-11-18 08:56:51",
  "temperature": 25.12
}

 

<script type="application/ld+json"> 
"@context": {
  "Thing": "@type",
  "CreativeWork": "@subtype",
  "Thing": [{
      "name": "temperature",
      "@type": "number",
      "@value": "CreativeWork"
      "minimum": 0,
      "maximum": 80,
      "description": "a physical quantity that expresses the subjective perceptions of hot and cold",
      "url": "https://en.wikipedia.org/wiki/Temperature",
      "unit": "Celsius",
      CreativeWork[{
          "name": "measure temperature",
          "description": "Get the sensor temperature value" ,
          "Celsius" "https://en.wikipedia.org/wiki/Celsius"
          "link": [{
              "href": "http://iwilr3-3.campus.fhludwigshafen.de/iotsemantic/tinkerforge/temperature.jsonld"
            }
          ]
        }
      ]
    }
  ]
}
</script>
Sirko
  • 72,589
  • 19
  • 149
  • 183
jiki
  • 25
  • 1
  • 9
  • 1
    You might be interested in [IoT and Schema.org: Getting Started](https://iot.schema.org/docs/iot-gettingstarted.html) ("Schema.org […] does not yet, however, have much support for the kind of data coming from IoT sensors - e.g. date/time stamped temperature measurements.") – unor Nov 17 '17 at 20:46
  • 1
    JSON-LD is just a syntax. You need a vocabulary to use it. You could of course create your own vocabulary, but then you can’t expect that others make use of it. So typically you’ll want to use an existing vocabulary. Schema.org is a popular one, but there are many more. -- It depends on your use case. – unor Nov 17 '17 at 21:13
  • But I didn't find the vocabulary temperature in Schema.org. In fact my case is to measure the room temperature. @unor – jiki Nov 17 '17 at 21:25
  • You measure the temperature, represent it with JSON-LD, and then what? Should others read/consume your JSON-LD, or are you (and your tools) the only consumer of the data? – unor Nov 17 '17 at 21:36
  • Actually, should others can also read it. How to create vocabulary about temperature? Can you tell me about other thesaurus like Schema.org? thank you @unor – jiki Nov 17 '17 at 21:53
  • temperature is defined by other vocabs. Create a `@Thing`, use the temperature IRI for additionalType, then uses the appropriate `@CreativeWork` subtype to add detail where `@Thing` is mainEntityOfPage. – Jay Gray Nov 17 '17 at 22:14
  • Could you please write this code? @Jay Gray – jiki Nov 17 '17 at 22:34
  • make an effort and i'll help with your new markup. you'll need `@Thing` the appropriate subtype for `@CreativeWork` and then link `@Thing` to `@CW` – Jay Gray Nov 18 '17 at 13:31
  • @Jay Gray Can you correct the new markup for me? thank you. – jiki Nov 18 '17 at 17:44

1 Answers1

2

first, write out your statements (triples) in turtle format

@Dataset name              text
         dateCreated       @DateTime
         about             @Thing
         variableMeasured  @PropertyValue

@Thing   name              "sample from a sensor"
         mainEntityOfPage  @CreativeWork

@CreativeWork name         sample
              description  text about sampling

@PropertyValue value           @Number
               unitText        temperature
               valueReference  @PropertyValue

@PropertyValue unitCode  http://dbpedia.org/page/Celsius
               unitText  celsius

then you compose the statements as a graph

Here is your @Graph of the @Types and their properties

{
"@graph": [
    {
    "@type": "Dataset",
    "@id": "DFI-1",
    "name": "label you use for the Dataset",
    "dateCreated": "2017-11-19T:04:30:40+06:00",
    "about":
        {
        "@type": "Thing",
        "@id": "Thing-1"
        },
    "variableMeasured":
        {
        "@type": "PropertyValue",
        "@id": "PV-1"
        }
    },
    {
    "@type": "Thing",
    "@id": "Thing-1",
    "name": "sample from a sensor",
    "mainEntityOfPage":
        {
        "@type": "CreativeWork",
        "@id": "CW-1"
        }
    },
    {
    "@type": "CreativeWork",
    "@id": "CW-1",
    "name": "label you use for the creative work to describe Thing-1",
    "description": "Thing-1 documentation"
    },
    {
    "@type": "PropertyValue",
    "@id": "PV-1",
    "name": "temperature",
    "value": "10",
    "valueReference": 
        {
        "@type": "PropertyValue",
        "@id": "PV-2"
        }
    },
    {
    "@type": "PropertyValue",
    "@id": "PV-2",
    "unitCode": "http://dbpedia.org/page/Celsius",
    "unitText": "celsius"
    }
],
"@context": "http://schema.org/"
}

Check it here GSDTT

Jay Gray
  • 1,706
  • 2
  • 20
  • 36
  • How to make automatic semantic annotation of temperature? If the data acquired by URL. Is it possible to get the temperature value from the URL using php $ Get? @Jay Gray thank you. – jiki Nov 21 '17 at 07:56
  • not quite sure what you are asking. however, in any solution, you will need to generate an `RDF` item that represents the data at a point-in-time. Of course, your `RDF` item is represented in JSON-LD format, not XML. WRT `GET` - I am not `PHP` literate. But a general purpose `GET` using `SPARQL` will enable you to fetch data from an endpoint. – Jay Gray Nov 21 '17 at 13:09
  • The current temperature data is written by us manually, for example "value": "10". I want to get the temperature value from the URL and write it automatically in JSON-LD, for example "value": "12 (Auto Write)". Is this possible? @Jay Gray thank you. – jiki Nov 21 '17 at 14:40
  • if i understand correctly, your gonna need another program to do that for you. we use mustache to do this kind of work. the JSON-LD is in a mustache template and reads the value from a source. the mustache {{}} can be in the JSON-LD, but you'll need a mustache processor to read the data from the source. Look at Google AMP for examples; see amp-list and amp-mustache. – Jay Gray Nov 21 '17 at 20:24
  • Your first part of the answer can be saved as JSON-LD format, such as "graph1.jsonld". "compose the statements as a graph" can be written as in graph1.jsonld @Jay Gray thank you – jiki Nov 22 '17 at 16:16
  • If URL is "@context":"http://iwilr3-3.campus.fhludwigshafen.de/iotsemantic/tinkerforge/temperature.jsonld","_UTC_timestamp":"2017-11-18 08:56:51","temperature":25.12. How to put the temperature(25.12) value automatically in "temperature.jsonld". @Jay Gray thank you – jiki Nov 23 '17 at 08:49
  • your gonna need another processor. per above, we use mustache to do what you need. you can see mustache at work at Google AMP. you don't need AMP, but you have to use mustache.js as the processor to inject data into your JSON-LD. there may be other ways to inject, but mustache is what we know and love. – Jay Gray Nov 23 '17 at 15:36
  • I know how to write mustasche.js but I don't know how to handle the connection between mustache.js and temperature.jsonld. Could you please show me an example? I have to hand over my project tomorrow. @Jay Gray thank you – jiki Nov 23 '17 at 16:17
  • See this thread: https://github.com/ampproject/amphtml/issues/3554. Change the example from JSON to JSON-LD. Your `{{variable}}` will be the source data. The result can be saved to a file and timestamped for that time-specific sample. With AMP, use `` and ``. If plain HTML, use mustache.js. In both cases the syntax is identical. – Jay Gray Nov 24 '17 at 11:06