joelkoz / signalk-tide-watch

A plugin for SignalK Node Server to monitor and determine tides
2 stars 0 forks source link

Depth Source #5

Open SCarns opened 4 years ago

SCarns commented 4 years ago

My enviroment.depth.belowSurface is calculated through derived-data. If I use this as the data source for Tide_Watch, I get an error in the log and it doesn't work. If I switch to environment.depth.belowTransducer (an actual value from the N2K network), the TypeError goes away. Obviously using the "belowSurface", even though it's a calculated value, would be more accurate. Here's the log:

Oct 08 09:53:19 TypeError: Cannot read property 'type' of undefined at evtDepthVal.evtDepth.filter.dbs (/home/pi/.signalk/node_modules/signalk-tide-watch/index.js:54:63) at Next.filter (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:926:10) at Dispatcher._handleEvent (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:2057:17) at Dispatcher.handleEvent (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:1265:17) at Object.sink (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:242:17) at Dispatcher.pushToSubscriptions (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:1223:23) at Dispatcher.pushIt (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:1245:10) at Object.inTransaction (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:430:16) at Dispatcher.push (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:1214:24) at Dispatcher.handleEvent (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:1267:17) at Bus.sink (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:242:17) at Bus.push (/usr/lib/node_modules/signalk-server/node_modules/baconjs/dist/Bacon.js:2371:21) at StreamBundle.push (/usr/lib/node_modules/signalk-server/lib/streambundle.js:92:31) at paths.forEach.path (/usr/lib/node_modules/signalk-server/lib/streambundle.js:46:34) at Array.forEach () at StreamBundle.update.values.forEach.pathValue (/usr/lib/node_modules/signalk-server/lib/streambundle.js:45:31) at Array.forEach () at StreamBundle.delta.updates.forEach.update (/usr/lib/node_modules/signalk-server/lib/streambundle.js:35:35) at Array.forEach () at StreamBundle.pushDelta (/usr/lib/node_modules/signalk-server/lib/streambundle.js:33:27) at FullSignalK.emit (events.js:203:15) at FullSignalK.addDelta (/usr/lib/node_modules/signalk-server/node_modules/@signalk/signalk-schema/dist/fullsignalk.js:52:8)

itemir commented 2 years ago

I have the same problem.

SCarns commented 2 years ago

I don't have this issue anymore, so I assume it's been fixed. However, the tide predictions are all wrong. I feel as this happened with the last update, but I'm unsure.

itemir commented 2 years ago

Strange, I just installed it this morning for the first time and it doesn't work with environment.depth.belowSurface (comes from derived-data) but it works with environment.depth.belowTransducer (comes from NMEA 2000).

Do you have anything in your Depth source Type filter and Depth source Talker filter? And what version are you using?

itemir commented 2 years ago

Digging into this a bit more, looks like the updates coming from NMEA and derived-data are slightly different:

NMEA 2000: Jan 23 09:31:09 2022-01-23T17:31:09.649Z signalk-debug {"context":"vessels.urn:mrn:imo:mmsi:367744020","updates":[{"source":{"label":"PiCAN-M","type":"NMEA2000","pgn":128267,"src":"105","deviceInstance":32},"$source":"PiCAN-M.105","timestamp":"2022-01-23T17:31:09.551Z","values":[{"path":"environment.depth.belowTransducer","value":20.06}]}]}

derived-data: Jan 23 09:31:10 2022-01-23T17:31:10.672Z signalk-debug {"context":"vessels.urn:mrn:imo:mmsi:367744020","updates":[{"$source":"derived-data","timestamp":"2022-01-23T17:31:10.615Z","values":[{"path":"environment.depth.belowSurface","value":20.553}]}]}

Source key is missing in derived-data, wondering if it is what messes up things when combined with the filter:

this.evtDepthVal = this.evtDepth .filter(dbs => { return this.wildcardEq(dbs.source.type, this.options.depthSourceType) && this.wildcardEq(dbs.source.talker, this.options.depthSourceTalker); } ) .map(".value");

SCarns commented 10 months ago

No “Types” specified. I’m on a new installation now, as I’m between boats - getting set up for the next one. I don’t yet have any NMEA data yet, but I am simulating the whole set up and it doesn’t work again. Since depth.belowSurface is the default value and that value will always be a calculated value as an offset of depth.belowTransducer, it shouldn’t require those types to function properly.