Hi
Can anyone please explain the use cases for Property, Action and Event. I Don’t see any difference on them. How are they supposed to be used ?
Hi
Can anyone please explain the use cases for Property, Action and Event. I Don’t see any difference on them. How are they supposed to be used ?
The are very much different things.
An action is something that can be triggered on a device.
An event is something the device reports as happening (so can not be triggered from the outside).
A property is a stateful field, which reflects a “property” of the device. If that state changes, the state is reflected in the API (resp. the gateway). If the property isn’t read only, the value of the property can be changed from the outside.
So they’re pretty much the common meaning of those terms, “property”, “action” and “event” in the eyes of the device/thing.
Our Web Thing API specification describes them as follows:
I understand what you are saying ( and actually have read it …)
But still everthing can be achieved using a property.
Looking at it from this point of view makes actions and events quite unnecessary. It is possible to solve everything with a property. Matter of fact, webthing-arduino haven’t even implemented action and events.
So, this said, Are the gateway treating Properties, Actions and Events in different ways ?
A property has a persistent value, neither actions nor events have a persistent value, that’s the big reason why they’re not just properties. If you look at the API actions and events are very similar to properties, just cut down to what you need for those use cases.
I agree that it can sometimes be difficult to decide when to use a property, action or event. We’ve tried to provide some guidelines in the spec, but it can still be unclear. For example iotschema.org specify a lot of actions for setting properties and events for reporting property changes which both seem redundant to me.
While it’s true that you can hack around most use cases just using properties, there are cases where actions or events are a more natural fit (e.g. actions which take time to complete or accept arguments or events which report an exception case or threshold of some kind).
Note that the data model of properties, actions and events is not something Mozilla defined - it comes from the W3C Thing Description specification which has been agreed upon by members of the W3C WoT Working Group.
Everything is “hackable”
If the gateway supports properties, action and events with its visual behavior it would be more understandable.
For example:
If “fade” action is invoked from gateway, the “bubble” blinks until the fade process is finished.
or…
if a “overheated” event is sent from the gateway, the “bubble” gets a red background.
The gateway does support all of these things. Actions and properties render differently. Actions are just a button. And events are shown as toast notifications and logged in an event log.
Properties and actions:
Event log:
Perfect, but where are this documented ?
I’ve seen nothing about it, but maybe I am a poor reader ??
I don’t think there’s full documentation of what the gateway does, which is understandable given that it’s just an experiment. The best way to learn about the gateway is to try it yourself.
The gateway also isn’t the only way one could consume the WoT API.
Try what ?
If you don’t know it exists, how are you supposed to try it out ?
Anyhow, I think the best way to success is to have good documentation so you get many followers. But that’s my view.
The gateway.
The entry point to the whole IoT project, https://iot.mozilla.org/ prominently features the gateway and how to install it.