-
Notifications
You must be signed in to change notification settings - Fork 231
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
Distinguish between "desired" and "twin" Feature properties #125
Comments
I played around with our existing concepts and scribbled a sequence diagram that shows a potential approach without yet extending the core of Eclipse Ditto but by accompanying it with a separate microservice that helps on the synchronization, i.e. creating a "patch" between desired and reported state. This approach is not based on revision numbers but on a second "copy" of state - called "Feature@desired" for each "Feature" of a Thing. This second Feature is is also fully managed within Ditto and also usable by applications. Devices/gateway have to do some "co-operation":
See my proposal: |
For use cases with more capable devices and not extremely limiting bandwidths to the devices the described approach above can be simplified without the need of a "patch" functionality: Use two Features for each element that has to distinguish between "reported" and "desired". Name the first one just "featureX" and the second one "featureX@desired". On device side, implement a re-connect mechanism that retrieves the The discussed issue here would then be an optimization that tries to save bandwidth and potentially also automates the process of sending the change to the device on each re-connect. But you could use this approach already for now without waiting for this issue. |
Based on the concepts implemented in Hono, it seems desirable for Ditto to be able to react to telemetry/event messages from devices that contain a time-till-disconnect property which is used in Hono to indicate that a device is online and willing to receive commands. Ditto could use this trigger to send pending patch/update command(s) to the device via Hono. If Ditto uses a request/response command for that purpose, it would also get notified about the outcome of processing the command on the device. |
We added an issue #492 in order to being able to reflect the Hono ttd information in Ditto's digital twins. With #492, IoT applications however can react on Hono's online indications and send a command down to the device themselves. |
As stated during the conf call last time, we are very much interested in this feature. @thjaeckle asked me to write down my thoughts about this. Here we go:
|
Thanks @BobClaerhout for your input. sub partsPart 1: Persisting "desired" state and providing API for that
Part 2: requesting a diff from twin/desired view
tbd:
Part 3: automated downlink delta for connected devicesCurrently I don't know if we even can or want support that to be honest - as mentioned in "Part 2" this does only make sense if the device says something about its currently known state .. and that way a automatic mechanism will never work out-of-the-box because it operates on outdated "reported" data of a connected device. Can we already agree on the used convention?Before we discuss that I would like to discuss and get the community's input on some alternatives we have. I will gladly enhance this list with community input. Implementation alternatives for Part 1
|
@thjaeckle I myself like the approach " We also observe a difference in sending desired states over live or twin channel. Let me give you my user story to clarify this. A user (through a frontend) or microservice wants to influence the device. It may do this through the digital twin or the live channel. There are (at least) two cases I can think of right now:
We solve the first case right now by using live messages, so we have a command/response API and are able to leverage timeouts and do the computation based on the methods (which might not refer to a single property per sé). Another solution would be to set properties over the live channel with a more limited API also resulting in a loss of the desired state if the device is offline (which is desired in this case). In the second case we want to set a desired state for properties, which will result in a success for this "correlation", but may fail when the state is applied. We then would have to emit an event message or something similar. I first thought, that another channel would be good to filter out only @Desired messages to reduce bandwith, but this could also be achieved via policies. A device may only have read on it's desired state properties but not on the actual ones having only write permissions on them. I think we can further make a distinction between desired state of configuration or status. A configuration@desired may be set directly and have or have no side effects. If a status is set however, this implies some more complex computation (maybe also configuration changes invoked by the device) to meet the desired status state. I'm just pointing this out right now, but I don't have any more ideas or thoughts on this at the moment. It's just fascinating :) Other Ideas
I really don't like the duplication of the last approach and it's error potentials around e.g. 'definition' and the vorto model. |
@thjaeckle When using vorto to define the twin schema, there seems to already be a logical split up between configuration/status/events/operations.
But maybe I'm missing something in my first steps in the world of Vorto ? |
@nicodeceulaer that would be correct if Ditto would always rely on Vorto's models. But that's not the case (a definition is completely optional and may also reference another type model), so we can't assume that there is a configuration section at all. I would like to completely leave the semantics of what is a property useful to have a desired state to the data modeler and applications using Ditto. |
It just came to my mind, that we could use approach 1 |
@w4tsn that sounds for me like choosing the worst stuff from approach 1 (problems with Vorto defintion, etc.) and 3 (much effort, duplication) :D What could also be another approach, which might be interesting for solving other problems as well: Managing metadata for scalar JSON fieldsIdea: add another "_meta" field which copies the JSON structure, but uses a Json object on the JSON leaves where additional meta information like modification timestamp, revision and desired state are located: {
"thingId": "org.eclipse.ditto:foo1",
"policyId": "org.eclipse.ditto:foo1",
"features": {
"lamp": {
"definition": [ "org.eclipse.ditto:Lamp:1.0.0" ],
"properties": {
"on": true
}
}
},
"_meta": {
"features": {
"lamp": {
"definition": {
"lastModified": "...",
"revision": 42
},
"properties": {
"on": {
"lastModified": "...",
"revision": 50,
"desired": false
}
}
}
}
} Just another idea which might come in very useful for other topics (e.g. updates based on the modification timestamp of a single value) as well .. |
We'll close this longly discussion about different formats/requirements, etc. and start over with #696 in order to track the overall concept. Issue #697 shall be the one I mentioned above being the Part 1: Persisting "desired" state and providing API for that. My last comment was already moved to another issue: #680 in which adding additional metadata for feature properties is tracked. |
In order to add another important Digital Twin feature to Ditto it requires to distinguish between different state perspectives.
We already have the "twin" and "live" perspective being an important differentiation between "cached state" and "actual live state".
However if a user wants to configure on a Digital Twin the desired state (e.g. "I want that this light is switched on") no matter if it is currently receiving the desired change or not, Ditto needs a place to store that.
I would suggest that
I would also like to propose to have a "common API" which handles the "twin/live/desired" under the hood.
E.g. that a user may trigger API calls in which she defines:
true
(first trying via "live", falling back to "desired" after a timeout when live doesn't answer in time)A device may retrieve the state is has still to apply in order to be "in sync" with the Digital Twin.
E.g.:
What is your opinion on that?
The text was updated successfully, but these errors were encountered: