@@ -84,10 +84,13 @@ module.exports = function (RED) {
8484 this . propertyName = config . name ;
8585 this . sendasdevice = config . sendasdevice ;
8686 this . device = config . device
87-
87+ const opts = { }
88+ if ( this . organization ) {
89+ opts . xOrganization = this . organization ;
90+ }
8891 this . on ( 'input' , async function ( msg ) {
8992 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 ) ;
9194 var s ;
9295 if ( typeof msg . payload !== "object" ) {
9396 s = getStatus ( msg . payload ) ;
@@ -157,6 +160,10 @@ module.exports = function (RED) {
157160 this . thing = config . thing ;
158161 this . propertyId = config . property ;
159162 this . propertyName = config . name ;
163+ const opts = { }
164+ if ( this . organization ) {
165+ opts . xOrganization = this . organization ;
166+ }
160167 node . on ( 'input' , async function ( ) {
161168 try {
162169 const now = moment ( ) ;
@@ -165,7 +172,7 @@ module.exports = function (RED) {
165172 if ( count !== null && count !== "" && count !== undefined && Number . isInteger ( parseInt ( count ) ) && parseInt ( count ) !== 0 ) {
166173 const start = now . subtract ( count * this . timeWindowUnit , 'second' ) . format ( ) ;
167174
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 ) ;
169176 const times = result . responses [ 0 ] . times ;
170177 const values = result . responses [ 0 ] . values ;
171178 let data = [ ] ;
@@ -241,19 +248,19 @@ module.exports = function (RED) {
241248 this . status ( { } ) ;
242249 this . timeWindowCount = config . timeWindowCount ;
243250 this . timeWindowUnit = config . timeWindowUnit ;
251+ this . organization = config . organization ;
244252 if ( connectionConfig && config . thing !== "" && config . thing !== "0" && config . property !== "" && config . property !== "0" ) {
245253 try {
246254 this . arduinoRestClient = await connectionManager . getClientHttp ( connectionConfig ) ;
247255 if ( this . arduinoRestClient ) {
248256 this . arduinoRestClient . openConnections ++ ;
249257 if ( config . thing !== "" && config . property !== "" ) {
250- this . organization = config . organization ;
251258 this . thing = config . thing ;
252259 this . propertyId = config . property ;
253260 this . propertyName = config . name ;
254261 const pollTime = this . timeWindowCount * this . timeWindowUnit ;
255262 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 ) ;
257264 this . on ( 'close' , function ( done ) {
258265 connectionManager . deleteClientHttp ( connectionConfig . credentials . clientid ) . then ( ( ) => { done ( ) ; } ) ;
259266 if ( this . pollTimeoutPoll )
@@ -283,9 +290,13 @@ module.exports = function (RED) {
283290 realConstructor . apply ( this , [ config ] ) ;
284291 }
285292 ArduinoIotInputPoll . prototype = {
286- poll : async function ( connectionConfig , pollTime ) {
293+ poll : async function ( connectionConfig , pollTime , organization ) {
287294 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 ) ;
289300 this . send (
290301 {
291302 topic : property . name ,
@@ -298,7 +309,7 @@ module.exports = function (RED) {
298309 this . status ( { fill : "grey" , shape : "dot" , text : s } ) ;
299310 else
300311 this . status ( { } ) ;
301- this . pollTimeoutPoll = setTimeout ( ( ) => { this . poll ( connectionConfig , pollTime ) } , pollTime * 1000 ) ;
312+ this . pollTimeoutPoll = setTimeout ( ( ) => { this . poll ( connectionConfig , pollTime , organization ) } , pollTime * 1000 ) ;
302313 } catch ( err ) {
303314 if ( err . response && err . response . res && err . response . request ) {
304315 console . log ( 'statusCode: ' + err . response . res . statusCode + '\n' +
@@ -336,9 +347,13 @@ module.exports = function (RED) {
336347 this . thing = config . thing ;
337348 this . propertyId = config . property ;
338349 this . propertyName = config . name ;
350+ const opts = { }
351+ if ( this . organization ) {
352+ opts . xOrganization = this . organization ;
353+ }
339354 node . on ( 'input' , async function ( ) {
340355 try {
341- const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId ) ;
356+ const property = await this . arduinoRestClient . getProperty ( this . thing , this . propertyId , opts ) ;
342357 this . send (
343358 {
344359 topic : property . name ,
0 commit comments