@@ -67,10 +67,6 @@ module.exports = function (RED) {
67
67
}
68
68
69
69
this . registerChildNode = function ( nodeId , callbacks ) {
70
- // console.log(
71
- // `registerChildNode() for ${nodeId} | allowed: ${this.allowedDeviceCount}`
72
- // )
73
-
74
70
if ( Object . keys ( this . childNodes ) . length >= this . allowedDeviceCount ) {
75
71
callbacks . setStatus ( {
76
72
shape : 'dot' ,
@@ -84,8 +80,6 @@ module.exports = function (RED) {
84
80
85
81
if ( Object . keys ( this . childNodes ) . length == 1 ) {
86
82
//first child node is registering!
87
- //console.log('first child node registering!!!')
88
-
89
83
this . connectAndSubscribe ( )
90
84
}
91
85
@@ -108,7 +102,6 @@ module.exports = function (RED) {
108
102
}
109
103
110
104
this . unregisterChildNode = async function ( nodeId ) {
111
- //console.log(`unregisterChildNode() for ${nodeId}`)
112
105
delete this . childNodes [ nodeId ]
113
106
114
107
if ( Object . keys ( this . childNodes ) . length == 0 ) {
@@ -149,6 +142,22 @@ module.exports = function (RED) {
149
142
} )
150
143
}
151
144
145
+ this . requestConfigDebounced = debounce ( this . requestConfig , 1000 )
146
+
147
+ this . markAsConnected = function ( ) {
148
+ this . publish ( `$aws/things/${ this . credentials . thingId } /shadow/update` , {
149
+ state : {
150
+ reported : {
151
+ connected : true ,
152
+ vsh_version : VSH_VERSION ,
153
+ nr_version : RED . version ( ) ,
154
+ } ,
155
+ } ,
156
+ } )
157
+ }
158
+
159
+ this . markAsConnectedDebounced = debounce ( this . markAsConnected , 7000 )
160
+
152
161
this . publish = async function ( topic , message ) {
153
162
if ( ! this . mqttClient ) {
154
163
return
@@ -161,8 +170,6 @@ module.exports = function (RED) {
161
170
return await this . mqttClient . publish ( topic , message )
162
171
}
163
172
164
- this . requestConfigDebounced = debounce ( this . requestConfig , 1000 )
165
-
166
173
this . triggerChangeReport = function ( {
167
174
endpointId,
168
175
properties,
@@ -569,18 +576,7 @@ module.exports = function (RED) {
569
576
text : 'online' ,
570
577
} )
571
578
572
- this . publish (
573
- `$aws/things/${ this . credentials . thingId } /shadow/update` ,
574
- {
575
- state : {
576
- reported : {
577
- connected : true ,
578
- vsh_version : VSH_VERSION ,
579
- nr_version : RED . version ( ) ,
580
- } ,
581
- } ,
582
- }
583
- )
579
+ this . markAsConnectedDebounced ( )
584
580
} ,
585
581
586
582
onDisconnect : ( ) => {
0 commit comments