fjs21 / homebridge-blueair

BlueAir air purifier plugin for homebridge
https://www.npmjs.com/package/@fjs21/homebridge-blueair
Apache License 2.0
50 stars 6 forks source link

time outs #46

Open ulte opened 2 years ago

ulte commented 2 years ago

Anyone else getting timeouts? Wonder if i'm getting rate limited given there seems to be a few queries inside of 5 seconds. Where would I modify the 5 second timer?

[5/27/2022, 2:29:07 PM] [BlueAir] BlueAir API: error - Time out on BlueAir connection.
[5/27/2022, 2:29:07 PM] [BlueAir] air: getDeviceAttributes failed.
[5/27/2022, 2:29:07 PM] [BlueAir] updateAccessoryCharacteristic failed (redacted)
[5/27/2022, 2:29:12 PM] [BlueAir] BlueAir API: error - Time out on BlueAir connection.
[5/27/2022, 2:29:12 PM] [BlueAir] air: getDeviceDatapoint failed.
[5/27/2022, 2:29:12 PM] [BlueAir] updateAccessoryCharacteristic failed (redacted)
[5/27/2022, 2:30:12 PM] [BlueAir] BlueAir API: error - Time out on BlueAir connection.
[5/27/2022, 2:30:12 PM] [BlueAir] air: getDeviceInfo failed.
fjs21 commented 2 years ago

I have these time outs as well. I'm guessing you have multiple devices? The issue is that every device is queried almost simultaneously and independently. This overloads the BlueAir API and you get a time out. If I introduce a delay to the requests, then Homebridge will timeout and complain that we are slowing down the server. I don't have any easy fix for this at this point in time and while it is annoying it doesn't seem to affect functionality too much. Would be great to get fresh eyes on this problem.

ulte commented 2 years ago

One device. Is there a cfg in a file that I can tweak the timer interval?

fjs21 commented 2 years ago

I'll expose the time out interval in the settings in a future version.

simplytoast1 commented 9 months ago

I think this will help with the issues I am having as well.

It gets to the point where I get the post data actually in the logs....

[9/11/2023, 6:15:04 AM] [@fjs21/homebridge-blueair] Body {
  _abort: false,
  _bytes: 60,
  _raw: [
    <Buffer 7b 22 4d 65 73 73 61 67 65 22 3a 22 55 73 65 72 20 69 73 20 6e 6f 74 20 61 75 74 68 6f 72 69 7a 65 64 20 74 6f 20 61 63 63 65 73 73 20 74 68 69 73 20 ... 10 more bytes>
  ],
  body: Gunzip {
    [Symbol(kCallback)]: null,
    [Symbol(kCapture)]: false,
    [Symbol(kError)]: null,
    _chunkSize: 16384,
    _defaultFlushFlag: 0,
    _defaultFullFlushFlag: 3,
    _events: [Object: null prototype] {
      data: [Function (anonymous)],
      end: [Function (anonymous)],
      error: [Function (anonymous)],
      prefinish: [Function: prefinish]
    },
    _eventsCount: 4,
    _finishFlushFlag: 4,
    _handle: null,
    _info: undefined,
    _level: -1,
    _maxListeners: undefined,
    _maxOutputLength: 4294967296,
    _outBuffer: <Buffer 7b 22 4d 65 73 73 61 67 65 22 3a 22 55 73 65 72 20 69 73 20 6e 6f 74 20 61 75 74 68 6f 72 69 7a 65 64 20 74 6f 20 61 63 63 65 73 73 20 74 68 69 73 20 ... 16334 more bytes>,
    _outOffset: 60,
    _readableState: ReadableState {
      [Symbol(kPaused)]: false,
      autoDestroy: true,
      awaitDrainWriters: null,
      buffer: BufferList { head: null, length: 0, tail: null },
      closeEmitted: true,
      closed: true,
      constructed: true,
      dataEmitted: true,
      decoder: null,
      defaultEncoding: 'utf8',
      destroyed: true,
      emitClose: true,
      emittedReadable: false,
      encoding: null,
      endEmitted: true,
      ended: true,
      errorEmitted: false,
      errored: null,
      flowing: true,
      highWaterMark: 16384,
      length: 0,
      multiAwaitDrain: false,
      needReadable: false,
      objectMode: false,
      pipes: [],
      readableListening: false,
      reading: false,
      readingMore: false,
      resumeScheduled: false,
      sync: false
    },
    _strategy: 0,
    _writableState: WritableState {
      [Symbol(kOnFinished)]: [],
      afterWriteTickInfo: null,
      allBuffers: true,
      allNoop: true,
      autoDestroy: true,
      bufferProcessing: false,
      buffered: [],
      bufferedIndex: 0,
      closeEmitted: true,
      closed: true,
      constructed: true,
      corked: 0,
      decodeStrings: true,
      defaultEncoding: 'utf8',
      destroyed: true,
      emitClose: true,
      ended: true,
      ending: true,
      errorEmitted: false,
      errored: null,
      finalCalled: true,
      finished: true,
      highWaterMark: 16384,
      length: 0,
      needDrain: false,
      objectMode: false,
      onwrite: [Function: bound onwrite],
      pendingcb: 0,
      prefinished: true,
      sync: false,
      writecb: null,
      writelen: 0,
      writing: false
    },
    _writeState: Uint32Array(2) [ 16324, 0 ],
    allowHalfOpen: true,
    bytesWritten: 78
  },
  bodyUsed: true,