File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,26 @@ module.exports = function(RED) {
5
5
var node = this ;
6
6
7
7
var signalk = node . context ( ) . global . get ( 'signalk' )
8
+ var app = node . context ( ) . global . get ( 'app' )
8
9
9
10
function on_delta ( delta ) {
10
- node . send ( { payload : delta } )
11
+ if ( delta . updates ) {
12
+ var copy = JSON . parse ( JSON . stringify ( delta ) )
13
+ copy . updates = [ ]
14
+ delta . updates . forEach ( update => {
15
+ if ( update . values &&
16
+ ( ! update . $source || ! update . $source . startsWith ( 'signalk-node-red' ) ) ) {
17
+ copy . updates . push ( update )
18
+ }
19
+ } )
20
+
21
+ if ( copy . updates . length > 0 ) {
22
+ if ( copy . context == app . selfContext ) {
23
+ copy . context = 'vessels.self'
24
+ }
25
+ node . send ( { payload : copy } )
26
+ }
27
+ }
11
28
}
12
29
13
30
signalk . on ( 'delta' , on_delta )
You can’t perform that action at this time.
0 commit comments