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

observeallproperties and unobserveallproperties clarification #1084

Closed
egekorkan opened this issue Mar 29, 2021 · 6 comments
Closed

observeallproperties and unobserveallproperties clarification #1084

egekorkan opened this issue Mar 29, 2021 · 6 comments

Comments

@egekorkan
Copy link
Contributor

While working on the PR for #1074 and the discussion on #1082 made me think of the meaning behind observeallproperties and unobserveallproperties. Actually, there is literally no text explaining what these operations do, all we can do is wishful thinking.

@sebastiankb said in the last F2F that observeallproperties returns all the property values when one property value changes, whether the rest are changed or not. At the time, I didn't think too much about it but now that I do, it does not make sense. If a Consumer gets all property values, it needs to find out which ones have changed and at that point, it becomes no different than readallproperties (I think it is even worse in this case). So the TF needs to agree what is the behavior behind this operation.

Also, this issue should raise awareness that we are putting new features into the spec that has no clear way of implementing them. Additionally, there is no implementation of this, raising further concerns in my opinion.

See also: eclipse-thingweb/node-wot#405 and w3c/wot-scripting-api#312

@sebastiankb
Copy link
Contributor

Sure, a delta-based approach would be more efficient. However, this is kind of a new little sub-protocol that needs to be defined somewhere. Maybe this is also a topic for the WoT Profile?

@danielpeintner
Copy link
Contributor

I can see pros for both approaches.

Does it make sense to have a way to indicate in a TD whether observeallproperties returns all properties or just the ones that have been changed?

@benfrancis
Copy link
Member

I suggest that observeallproperties should only push the values of properties which have changed, not all properties. Pushing the values of all properties just adds an unnecessary extra step for the Consumer to figure out which properties changed. If a Consumer wants to get the current values of all properties they can use readallproperties.

The specification does say:

The data schema for each of these meta-interactions is constructed by combining the data schemas of each PropertyAffordance instance in a single ObjectSchema instance, where the properties Map of the ObjectSchema instance contains each data schema of the PropertyAffordances identified by the name of the corresponding PropertyAffordances instance.

So my assumption is that for a property with a type of boolean, the payload of an observeallproperties notification would look something like:

{
  "on": true
}

This tells you which property has changed and what it's new value is. I also think it it would be reasonable for a Web Thing to batch together multiple property changes into a single message.

I agree it's really not clear from the specification how this operation is expected to work beyond that, it will vary a lot depending on protocol.

WebThings doesn't currently implement observeallproperties (since it doesn't use Forms or op yet at all), but the WebSocket sub-protocol does define a propertyStatus message type which pushes property changes to the client. (For covenience the implementation also sends a propertyStatus message with the current values of all properties when a client first opens the WebSocket, but after that only sends messages when something changes.) This sub-protocol probably couldn't be described in a Thing Description since there is no way to describe WebSocket messages (it will instead have to rely on the subprotocol member to refer to an external specification), but I can imagine something similar being implemented using another mechanism like Server Sent Events which might be possible to describe in a Thing Description.

For the Core Profile we will need to decide on a default mechanism for observe operations (if they are supported) using HTTP, which might help excercise this feature.

@egekorkan
Copy link
Contributor Author

I also like sending only the ones who have changed. If I need to sort the changed values somehow, I would prefer doing single observe operations. Regarding whether this is a subprotocol or not, I think that sending all values is also a subprotocol, we are prescribing how something should happen.

In WebThings, I would say that there is observeallproperties just that it is not called like that. In MQTT, only the changed values would be pushed as well. I don't know why would someone build a Thing that push all values when just a single one changes.

@egekorkan
Copy link
Contributor Author

PR by @benfrancis at w3c/wot-architecture#605 says that only updated values should be sent. I would propose closing it here since the decision will be made at architecture specification.

@egekorkan
Copy link
Contributor Author

In the call of 21.07 we have decided to close this issue. Objections to the meaning of this operation should be done at the w3c/wot-architecture#605

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants