@@ -84,10 +84,13 @@ module.exports = function (RED) {
84
84
this . propertyName = config . name ;
85
85
this . sendasdevice = config . sendasdevice ;
86
86
this . device = config . device
87
-
87
+ const opts = { }
88
+ if ( this . organization ) {
89
+ opts . xOrganization = this . organization ;
90
+ }
88
91
this . on ( 'input' , async function ( msg ) {
89
92
try {
90
- await this . arduinoRestClient . setProperty ( this . thing , this . propertyId , msg . payload , this . sendasdevice ? this . device : undefined ) ;
93
+ await this . arduinoRestClient . setProperty ( this . thing , this . propertyId , msg . payload , opts , this . sendasdevice ? this . device : undefined ) ;
91
94
var s ;
92
95
if ( typeof msg . payload !== "object" ) {
93
96
s = getStatus ( msg . payload ) ;
@@ -157,6 +160,10 @@ module.exports = function (RED) {
157
160
this . thing = config . thing ;
158
161
this . propertyId = config . property ;
159
162
this . propertyName = config . name ;
163
+ const opts = { }
164
+ if ( this . organization ) {
165
+ opts . xOrganization = this . organization ;
166
+ }
160
167
node . on ( 'input' , async function ( ) {
161
168
try {
162
169
const now = moment ( ) ;
@@ -165,7 +172,7 @@ module.exports = function (RED) {
165
172
if ( count !== null && count !== "" && count !== undefined && Number . isInteger ( parseInt ( count ) ) && parseInt ( count ) !== 0 ) {
166
173
const start = now . subtract ( count * this . timeWindowUnit , 'second' ) . format ( ) ;
167
174
168
- const result = await this . arduinoRestClient . getSeries ( this . thing , this . propertyId , start , end ) ;
175
+ const result = await this . arduinoRestClient . getSeries ( this . thing , this . propertyId , start , end , opts ) ;
169
176
const times = result . responses [ 0 ] . times ;
170
177
const values = result . responses [ 0 ] . values ;
171
178
let data = [ ] ;
@@ -241,19 +248,19 @@ module.exports = function (RED) {
241
248
this . status ( { } ) ;
242
249
this . timeWindowCount = config . timeWindowCount ;
243
250
this . timeWindowUnit = config . timeWindowUnit ;
251
+ this . organization = config . organization ;
244
252
if ( connectionConfig && config . thing !== "" && config . thing !== "0" && config . property !== "" && config . property !== "0" ) {
245
253
try {
246
254
this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
247
255
if ( this . arduinoRestClient ) {
248
256
this . arduinoRestClient . openConnections ++ ;
249
257
if ( config . thing !== "" && config . property !== "" ) {
250
- this . organization = config . organization ;
251
258
this . thing = config . thing ;
252
259
this . propertyId = config . property ;
253
260
this . propertyName = config . name ;
254
261
const pollTime = this . timeWindowCount * this . timeWindowUnit ;
255
262
if ( pollTime !== null && pollTime !== "" && pollTime !== undefined && Number . isInteger ( parseInt ( pollTime ) ) && parseInt ( pollTime ) !== 0 ) {
256
- this . poll ( connectionConfig , pollTime ) ;
263
+ this . poll ( connectionConfig , pollTime , this . organization ) ;
257
264
this . on ( 'close' , function ( done ) {
258
265
connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
259
266
if ( this . pollTimeoutPoll )
@@ -283,9 +290,13 @@ module.exports = function (RED) {
283
290
realConstructor . apply ( this , [ config ] ) ;
284
291
}
285
292
ArduinoIotInputPoll . prototype = {
286
- poll : async function ( connectionConfig , pollTime ) {
293
+ poll : async function ( connectionConfig , pollTime , organization ) {
287
294
try {
288
- const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId ) ;
295
+ const opts = { }
296
+ if ( organization ) {
297
+ opts . xOrganization = organization ;
298
+ }
299
+ const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId , opts ) ;
289
300
this . send (
290
301
{
291
302
topic : property . name ,
@@ -298,7 +309,7 @@ module.exports = function (RED) {
298
309
this . status ( { fill : "grey" , shape : "dot" , text : s } ) ;
299
310
else
300
311
this . status ( { } ) ;
301
- this . pollTimeoutPoll = setTimeout ( ( ) => { this . poll ( connectionConfig , pollTime ) } , pollTime * 1000 ) ;
312
+ this . pollTimeoutPoll = setTimeout ( ( ) => { this . poll ( connectionConfig , pollTime , organization ) } , pollTime * 1000 ) ;
302
313
} catch ( err ) {
303
314
if ( err . response && err . response . res && err . response . request ) {
304
315
console . log ( 'statusCode: ' + err . response . res . statusCode + '\n' +
@@ -336,9 +347,13 @@ module.exports = function (RED) {
336
347
this . thing = config . thing ;
337
348
this . propertyId = config . property ;
338
349
this . propertyName = config . name ;
350
+ const opts = { }
351
+ if ( this . organization ) {
352
+ opts . xOrganization = this . organization ;
353
+ }
339
354
node . on ( 'input' , async function ( ) {
340
355
try {
341
- const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId ) ;
356
+ const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId , opts ) ;
342
357
this . send (
343
358
{
344
359
topic : property . name ,
0 commit comments