@@ -98,7 +98,7 @@ export class BluelinkCanada extends Bluelink {
9898 req . method = 'GET'
9999 await req . load ( )
100100 for ( const cookie of req . response . cookies ) {
101- if ( cookie . name === 'dtCookie ' ) {
101+ if ( cookie . name . toLowerCase ( ) === 'dtcookie ' ) {
102102 return `dtCookie=${ cookie . value } `
103103 }
104104 }
@@ -298,15 +298,6 @@ export class BluelinkCanada extends Bluelink {
298298 throw Error ( error )
299299 }
300300
301- protected getTransactionId ( headers : Record < string , any > ) : string {
302- // response is inconsistant re case
303- if ( Object . hasOwn ( headers , 'transactionId' ) ) return headers . transactionId
304- if ( Object . hasOwn ( headers , 'transactionid' ) ) return headers . transactionid
305- const error = `Failed to extract transaction id from: ${ JSON . stringify ( headers ) } `
306- if ( this . config . debugLogging ) this . logger . log ( error )
307- throw Error ( error )
308- }
309-
310301 protected async pollForCommandCompletion (
311302 id : string ,
312303 authCode : string ,
@@ -376,8 +367,8 @@ export class BluelinkCanada extends Bluelink {
376367 validResponseFunction : this . requestResponseValid ,
377368 } )
378369 if ( this . requestResponseValid ( resp . resp , resp . json ) . valid ) {
379- const transactionId = this . getTransactionId ( resp . resp . headers )
380- return await this . pollForCommandCompletion ( id , authCode , transactionId )
370+ const transactionId = this . caseInsensitiveParamExtraction ( 'transactionid' , resp . resp . headers )
371+ if ( transactionId ) return await this . pollForCommandCompletion ( id , authCode , transactionId )
381372 }
382373 const error = `Failed to send lockUnlock command: ${ JSON . stringify ( resp . json ) } request ${ JSON . stringify ( this . debugLastRequest ) } `
383374 if ( this . config . debugLogging ) this . logger . log ( error )
@@ -411,8 +402,8 @@ export class BluelinkCanada extends Bluelink {
411402 validResponseFunction : this . requestResponseValid ,
412403 } )
413404 if ( this . requestResponseValid ( resp . resp , resp . json ) . valid ) {
414- const transactionId = this . getTransactionId ( resp . resp . headers )
415- return await this . pollForCommandCompletion ( id , authCode , transactionId )
405+ const transactionId = this . caseInsensitiveParamExtraction ( 'transactionid' , resp . resp . headers )
406+ if ( transactionId ) return await this . pollForCommandCompletion ( id , authCode , transactionId )
416407 }
417408 const error = `Failed to send charge command: ${ JSON . stringify ( resp . json ) } request ${ JSON . stringify ( this . debugLastRequest ) } `
418409 if ( this . config . debugLogging ) this . logger . log ( error )
@@ -456,8 +447,8 @@ export class BluelinkCanada extends Bluelink {
456447 validResponseFunction : this . requestResponseValid ,
457448 } )
458449 if ( this . requestResponseValid ( resp . resp , resp . json ) . valid ) {
459- const transactionId = this . getTransactionId ( resp . resp . headers )
460- return await this . pollForCommandCompletion ( id , authCode , transactionId )
450+ const transactionId = this . caseInsensitiveParamExtraction ( 'transactionid' , resp . resp . headers )
451+ if ( transactionId ) return await this . pollForCommandCompletion ( id , authCode , transactionId )
461452 }
462453 const error = `Failed to send climateOff command: ${ JSON . stringify ( resp . json ) } request ${ JSON . stringify ( this . debugLastRequest ) } `
463454 if ( this . config . debugLogging ) this . logger . log ( error )
@@ -480,8 +471,8 @@ export class BluelinkCanada extends Bluelink {
480471 validResponseFunction : this . requestResponseValid ,
481472 } )
482473 if ( this . requestResponseValid ( resp . resp , resp . json ) . valid ) {
483- const transactionId = this . getTransactionId ( resp . resp . headers )
484- return await this . pollForCommandCompletion ( id , authCode , transactionId )
474+ const transactionId = this . caseInsensitiveParamExtraction ( 'transactionid' , resp . resp . headers )
475+ if ( transactionId ) return await this . pollForCommandCompletion ( id , authCode , transactionId )
485476 }
486477 const error = `Failed to send climateOff command: ${ JSON . stringify ( resp . json ) } request ${ JSON . stringify ( this . debugLastRequest ) } `
487478 if ( this . config . debugLogging ) this . logger . log ( error )
0 commit comments