@signalk/freeboard-sk 2.2.0 → 2.2.1
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/CHANGELOG.md +7 -0
- package/package.json +18 -20
- package/plugin/alarms/alarms.js +2 -3
- package/plugin/index.js +10 -11
- package/plugin/lib/noaa.js +58 -62
- package/plugin/lib/openweather.js +54 -57
- package/plugin/lib/types.js +8 -8
- package/plugin/weather.js +7 -9
- package/public/3rdpartylicenses.txt +3 -6
- package/public/760.128eba7bc7bf35a5.js +1 -0
- package/public/assets/help/index.html +4 -2
- package/public/index.html +6 -5
- package/public/main.5461196ce3d0ae77.js +1 -0
- package/public/polyfills.61cfd308b28d8fe0.js +1 -0
- package/public/{runtime.2004f5e0f40621fc.js → runtime.d3c37bb0c0c8df86.js} +1 -1
- package/public/styles.b53caac129c3f7a0.css +1 -0
- package/public/598.58a90802ad6bb7ff.js +0 -1
- package/public/main.5ff254cefee77641.js +0 -1
- package/public/polyfills.12ddee7e4cb46a02.js +0 -1
- package/public/styles.7ebc2b506afc0008.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# CHANGELOG: Freeboard
|
|
2
2
|
|
|
3
|
+
### v2.2.1
|
|
4
|
+
|
|
5
|
+
- **Fixed**: Issue where waypoint was not centered on the screen when the center waypoint button was clicked from the entry in the waypoint list.
|
|
6
|
+
|
|
7
|
+
- **Fixed**: Issue where invalid fixed location postion was being written to settings.
|
|
8
|
+
|
|
9
|
+
|
|
3
10
|
### v2.2.0
|
|
4
11
|
|
|
5
12
|
- **Added**: Ability to center a vessel in the Vessels List.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signalk/freeboard-sk",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Openlayers chart plotter implementation for Signal K",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"signalk-webapp",
|
|
@@ -20,9 +20,7 @@
|
|
|
20
20
|
"build": "ng build",
|
|
21
21
|
"test": "ng test",
|
|
22
22
|
"format": "prettier --ignore-path .gitignore --write \"src/**/*.+(ts|html)\"",
|
|
23
|
-
"format:projects": "prettier --ignore-path .gitignore --write \"projects/**/*.+(ts|html)\"",
|
|
24
23
|
"format:helper": "prettier --ignore-path .gitignore --write \"helper/**/*.+(ts|html)\"",
|
|
25
|
-
"e2e": "ng e2e",
|
|
26
24
|
"build:helper": "tsc -p tsconfig-helper.json",
|
|
27
25
|
"build:web": "ng build -c production --output-hashing all",
|
|
28
26
|
"build:all": "npm run build:helper && npm run build:web",
|
|
@@ -44,19 +42,19 @@
|
|
|
44
42
|
"tslib": "^2.0.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"@angular-devkit/build-angular": "^
|
|
48
|
-
"@angular/animations": "^
|
|
49
|
-
"@angular/cdk": "^
|
|
50
|
-
"@angular/cli": "^
|
|
51
|
-
"@angular/common": "^
|
|
52
|
-
"@angular/compiler": "^
|
|
53
|
-
"@angular/compiler-cli": "^
|
|
54
|
-
"@angular/core": "^
|
|
55
|
-
"@angular/forms": "^
|
|
56
|
-
"@angular/language-service": "^
|
|
57
|
-
"@angular/material": "^
|
|
58
|
-
"@angular/platform-browser": "^
|
|
59
|
-
"@angular/platform-browser-dynamic": "^
|
|
45
|
+
"@angular-devkit/build-angular": "^16.2.0",
|
|
46
|
+
"@angular/animations": "^16.2.0",
|
|
47
|
+
"@angular/cdk": "^16.2.0",
|
|
48
|
+
"@angular/cli": "^16.2.0",
|
|
49
|
+
"@angular/common": "^16.2.0",
|
|
50
|
+
"@angular/compiler": "^16.2.0",
|
|
51
|
+
"@angular/compiler-cli": "^16.2.0",
|
|
52
|
+
"@angular/core": "^16.2.0",
|
|
53
|
+
"@angular/forms": "^16.2.0",
|
|
54
|
+
"@angular/language-service": "^16.2.0",
|
|
55
|
+
"@angular/material": "^16.2.0",
|
|
56
|
+
"@angular/platform-browser": "^16.2.0",
|
|
57
|
+
"@angular/platform-browser-dynamic": "^16.2.0",
|
|
60
58
|
"@kolkov/angular-editor": "^2.1.0",
|
|
61
59
|
"@signalk/server-api": "^2.0.0",
|
|
62
60
|
"@types/arcgis-rest-api": "^10.4.5",
|
|
@@ -78,7 +76,7 @@
|
|
|
78
76
|
"karma-coverage-istanbul-reporter": "~3.0.2",
|
|
79
77
|
"karma-jasmine": "~4.0.0",
|
|
80
78
|
"karma-jasmine-html-reporter": "^1.5.0",
|
|
81
|
-
"ng-packagr": "^
|
|
79
|
+
"ng-packagr": "^16.2.0",
|
|
82
80
|
"ngeohash": "^0.6.3",
|
|
83
81
|
"ol": "^7.4.0",
|
|
84
82
|
"pmtiles": "^2.7.0",
|
|
@@ -91,7 +89,7 @@
|
|
|
91
89
|
"signalk-worker-angular": "^1.1.4",
|
|
92
90
|
"simplify-ts": "^1.0.2",
|
|
93
91
|
"ts-node": "~7.0.0",
|
|
94
|
-
"typescript": "~4.
|
|
95
|
-
"zone.js": "~0.
|
|
92
|
+
"typescript": "~4.9.5",
|
|
93
|
+
"zone.js": "~0.13.1"
|
|
96
94
|
}
|
|
97
|
-
}
|
|
95
|
+
}
|
package/plugin/alarms/alarms.js
CHANGED
|
@@ -77,7 +77,6 @@ const initAlarmEndpoints = () => {
|
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
79
|
const handlePutAlarmState = (context, path, value) => {
|
|
80
|
-
var _a, _b;
|
|
81
80
|
server.debug(context);
|
|
82
81
|
server.debug(path);
|
|
83
82
|
server.debug(JSON.stringify(value));
|
|
@@ -95,7 +94,7 @@ const handlePutAlarmState = (context, path, value) => {
|
|
|
95
94
|
server.debug(JSON.stringify(alarmType));
|
|
96
95
|
let noti;
|
|
97
96
|
if (value) {
|
|
98
|
-
noti = new types_1.Notification(alarmType, buildAlarmMessage(value.message, alarmType),
|
|
97
|
+
noti = new types_1.Notification(alarmType, buildAlarmMessage(value.message, alarmType), value.state ?? null, value.method ?? null);
|
|
99
98
|
}
|
|
100
99
|
else {
|
|
101
100
|
noti = {
|
|
@@ -123,7 +122,7 @@ const buildAlarmMessage = (message, alarmType) => {
|
|
|
123
122
|
if (['mob', 'sinking'].includes(alarmType)) {
|
|
124
123
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
124
|
const pos = server.getSelfPath('navigation.position');
|
|
126
|
-
msgAttrib = pos ? JSON.stringify(pos
|
|
125
|
+
msgAttrib = pos ? JSON.stringify(pos?.value) : '';
|
|
127
126
|
}
|
|
128
127
|
return `${message}\n\r${msgAttrib}`;
|
|
129
128
|
};
|
package/plugin/index.js
CHANGED
|
@@ -122,32 +122,31 @@ module.exports = (server) => {
|
|
|
122
122
|
};
|
|
123
123
|
// ************************************
|
|
124
124
|
const doStartup = (options) => {
|
|
125
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
126
125
|
try {
|
|
127
126
|
server.debug(`${plugin.name} starting.......`);
|
|
128
127
|
if (typeof options !== 'undefined') {
|
|
129
128
|
settings = options;
|
|
130
129
|
}
|
|
131
|
-
settings.weather =
|
|
130
|
+
settings.weather = options.weather ?? {
|
|
132
131
|
enable: false,
|
|
133
132
|
apiKey: '',
|
|
134
133
|
service: 'openweather'
|
|
135
134
|
};
|
|
136
|
-
settings.weather.enable =
|
|
137
|
-
settings.weather.apiKey =
|
|
138
|
-
settings.weather.service =
|
|
139
|
-
settings.alarms =
|
|
135
|
+
settings.weather.enable = options.weather.enable ?? false;
|
|
136
|
+
settings.weather.apiKey = options.weather.apiKey ?? '';
|
|
137
|
+
settings.weather.service = options.weather.service ?? 'openweather';
|
|
138
|
+
settings.alarms = options.alarms ?? {
|
|
140
139
|
enable: true
|
|
141
140
|
};
|
|
142
|
-
settings.alarms.enable =
|
|
143
|
-
settings.pypilot =
|
|
141
|
+
settings.alarms.enable = options.alarms.enable ?? true;
|
|
142
|
+
settings.pypilot = options.pypilot ?? {
|
|
144
143
|
enable: false,
|
|
145
144
|
host: 'localhost',
|
|
146
145
|
port: 8000
|
|
147
146
|
};
|
|
148
|
-
settings.pypilot.enable =
|
|
149
|
-
settings.pypilot.host =
|
|
150
|
-
settings.pypilot.port =
|
|
147
|
+
settings.pypilot.enable = options.pypilot.enable ?? false;
|
|
148
|
+
settings.pypilot.host = options.pypilot.host ?? 'localhost';
|
|
149
|
+
settings.pypilot.port = options.pypilot.port ?? 8000;
|
|
151
150
|
server.debug(`Applied config: ${JSON.stringify(settings)}`);
|
|
152
151
|
if (settings.alarms.enable) {
|
|
153
152
|
(0, alarms_1.initAlarms)(server, plugin.id);
|
package/plugin/lib/noaa.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// NOAA
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.NOAA = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
5
|
const fetch_1 = require("./fetch");
|
|
7
6
|
var CARDINAL_POINTS;
|
|
8
7
|
(function (CARDINAL_POINTS) {
|
|
@@ -24,55 +23,8 @@ var CARDINAL_POINTS;
|
|
|
24
23
|
CARDINAL_POINTS[CARDINAL_POINTS["NNW"] = 337.5] = "NNW";
|
|
25
24
|
})(CARDINAL_POINTS || (CARDINAL_POINTS = {}));
|
|
26
25
|
class NOAA {
|
|
26
|
+
settings;
|
|
27
27
|
constructor(config) {
|
|
28
|
-
this.fetchData = (position) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f;
|
|
30
|
-
const url = this.getUrl(position);
|
|
31
|
-
try {
|
|
32
|
-
//console.log(`url`, url)
|
|
33
|
-
const response = yield (0, fetch_1.fetch)(url);
|
|
34
|
-
let forecasts = [];
|
|
35
|
-
let observations = [];
|
|
36
|
-
// observations
|
|
37
|
-
if ((_a = response === null || response === void 0 ? void 0 : response.properties) === null || _a === void 0 ? void 0 : _a.observationStations) {
|
|
38
|
-
const stations = yield (0, fetch_1.fetch)(response.properties.observationStations);
|
|
39
|
-
observations = yield (0, fetch_1.fetch)(`${stations.features[0].id}/observations/latest`);
|
|
40
|
-
//console.log(`observations`, observations)
|
|
41
|
-
}
|
|
42
|
-
// forecasts
|
|
43
|
-
if ((_b = response === null || response === void 0 ? void 0 : response.properties) === null || _b === void 0 ? void 0 : _b.forecastHourly) {
|
|
44
|
-
forecasts = yield (0, fetch_1.fetch)(response.properties.forecastHourly);
|
|
45
|
-
//console.log(`forecasts`, forecasts)
|
|
46
|
-
}
|
|
47
|
-
// warnings
|
|
48
|
-
const warnings = yield (0, fetch_1.fetch)(`https://api.weather.gov/alerts/active?point=${position.latitude.toFixed(4)},${position.longitude.toFixed(4)}`);
|
|
49
|
-
//console.log(`warnings`, warnings)
|
|
50
|
-
return this.parseResponse({
|
|
51
|
-
position: position,
|
|
52
|
-
forecasts: (_d = (_c = forecasts === null || forecasts === void 0 ? void 0 : forecasts.properties) === null || _c === void 0 ? void 0 : _c.periods) !== null && _d !== void 0 ? _d : [],
|
|
53
|
-
observations: (_e = observations === null || observations === void 0 ? void 0 : observations.properties) !== null && _e !== void 0 ? _e : null,
|
|
54
|
-
warnings: (_f = warnings === null || warnings === void 0 ? void 0 : warnings.features) !== null && _f !== void 0 ? _f : []
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
this.parseResponse = (wData) => {
|
|
62
|
-
return {
|
|
63
|
-
self: {
|
|
64
|
-
id: 'self',
|
|
65
|
-
name: 'Weather data relative to supplied position.',
|
|
66
|
-
position: {
|
|
67
|
-
latitude: wData.latitude,
|
|
68
|
-
longitude: wData.longitude
|
|
69
|
-
},
|
|
70
|
-
observations: this.parseNoaaObservations(wData.observations),
|
|
71
|
-
forecasts: this.parseNoaaForecasts(wData.forecasts),
|
|
72
|
-
warnings: this.parseNoaaWarnings(wData.warnings)
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
28
|
this.settings = config;
|
|
77
29
|
}
|
|
78
30
|
getUrl(position) {
|
|
@@ -84,14 +36,60 @@ class NOAA {
|
|
|
84
36
|
return `${api}/${position.latitude.toFixed(4)},${position.longitude.toFixed(4)}`;
|
|
85
37
|
}
|
|
86
38
|
}
|
|
39
|
+
fetchData = async (position) => {
|
|
40
|
+
const url = this.getUrl(position);
|
|
41
|
+
try {
|
|
42
|
+
//console.log(`url`, url)
|
|
43
|
+
const response = await (0, fetch_1.fetch)(url);
|
|
44
|
+
let forecasts = [];
|
|
45
|
+
let observations = [];
|
|
46
|
+
// observations
|
|
47
|
+
if (response?.properties?.observationStations) {
|
|
48
|
+
const stations = await (0, fetch_1.fetch)(response.properties.observationStations);
|
|
49
|
+
observations = await (0, fetch_1.fetch)(`${stations.features[0].id}/observations/latest`);
|
|
50
|
+
//console.log(`observations`, observations)
|
|
51
|
+
}
|
|
52
|
+
// forecasts
|
|
53
|
+
if (response?.properties?.forecastHourly) {
|
|
54
|
+
forecasts = await (0, fetch_1.fetch)(response.properties.forecastHourly);
|
|
55
|
+
//console.log(`forecasts`, forecasts)
|
|
56
|
+
}
|
|
57
|
+
// warnings
|
|
58
|
+
const warnings = await (0, fetch_1.fetch)(`https://api.weather.gov/alerts/active?point=${position.latitude.toFixed(4)},${position.longitude.toFixed(4)}`);
|
|
59
|
+
//console.log(`warnings`, warnings)
|
|
60
|
+
return this.parseResponse({
|
|
61
|
+
position: position,
|
|
62
|
+
forecasts: forecasts?.properties?.periods ?? [],
|
|
63
|
+
observations: observations?.properties ?? null,
|
|
64
|
+
warnings: warnings?.features ?? []
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
parseResponse = (wData) => {
|
|
72
|
+
return {
|
|
73
|
+
self: {
|
|
74
|
+
id: 'self',
|
|
75
|
+
name: 'Weather data relative to supplied position.',
|
|
76
|
+
position: {
|
|
77
|
+
latitude: wData.latitude,
|
|
78
|
+
longitude: wData.longitude
|
|
79
|
+
},
|
|
80
|
+
observations: this.parseNoaaObservations(wData.observations),
|
|
81
|
+
forecasts: this.parseNoaaForecasts(wData.forecasts),
|
|
82
|
+
warnings: this.parseNoaaWarnings(wData.warnings)
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
87
86
|
parseNoaaObservations(wData) {
|
|
88
|
-
var _a, _b;
|
|
89
87
|
const data = [];
|
|
90
88
|
const obs = {};
|
|
91
89
|
let v;
|
|
92
90
|
if (wData) {
|
|
93
|
-
obs.timestamp =
|
|
94
|
-
obs.description =
|
|
91
|
+
obs.timestamp = wData.timestamp ?? null;
|
|
92
|
+
obs.description = wData.textDescription ?? null;
|
|
95
93
|
v = wData.visibility.value
|
|
96
94
|
? wData.visibility.unitCode === 'wmoUnit:m'
|
|
97
95
|
? wData.visibility.value
|
|
@@ -176,10 +174,9 @@ class NOAA {
|
|
|
176
174
|
const data = [];
|
|
177
175
|
if (forecasts && Array.isArray(forecasts)) {
|
|
178
176
|
forecasts.forEach((f) => {
|
|
179
|
-
var _a, _b, _c;
|
|
180
177
|
const forecast = {};
|
|
181
|
-
forecast.timestamp =
|
|
182
|
-
forecast.description =
|
|
178
|
+
forecast.timestamp = f.startTime ?? null;
|
|
179
|
+
forecast.description = f.shortForecast ?? null;
|
|
183
180
|
forecast.temperature = {};
|
|
184
181
|
forecast.temperature.air = {
|
|
185
182
|
value: typeof f.temperature !== 'undefined'
|
|
@@ -189,7 +186,7 @@ class NOAA {
|
|
|
189
186
|
};
|
|
190
187
|
forecast.wind = {};
|
|
191
188
|
forecast.wind.speed = {
|
|
192
|
-
value:
|
|
189
|
+
value: parseInt(f.windSpeed.split(' ')[0]) / 2.237 ?? null,
|
|
193
190
|
units: 'm/s'
|
|
194
191
|
};
|
|
195
192
|
const wd = f.windDirection
|
|
@@ -208,13 +205,12 @@ class NOAA {
|
|
|
208
205
|
const data = [];
|
|
209
206
|
if (alerts && Array.isArray(alerts)) {
|
|
210
207
|
alerts.forEach((alert) => {
|
|
211
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
212
208
|
const warn = {
|
|
213
|
-
startTime:
|
|
214
|
-
endTime:
|
|
215
|
-
details:
|
|
216
|
-
source:
|
|
217
|
-
type:
|
|
209
|
+
startTime: alert?.properties?.effective ?? null,
|
|
210
|
+
endTime: alert?.properties?.ends ?? null,
|
|
211
|
+
details: alert?.properties?.description ?? null,
|
|
212
|
+
source: alert?.properties?.senderName ?? null,
|
|
213
|
+
type: alert?.properties?.messageType ?? null
|
|
218
214
|
};
|
|
219
215
|
data.push(warn);
|
|
220
216
|
});
|
|
@@ -2,35 +2,10 @@
|
|
|
2
2
|
// OpenWeather
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.OpenWeather = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
5
|
const fetch_1 = require("./fetch");
|
|
7
6
|
class OpenWeather {
|
|
7
|
+
settings;
|
|
8
8
|
constructor(config) {
|
|
9
|
-
this.fetchData = (position) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
-
const url = this.getUrl(position);
|
|
11
|
-
try {
|
|
12
|
-
const response = yield (0, fetch_1.fetch)(url);
|
|
13
|
-
return this.parseResponse(response);
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
this.parseResponse = (owData) => {
|
|
20
|
-
return {
|
|
21
|
-
self: {
|
|
22
|
-
id: 'self',
|
|
23
|
-
name: 'Weather data relative to supplied position.',
|
|
24
|
-
position: {
|
|
25
|
-
latitude: owData.lat,
|
|
26
|
-
longitude: owData.lon
|
|
27
|
-
},
|
|
28
|
-
observations: this.parseOWObservations(owData),
|
|
29
|
-
forecasts: this.parseOWForecasts(owData),
|
|
30
|
-
warnings: this.parseOWWarnings(owData)
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
9
|
this.settings = config;
|
|
35
10
|
}
|
|
36
11
|
getUrl(position) {
|
|
@@ -42,8 +17,32 @@ class OpenWeather {
|
|
|
42
17
|
return `${api}?lat=${position.latitude}&lon=${position.longitude}&exclude=minutely,daily&appid=${this.settings.apiKey}`;
|
|
43
18
|
}
|
|
44
19
|
}
|
|
20
|
+
fetchData = async (position) => {
|
|
21
|
+
const url = this.getUrl(position);
|
|
22
|
+
try {
|
|
23
|
+
const response = await (0, fetch_1.fetch)(url);
|
|
24
|
+
return this.parseResponse(response);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
parseResponse = (owData) => {
|
|
31
|
+
return {
|
|
32
|
+
self: {
|
|
33
|
+
id: 'self',
|
|
34
|
+
name: 'Weather data relative to supplied position.',
|
|
35
|
+
position: {
|
|
36
|
+
latitude: owData.lat,
|
|
37
|
+
longitude: owData.lon
|
|
38
|
+
},
|
|
39
|
+
observations: this.parseOWObservations(owData),
|
|
40
|
+
forecasts: this.parseOWForecasts(owData),
|
|
41
|
+
warnings: this.parseOWWarnings(owData)
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
45
|
parseOWObservations(owData) {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
47
46
|
//server.debug(JSON.stringify(weatherData.current))
|
|
48
47
|
const data = [];
|
|
49
48
|
const obs = {};
|
|
@@ -52,32 +51,32 @@ class OpenWeather {
|
|
|
52
51
|
obs.timestamp = current.dt
|
|
53
52
|
? new Date(current.dt * 1000).toISOString()
|
|
54
53
|
: null;
|
|
55
|
-
obs.description =
|
|
56
|
-
obs.sunrise =
|
|
57
|
-
obs.sunset =
|
|
54
|
+
obs.description = current.weather[0].description ?? null;
|
|
55
|
+
obs.sunrise = new Date(current.sunrise * 1000).toISOString() ?? null;
|
|
56
|
+
obs.sunset = new Date(current.sunset * 1000).toISOString() ?? null;
|
|
58
57
|
obs.uvIndex = {
|
|
59
|
-
value:
|
|
58
|
+
value: current.uvi ?? null,
|
|
60
59
|
units: null
|
|
61
60
|
};
|
|
62
61
|
obs.clouds = {
|
|
63
|
-
value:
|
|
62
|
+
value: current.clouds ?? null,
|
|
64
63
|
units: '%'
|
|
65
64
|
};
|
|
66
65
|
obs.visibility = {
|
|
67
|
-
value:
|
|
66
|
+
value: current.visibility ?? null,
|
|
68
67
|
units: 'm'
|
|
69
68
|
};
|
|
70
69
|
obs.temperature = {};
|
|
71
70
|
obs.temperature.air = {
|
|
72
|
-
value:
|
|
71
|
+
value: current.temp ?? null,
|
|
73
72
|
units: 'K'
|
|
74
73
|
};
|
|
75
74
|
obs.temperature.feelsLike = {
|
|
76
|
-
value:
|
|
75
|
+
value: current.feels_like ?? null,
|
|
77
76
|
units: 'K'
|
|
78
77
|
};
|
|
79
78
|
obs.temperature.dewPoint = {
|
|
80
|
-
value:
|
|
79
|
+
value: current.dew_point ?? null,
|
|
81
80
|
units: 'K'
|
|
82
81
|
};
|
|
83
82
|
obs.pressure = {};
|
|
@@ -87,12 +86,12 @@ class OpenWeather {
|
|
|
87
86
|
};
|
|
88
87
|
obs.humidity = {};
|
|
89
88
|
obs.humidity.absolute = {
|
|
90
|
-
value:
|
|
89
|
+
value: current.humidity ?? null,
|
|
91
90
|
units: '%'
|
|
92
91
|
};
|
|
93
92
|
obs.wind = {};
|
|
94
93
|
obs.wind.speed = {
|
|
95
|
-
value:
|
|
94
|
+
value: current.wind_speed ?? null,
|
|
96
95
|
units: 'm/s'
|
|
97
96
|
};
|
|
98
97
|
obs.wind.direction = {
|
|
@@ -127,47 +126,46 @@ class OpenWeather {
|
|
|
127
126
|
if (owData && owData[period] && Array.isArray(owData[period])) {
|
|
128
127
|
const forecasts = owData[period];
|
|
129
128
|
forecasts.forEach((f) => {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
131
129
|
const forecast = {};
|
|
132
130
|
forecast.timestamp = f.dt ? new Date(f.dt * 1000).toISOString() : null;
|
|
133
|
-
forecast.description =
|
|
131
|
+
forecast.description = f.weather[0].description ?? null;
|
|
134
132
|
forecast.temperature = {};
|
|
135
133
|
forecast.temperature.air = {
|
|
136
|
-
value:
|
|
134
|
+
value: f.temp ?? null,
|
|
137
135
|
units: 'K'
|
|
138
136
|
};
|
|
139
137
|
if (period === 'daily') {
|
|
140
|
-
forecast.sunrise =
|
|
141
|
-
forecast.sunset =
|
|
138
|
+
forecast.sunrise = new Date(f.sunrise * 1000).toISOString() ?? null;
|
|
139
|
+
forecast.sunset = new Date(f.sunset * 1000).toISOString() ?? null;
|
|
142
140
|
forecast.temperature.minimum = {
|
|
143
|
-
value:
|
|
141
|
+
value: f.temp.min ?? null,
|
|
144
142
|
units: 'K'
|
|
145
143
|
};
|
|
146
144
|
forecast.temperature.maximum = {
|
|
147
|
-
value:
|
|
145
|
+
value: f.temp.max ?? null,
|
|
148
146
|
units: 'K'
|
|
149
147
|
};
|
|
150
148
|
forecast.temperature.feelsLike = {
|
|
151
|
-
value:
|
|
149
|
+
value: f.feels_like.day ?? null,
|
|
152
150
|
units: 'K'
|
|
153
151
|
};
|
|
154
152
|
}
|
|
155
153
|
else {
|
|
156
154
|
forecast.temperature.feelsLike = {
|
|
157
|
-
value:
|
|
155
|
+
value: f.feels_like ?? null,
|
|
158
156
|
units: 'K'
|
|
159
157
|
};
|
|
160
158
|
}
|
|
161
159
|
forecast.temperature.dewPoint = {
|
|
162
|
-
value:
|
|
160
|
+
value: f.dew_point ?? null,
|
|
163
161
|
units: 'K'
|
|
164
162
|
};
|
|
165
163
|
forecast.uvIndex = {
|
|
166
|
-
value:
|
|
164
|
+
value: f.uvi ?? null,
|
|
167
165
|
units: null
|
|
168
166
|
};
|
|
169
167
|
forecast.clouds = {
|
|
170
|
-
value:
|
|
168
|
+
value: f.clouds ?? null,
|
|
171
169
|
units: '%'
|
|
172
170
|
};
|
|
173
171
|
forecast.pop = {
|
|
@@ -180,12 +178,12 @@ class OpenWeather {
|
|
|
180
178
|
};
|
|
181
179
|
forecast.humidity = {};
|
|
182
180
|
forecast.humidity.absolute = {
|
|
183
|
-
value:
|
|
181
|
+
value: f.humidity ?? null,
|
|
184
182
|
units: '%'
|
|
185
183
|
};
|
|
186
184
|
forecast.wind = {};
|
|
187
185
|
forecast.wind.speed = {
|
|
188
|
-
value:
|
|
186
|
+
value: f.wind_speed ?? null,
|
|
189
187
|
units: 'm/s'
|
|
190
188
|
};
|
|
191
189
|
forecast.wind.direction = {
|
|
@@ -195,7 +193,7 @@ class OpenWeather {
|
|
|
195
193
|
units: 'rad'
|
|
196
194
|
};
|
|
197
195
|
forecast.wind.gust = {
|
|
198
|
-
value:
|
|
196
|
+
value: f.wind_gust ?? null,
|
|
199
197
|
units: 'm/s'
|
|
200
198
|
};
|
|
201
199
|
forecast.precipitation = {
|
|
@@ -221,7 +219,6 @@ class OpenWeather {
|
|
|
221
219
|
if (owData && owData.alerts) {
|
|
222
220
|
const alerts = owData.alerts;
|
|
223
221
|
alerts.forEach((alert) => {
|
|
224
|
-
var _a, _b, _c;
|
|
225
222
|
const warn = {
|
|
226
223
|
startTime: alert.start
|
|
227
224
|
? new Date(alert.start * 1000).toISOString()
|
|
@@ -229,9 +226,9 @@ class OpenWeather {
|
|
|
229
226
|
endTime: alert.end
|
|
230
227
|
? new Date(alert.start * 1000).toISOString()
|
|
231
228
|
: null,
|
|
232
|
-
details:
|
|
233
|
-
source:
|
|
234
|
-
type:
|
|
229
|
+
details: alert.description ?? null,
|
|
230
|
+
source: alert.sender_name ?? null,
|
|
231
|
+
type: alert.event ?? null
|
|
235
232
|
};
|
|
236
233
|
data.push(warn);
|
|
237
234
|
});
|
package/plugin/lib/types.js
CHANGED
|
@@ -18,15 +18,15 @@ var ALARM_METHOD;
|
|
|
18
18
|
})(ALARM_METHOD = exports.ALARM_METHOD || (exports.ALARM_METHOD = {}));
|
|
19
19
|
// Class encapsulating Signal K Notification
|
|
20
20
|
class Notification {
|
|
21
|
+
_message = {
|
|
22
|
+
path: `notifications.`,
|
|
23
|
+
value: {
|
|
24
|
+
state: ALARM_STATE.alarm,
|
|
25
|
+
method: [ALARM_METHOD.sound, ALARM_METHOD.visual],
|
|
26
|
+
message: 'Alarm!'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
21
29
|
constructor(path, msg, state, method) {
|
|
22
|
-
this._message = {
|
|
23
|
-
path: `notifications.`,
|
|
24
|
-
value: {
|
|
25
|
-
state: ALARM_STATE.alarm,
|
|
26
|
-
method: [ALARM_METHOD.sound, ALARM_METHOD.visual],
|
|
27
|
-
message: 'Alarm!'
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
30
|
this._message.path += path;
|
|
31
31
|
this._message.value.message = msg;
|
|
32
32
|
if (state) {
|
package/plugin/weather.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getWeather = exports.listWeather = exports.stopWeather = exports.initWeather = exports.WEATHER_SERVICES = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const types_1 = require("./lib/types");
|
|
6
5
|
const openweather_1 = require("./lib/openweather");
|
|
7
6
|
const noaa_1 = require("./lib/noaa");
|
|
@@ -41,7 +40,7 @@ const stopWeather = () => {
|
|
|
41
40
|
};
|
|
42
41
|
exports.stopWeather = stopWeather;
|
|
43
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
-
const listWeather = (params) =>
|
|
43
|
+
const listWeather = async (params) => {
|
|
45
44
|
server.debug(`getWeather ${JSON.stringify(params)}`);
|
|
46
45
|
const res = {};
|
|
47
46
|
if (weatherData) {
|
|
@@ -51,11 +50,11 @@ const listWeather = (params) => tslib_1.__awaiter(void 0, void 0, void 0, functi
|
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
return res;
|
|
54
|
-
}
|
|
53
|
+
};
|
|
55
54
|
exports.listWeather = listWeather;
|
|
56
|
-
const getWeather = (path, property
|
|
55
|
+
const getWeather = async (path, property
|
|
57
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
-
) =>
|
|
57
|
+
) => {
|
|
59
58
|
server.debug(`getWeather ${path}, ${property}`);
|
|
60
59
|
if (!weatherData) {
|
|
61
60
|
return {};
|
|
@@ -68,12 +67,12 @@ const getWeather = (path, property
|
|
|
68
67
|
const value = property.split('.').reduce((acc, val) => {
|
|
69
68
|
return acc[val];
|
|
70
69
|
}, station);
|
|
71
|
-
return value
|
|
70
|
+
return value ?? {};
|
|
72
71
|
}
|
|
73
72
|
else {
|
|
74
73
|
return station;
|
|
75
74
|
}
|
|
76
|
-
}
|
|
75
|
+
};
|
|
77
76
|
exports.getWeather = getWeather;
|
|
78
77
|
const fetchWeatherData = () => {
|
|
79
78
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -155,7 +154,6 @@ const checkForWarnings = () => {
|
|
|
155
154
|
};
|
|
156
155
|
// emit weather warning notification
|
|
157
156
|
const emitWarningNotification = (warning) => {
|
|
158
|
-
var _a;
|
|
159
157
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
160
158
|
let delta;
|
|
161
159
|
if (warning) {
|
|
@@ -168,7 +166,7 @@ const emitWarningNotification = (warning) => {
|
|
|
168
166
|
method: [types_1.ALARM_METHOD.visual],
|
|
169
167
|
message: warning.details
|
|
170
168
|
? warning.details
|
|
171
|
-
:
|
|
169
|
+
: warning.type ?? warning.source
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
172
|
}
|