@meri-imperiumi/signalk-mob-notifier 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -11,6 +11,10 @@ Please note that this plugin aims to aid with noticing and locating crew overboa
11
11
 
12
12
  ## Changes
13
13
 
14
+ * 1.1.2 (2025-11-01)
15
+ - Better approach at getting MOB coordinates
16
+ * 1.1.1 (2025-09-18)
17
+ - Notifications include position when available
14
18
  * 1.1.0 (2025-09-04)
15
19
  - Notification is not re-published if it already exists
16
20
  * 1.0.0 (2025-08-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meri-imperiumi/signalk-mob-notifier",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Create Signal K notifications for discovered AIS MOB, EPIRB, and SART beacons",
5
5
  "main": "plugin/index.js",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  },
13
13
  "keywords": [
14
14
  "signalk-node-server-plugin",
15
+ "signalk-category-ais",
15
16
  "signalk-category-notifications"
16
17
  ],
17
18
  "author": "Henri Bergius <henri.bergius@iki.fi>",
package/plugin/index.js CHANGED
@@ -110,9 +110,25 @@ module.exports = (app) => {
110
110
  message = 'Emergency Position Indicating Beacon detected';
111
111
  }
112
112
  // For each MOB get direction and range
113
- const ownPosition = app.getSelfPath('navigation.position');
114
- const mobPosition = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}.navigation.position`);
115
- if (ownPosition && mobPosition) {
113
+ const getCoordinates = (v) => {
114
+ if (Number.isFinite(v.latitude)) {
115
+ return v;
116
+ }
117
+ if (v.value && Number.isFinite(v.value.latitude)) {
118
+ return v.value;
119
+ }
120
+ return {};
121
+ };
122
+ const ownPosition = getCoordinates(app.getSelfPath('navigation.position'));
123
+ const mob = app.getPath(`vessels.urn:mrn:imo:mmsi:${mmsi}`);
124
+ let mobPosition = {};
125
+ if (mob.navigation && mob.navigation.position) {
126
+ mobPosition = getCoordinates(mob.navigation.position);
127
+ }
128
+ if (ownPosition
129
+ && Number.isFinite(ownPosition.latitude)
130
+ && mobPosition
131
+ && Number.isFinite(mobPosition.latitude)) {
116
132
  const me = new Point(ownPosition.latitude, ownPosition.longitude);
117
133
  const they = new Point(mobPosition.latitude, mobPosition.longitude);
118
134
  const distance = me.distanceTo(they, 'K') * 1000; // In meters
@@ -134,6 +150,10 @@ module.exports = (app) => {
134
150
  path: `notifications.mob.${mmsi}`,
135
151
  value: {
136
152
  message,
153
+ position: mobPosition || null,
154
+ data: {
155
+ mmsi,
156
+ },
137
157
  state: 'emergency',
138
158
  method: ['visual', 'sound'],
139
159
  },