RFC: A location property for notifications

Open
#694 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, json, openapi

Research direction

Start by reading the Notification value schema and the Notifications API OpenAPI and AsyncAPI schemas named in the proposal. Trace how raise() and update() accept and expose notification fields, including their REST counterparts, and check the existing location data from @signalk/n2k-signalk. Done means the optional property is specified consistently across the schemas and API surfaces, with the compatibility and open questions resolved.

Written by the indexing model from the issue text.

Description

Summary

Add an optional location string to the Notification value: a human-readable place on the vessel or installation the notification refers to, such as "ER Port" or "Galley". Clients show it together with message, so an alarm reads "Highwater – ER Port" instead of "Highwater".

Motivation

An NMEA 2000 alert (PGN 126985 Alert Text) carries two strings: the alert text and the alert location text. Alerting systems such as Maretron N2KView put the condition in the first and the place in the second, so the text alone is often ambiguous. On one boat, ten alerts include "Highwater" twice and "CO 8Ohm" four times, and only the location tells them apart:

Text Location
CO 8Ohm Port Fwd Cabin
CO 8 Ohm Port Mid Cabin
CO 8Ohm Galley
CO 8Ohm Masercabin
Highwater Vorpiek Stb
Highwater ER Port

@signalk/n2k-signalk has published the location since 4.7.0, as a location property next to message in notifications.nmea.*. The Notification schema has no such property, so clients do not know it exists. Freeboard-SK, for example, builds its alert from message and the Notifications API fields only, and shows "Highwater" with no way to tell which bilge is flooding.

Putting the place into message would work in every client today, but it mixes two pieces of information that a client may want to present differently (a column, a filter, a second line), and every producer would format it its own way. A defined property keeps them apart and gives producers one place to put it.

Proposal

Specification

In the Notification value, next to state, method and message:

"location": {
  "type": "string",
  "description": "Where on the vessel or installation the condition is, in human-readable form, e.g. \"ER Port\" or \"Galley\". Not a geographic position; see position."
}
  • Optional. Absent and empty mean "no location given".
  • Free text, set by the producer. No vocabulary is defined, because installations name their spaces themselves.
  • Distinct from position, which is the vessel's geographic position when the notification was raised.

The property is named location because that is what n2k-signalk already emits, so the existing N2K mapping becomes conformant without any change.

Server
  • Notification in @signalk/server-api gains location?: string.
  • The Notifications API OpenAPI and AsyncAPI schemas document it.
  • raise() and update() in the Notifications API, and their REST counterparts, accept location, so plugins raising alarms can set it.
  • Notifications that arrive as deltas already keep the whole value, so location passes through to clients unchanged.
Clients

A client that shows a notification's message should show location with it when present. The exact form ("Highwater – ER Port", a second line, a column) is the client's choice.

Producers
  • @signalk/n2k-signalk: no change; it already sets location from PGN 126985.
  • Plugins that know the place of a condition (bilge, fire and gas sensors, tank alarms) can set it instead of writing it into message.

Compatibility

Purely additive. A client that ignores location behaves as today, and a producer that does not set it is unaffected.

Open questions

  1. Should the Notifications API's own alarms (MOB, for instance) ever set location? Probably not, since position covers them.
  2. Should location be translatable, given that PGN 126985 carries a language id? This RFC treats it as display text in whatever language the producer has.
Dominant language
JavaScript
Stars
105
Forks
72
Avg merge
11h 49m
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SignalK/specification

All issues in SignalK/specification

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.