Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op does not have with default tag anymore #1192

Open
egekorkan opened this issue Jul 14, 2021 · 5 comments
Open

op does not have with default tag anymore #1192

egekorkan opened this issue Jul 14, 2021 · 5 comments
Labels
Defer to TD 2.0 Has Use Case Potential The use case can be extracted and explained

Comments

@egekorkan
Copy link
Contributor

egekorkan commented Jul 14, 2021

The REC version has the with default assignment for the op in the forms (see screenshot below).

image

However, the editor spec says optional (see below) which means that it can be totally omitted. This is a bug in my opinion.

image

@sebastiankb sebastiankb self-assigned this Jul 28, 2021
@sebastiankb
Copy link
Contributor

thanks for the pointer. I will fix this in the next update

@benfrancis
Copy link
Member

I would personally prefer to keep this "bug". See #878.

@sebastiankb
Copy link
Contributor

issue solved

@benfrancis
Copy link
Member

benfrancis commented Nov 17, 2021

This change has created a blocker in making WebThings W3C compliant, as discussed in #878. Was that taken into account before merging #1262?

The issue lies with how to express a WebSocket endpoint in a Thing Description which is shared for all interaction affordances. Our conclusion from that discussion had been that we could provide a simple form for the top level WebSocket endpoint with no op member, with that endpoint being used for all operations on all affordances as defined in the "webthing" subprotocol.

  "forms": [
    {
      "href": "wss://foo.webthings.io/things/lamp",
      "subprotocol": "webthing"
    }
  ]

If op is no longer optional then this is no longer possible, unless #1070 is implemented instead, to allow all operation values in a top level form, e.g.

  "forms": [
    {
      "href": "wss://foo.webthings.io/things/lamp",
      "subprotocol": "webthing",
      "op": ["writeproperty", "invokeaction", "queryaction", "subscribeevent", "writeallproperties", "writemultipleproperties", "observeallproperties", "queryallactions", "subscribeallevents"]
    }
  ]

Without either op being optional or allowing all operation values Thing Descriptions become very verbose as the same WebSocket endpoint has to be duplicated in every interaction affordance. It also results in some quite awkward forms since the messages in the current WebSocket protocol don't all map neatly onto operations in this format. E.g.

{
  "@context": [
     "https://www.w3.org/2019/wot/td/v1",
     "https://webthings.io/schemas/"
  ],
  "@type": ["Light", "OnOffSwitch"],
  "id": "https://user1.webthings.io/things/lamp1/",
  "title": "My Lamp",
  "description": "A web connected lamp",
  "base": "https://user1.webthings.io/things/lamp1/",
  "securityDefinitions": { ... },
  "security": "oauth2",
  "properties": {
    "on": {
      "@type": "OnOffProperty",
      "type": "boolean",
      "title": "On/Off",
      "description": "Whether the lamp is turned on",
      "forms": [
        {
          "href": "properties/on"
        },
        {
          "href": "wss://user1.webthings.io/things/lamp1",
          "subprotocol": "webthing",
          "op": "writeproperty"
        }
      ],
    },
    "brightness" : {
      "@type": "BrightnessProperty",
      "type": "integer",
      "title": "Brightness",
      "description": "The level of light from 0-100",
      "minimum" : 0,
      "maximum" : 100,
      "forms": [
        {
          "href": "properties/brightness"
        },
        {
          "href": "wss://user1.webthings.io/things/lamp1",
          "subprotocol": "webthing",
          "op": "writeproperty"
        }
      ],
    }
  },
  "actions": {
    "fade": {
      "@type": "FadeAction",
      "title": "Fade",
      "description": "Fade the lamp to a given level",
      "input": {
        "type": "object",
        "properties": {
          "level": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "duration": {
            "type": "integer",
            "minimum": 0,
            "unit": "milliseconds"
          }
        }
      },
      "forms": [
        {
          "href": "actions/fade"
        },
        {
          "href": "wss://user1.webthings.io/things/lamp1",
          "subprotocol": "webthing",
          "op": ["invokeaction", "queryaction"]
        }
      ],
    }
  },
  "events": {
    "overheated": {
      "title": "Overheated",
      "@type": "OverheatedEvent",
      "data": {
        "type": "number",
        "unit": "degree celsius"
      },
      "description": "The lamp has exceeded its safe operating temperature",
      "forms": [
        {
          "href": "events/overheated",
          "subprotocol": "sse",
        },
        {
          "href": "wss://user1.webthings.io/things/lamp1",
          "subprotocol": "webthing",
          "op": "subscribeevent"
        }
      ],
    }
  },
  "forms": [
    {
      "op": "readallproperties"
      "href": "properties"
    },
    {
      "op": "queryallactions"
      "href": "actions"
    },
    {
      "op": "subscribeallevents",
      "href": "events",
      "subprotocol": "sse",
    },
    {
      "href": "wss://user1.webthings.io/things/lamp1",
      "subprotocol": "webthing",
      "op": ["writeallproperties", "writemultipleproperties", "observeallproperties", "queryallactions", "subscribeallevents"]
    }
  ],
  "links": [
    {
      "rel": "alternate",
      "type": "text/html",
      "href": ""
    }
  ]
}

In order to unblock us I can see 3 solutions:

  1. Make op optional again (i.e. reverse fix default value link for op #1262) - this would be the simplest
  2. Allow any operation value in a top level form (i.e. implement Allow more operations in a top level form #1070)
  3. We leave the WebSocket endpoints in WebThings as links rather than forms, which while technically a valid Thing Description is really a workaround and wouldn't be usable by most WoT Consumers (see example below, which is what we currently do)
  "links": [
    {
      "rel": "alternate",
      "href": "wss://foo.webthings.io/things/lamp"
    }
  ]

@lu-zero
Copy link
Contributor

lu-zero commented Jan 26, 2024

This is related to the whole protocol overhaul and a concrete use-case for connected protocols (websocket protocols)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defer to TD 2.0 Has Use Case Potential The use case can be extracted and explained
Projects
None yet
Development

No branches or pull requests

4 participants