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

Static property update adds a rogue 'mmsi' property to target path #1221

Closed
preeve9534 opened this issue Dec 22, 2020 · 1 comment
Closed

Comments

@preeve9534
Copy link

I have a plugin which maintains some paths and I want to add a meta value alongside the data path which describes the path value and its units. So, I want to use static property update.

Before the static update is executed the target key does not exist in the Signal K tree.

I generate a delta expressing the required static update.

var delta = {
  context: 'vessels.urn:mrn:imo:mmsi:235115158.environment.sunphases.dawn',
  updates: [{
    values: [ { "path": "", "value": {
      "meta": { description": "Morning nautical twilight ends, morning civil twilight starts", "units": "ISO-8601 (UTC)" }
    }} ]
  }]
};

And commit it with app.handleMessage.

After the update my path value is:

{
  "mmsi": "235115158",
  "meta": {
    "description": "Morning nautical twilight ends, morning civil twilight starts",
    "units": "ISO-8601 (UTC)"
  }
}

So, the meta property has been added just fine, but where has that pesky 'mmsi' property appeared from?. A ghost in the machine?

@preeve9534 preeve9534 changed the title Static property update adds a rogue property to target path Static property update adds a rogue 'mmsi' property to target path Dec 22, 2020
@tkurki
Copy link
Member

tkurki commented Dec 22, 2020

You should use the recently introduced meta deltas for sending metadata.

https://github.com/SignalK/signalk-server/releases/tag/v1.37.0

They've been a long time coming - now the plan is to iron out remaining wrinkles by using this feature and then add them to the specification.

In general the context was originally perceived to work like you've used it. I can't remember the exact details, but supporting arbitrary levels proved to be problematic, and the current implementation assumes that it is fixed to two levels. This is probably not documented as well as it should or at all.

Without testing or looking this up in the code there's most likely logic to fill the mmsi property from contexts with mmsi identity, and it is populated where the context points, thus the rogue property.

The meta delta feature should get you where you want to go, so I am closing this. If there's more to this feel free to reopen.

@tkurki tkurki closed this as completed Dec 22, 2020
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

2 participants