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

DTDL-Generalize messages with message types and related schemas #43

Open
jonmikeli opened this issue Dec 29, 2019 · 7 comments
Open

DTDL-Generalize messages with message types and related schemas #43

jonmikeli opened this issue Dec 29, 2019 · 7 comments

Comments

@jonmikeli
Copy link

Hi,

Is there any plan to generalize message types and replace the telemetry type by a generic message structure with, for instance:

  • messageType (ex: telemetry, error, system, etc)
  • messageSchema
  • messageSchemaVersion
    and allowing a device (or module) to send different types of messages.

Unless I have misunderstood something, this is not possible today.
I have been confronted with this need in different projects and it is actually quite useful.

@jonmikeli
Copy link
Author

I had missed the object type in the schema property of the telemetry type.

image

schema property values:

image

object type:

image

An example:

image

Source:
https://github.com/Azure/IoTPlugandPlay/tree/master/DTDL

I guess this should allow sending "messages" of different types through telemetry.

Any plan to add JSON schema references to the object type (ideally with the schema version)?

@briancr-ms
Copy link
Member

Yes, the intention of DTDL's telemetry is to enable messages of nearly any type to be defined. These could be telemetry messages that contain measurements sent every minute, like temperature and humidity. These could be telemetry messages that are sent only when an event occurs, like when a door opens or an error occurs.

We hadn't planned on adding JSON Schema support, but can you elaborate more on what you're thinking, perhaps with an example?

@jonmikeli
Copy link
Author

Thanks @briancr-ms.
Sure, no problem to elaborate.

The idea behind my question was to control the structure of incoming messages and only accept in the system the valid ones (in terms of schema and allowed values, if specified in the schema).
It adds consistency to the whole solution and minimizes the data being stored and going through the processes in the solution.

I have coded that feature with Azure Functions in many projects and it surprised me how useful it has been. If you need code examples I can send you a few (I am also cleaning a private repository to publish it and it will contain the mentioned feature with many others).

@briancr-ms
Copy link
Member

I understand the value of validating incoming messages based on the DTDL telemetry definitions. The intention of DTDL is to capture enough information so that validators like you suggest can be built. In general, it should be possible to generate a JSON Schema from a DTDL definition.

@ahernandez-allegion
Copy link

ahernandez-allegion commented Jan 20, 2021

@jonmikeli @briancr-ms

I completely agree with this initiative. I believe Telemetry should be a semantic variation on the fundamental capability of a Message. Furthermore, Event should be another semantic type of a Message capability.

There are huge fundamental differences between Telemetry, Events, and Messages. Telemetry can be dropped. Events cannot. An Event can be Telemetry. Telemetry is not necessarily an Event.

There are also significant temporal differences around timestamping, which is also what differentiates a basic Message from the other two (Messages don't necessarily have a time component).

Replacing Telemetry with a more fundamental Message (or Event) type and adding Telemetry and Event would also be more inline with other DSLs:

https://www.w3.org/TR/wot-thing-description/#thing
https://www.eclipse.org/ditto/basic-feature.html
https://webthings.io/schemas/
https://docs.aws.amazon.com/thingsgraph/latest/ug/iot-tg-models-tdm-core.html

See also:

#20
#10

@jrdouceur
Copy link
Collaborator

I realize that this is a rather old discussion, but in case it is still relevant....

The idea behind my question was to control the structure of incoming messages and only accept in the system the valid ones (in terms of schema and allowed values, if specified in the schema).

The latest DTDL parser provides support for this type of validation. There is a tutorial that illustrates the feature.

@jonmikeli
Copy link
Author

Hi @jrdouceur ,

Thanks for the update. I read about the Parsing/Validation feature some time ago, which is great. At that time, DTDL v2 had some limitations in terms of what could be defined (and how). I need to assess again all this with DTDL v3.

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