WebThingsIO / api

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

Define which members are mandatory vs. optional #135

Open dravenk opened 5 years ago

dravenk commented 5 years ago

I finished reading Web Thing API , but anyway, I've read WoT Capability Schemas, but did not find any RFC file definition of property resource.
I see this discussion Actions vs. Properties #4 and this answer.

Fair enough. You could represent that state with two booleans (as you have) or with an integer (0, 1, 2, 3) or a string "on", "of", "turningOn", "turningOff".

This would make it impossible for me to define exactly and use a property resource.

benfrancis commented 5 years ago

The Web Thing API specification provides a definition for the Property object which describes a property in the Thing Descriptiona and the Property resource which is part of the REST API.

What exactly is it that you want to know?

dravenk commented 5 years ago

I just want a definition of the Property of the RFC documents, such as https://tools.ietf.org/html/rfc5988 . Because it will use key words "MUST", "MUST NOT", "REQUIRED"... More accurately inform what implementations need to be done.
Property object not describing exactly what must be implemented. For example, an OnOffProperty does not require A minimum and maximum (numeric values), but LevelProperty does.

benfrancis commented 5 years ago

@dravenk I'm afraid the unofficial specification we maintain at https://iot.mozilla.org/wot does not yet have these kinds of formal definitions like an IETF RFC might have, although we should probably at least specify which members are mandatory (I've updated the title of this issue to reflect that).

The W3C maintain a more formal specification for a Thing Description at https://www.w3.org/TR/wot-thing-description/ although this does not exactly match what Mozilla WebThings implements as the specification is still evolving.

dravenk commented 5 years ago

@benfrancis Hi, I wonder whether the description of OnOffProperty definition is An OnOffProperty is like a BooleanProperty, but with the added semantics that true means "on" and false means "off"., is description right? But, there is another description Whether the lamp is turned on of OnOffProperty.

I have some predefined Thing property, whether I should be in accordance with the predefined description, for instance: OnOffPropertyAn OnOffProperty is like a BooleanProperty, but with the added semantics that true means "on" and false means "off".?


{ "@context": "https://iot.mozilla.org/schemas/",
  "@type": ["Light", "OnOffSwitch"],
  "name":"My Lamp",
  "description": "A web connected lamp"
}

Are the @type is Capabilities in the example code? Light contains OnOffProperty, while OnOffSwitch contains only OnOffProperty. Is the @type of example repeated? Should I use Capabilities as the definition of the Thing bundle? If some Thing bundles are predefined in this way, they will not be both Light and OnOffSwitch. for example:


* Light // Capabilities as the bundle of Thing
    - Lamp A // The instance
    - Lamp B // The instance
* OnOffSwitch // Capabilities as the bundle of Thing
    - Switch A // The instance
    - Switch B // The instance
benfrancis commented 5 years ago

@dravenk Sorry but I'm struggling to understand your questions, which don't seem related to the topic of this issue.

@type is an optional semantic annotation in a Thing Description to give a client more information about a device, using schemas like those defined in our schema repository. A property can have multiple @types if it conforms to multiple schemas (e.g. a door sensor may fit both the BinarySensor and DoorSensor capabilities). These are really just hints to help a client provide users with a meaningful user interface or for the purpose of automation.

OnOffProperty is a semantic annotation in our schema repository which can be provided as a @type in a Property object of a Thing Description to tell a client that a boolean property represents an on/off state where true is on and false is off.

The optional description field in a Property object can be set to any string by the author of the Thing Description and is specific to an individual device.

I'm not sure what you mean by Thing bundle.

dravenk commented 5 years ago

@benfrancis Thank you. I did more research and found a good point to deal with the question of whether to pre-define the Thing bundle. https://github.com/mozilla-iot/wot/issues/56#

We're also finding that defining web thing types at just the thing level is too inflexible. Through the W3C we are investigating standardising "capabilities"