Skip to content

API Descriptions: Lamp

Alexey Andreyev edited this page Oct 14, 2016 · 29 revisions

Below bodies of responses to requests to the given URLs are presented, including the .well-known/core URL.

API Documentation

Response to GET http://external/doc

{
  "@context": [
    "https://w3id.org/semiot/device/commoncontext#",
    { "doc": "http://external/doc#" }
  ],
  "@id": "doc:ApiDocumentation",
  "@type": "ApiDocumentation",
  "supportedClass": [
    {
      "@id": "doc:LampDevice",
      "subClassOf": "Device",
      "supportedProperty": [{
        "property": "location",
        "writable": "true",
        "label": { "@value": "Location", "@language": "en" }
      },
      {
        "property": "label",
        "writable": "false",
        "label": { "@value": "Label", "@language": "en" }
      }],
      "supportedOperation": {
        "method": "PUT",
        "expects": "doc:LampDevice",
        "returns": "doc:LampDevice"
      }
    },
    {
      "@id": "doc:shineAction",
      "@type": "Link",
      "range": "ControlAction",
      "supportedOperation": [{
        "method": "GET",
        "returns": "ControlAction"
      },
      {
        "method": "POST",
        "expects": "doc:TurnOnAction"
      },
      {
        "method": "POST",
        "expects": "doc:TurnOffAction"
      }]
    },
    {
      "@id": "doc:TurnOnAction",
      "subClassOf": "ControlAction",
      "label": { "@value": "Turn on", "@language": "en" },
      "supportedProperty": {
        "@type": "PropertyValueSpecification",
        "property": "doc:brightness",
        "label": { "@value": "Brightness", "@language": "en" },
        "valueRequired": false,
        "defaultValue": 50.0,
        "minValue": 0.0,
        "maxValue": 100.0
      }
    },
    {
      "@id": "doc:TurnOffAction",
      "subClassOf": "ControlAction",
      "label": { "@value": "Turn off", "@language": "en" }
    },
    {
      "@id": "doc:LampConfiguration",
      "subClassOf": "DeviceConfiguration",
      "supportedProperty": [
        {
          "label": "Wi-Fi Name",
          "property": "doc:wifiName",
          "valueRequired": true,
          "writable": true
        },
        {
          "label": "Wi-Fi Password",
          "property": "doc:wifiPassword",
          "valueRequired": true,
          "writable": true
        },
        {
          "label": "Auth username",
          "property": "doc:username",
          "valueRequired": true,
          "writable": true
        },
        {
          "label": "Auth password",
          "property": "doc:password",
          "valueRequired": true,
          "writable": true
        },
        {
          "label": "Device Name",
          "property": "doc:deviceName",
          "valueRequired": true,
          "writable": true
        }
      ]
    }
  ]
}

Public API

Response to GET /.well-known/core

  • /
    • rt = http://schema.org/EntryPoint

Response to GET /

{
  "@context": "http://external/doc#",
  "@id": "coap://1.1.1.1/",
  "@type": "LampDevice",
  "label": { "@value": "Lamp #1010", "@language": "en" }
  "identifier": "e9704",
  "location": {
    "@type": "Place",
    "label": "1010"
  },
  "shineAction": "/shine"
}

PUT Request to /

{
  "@context": "http://external/doc#",
  "@type": "LampDevice",
  "location": {
    "@type": "Place",
    "label": "301"
  }
}

Response to GET /shine

{
  "@context": "http://external/doc#",
  "@type": "TurnOff",
  "actionStatus": "CompletedActionStatus"
}
{
  "@context": "http://external/doc#",
  "@type": "TurnOn",
  "actionStatus": "CompletedActionStatus",
  "brightness": 73
}

PUT Request to /shine

{
  "@context": "http://external/doc#",
  "@type": "TurnOffAction"
}
{
  "@context": "http://external/doc#",
  "@type": "TurnOnAction",
  "brightness": 73
}

Configuration API

Response to GET /config

{
  "@context": "http://external/doc#",
  "@id": "/config",
  "@type": "Configuration",
  "wifiName": "ISST",
  "wifiPassword": "ISSTpassword",
  "username": "superuser",
  "password": "strongpass",
  "deviceName": "My Device"
}

Clone this wiki locally