lukasroegner / homebridge-tado-smart-thermostat

Plugin for using Tado devices in homebridge.
MIT License
13 stars 4 forks source link

Failed requests with scenes - Improve reliability #30

Open bxlouis opened 3 years ago

bxlouis commented 3 years ago

Hi, I have been using the plugin for quite a while now and I am experiencing reliability issues on a regular basis (every day). The issue is that almost every time a scene is triggered by Homekit, some of my thermostats fail to change their temperature.

[1/17/2021, 9:45:49 PM] [TadoPlatform] 2 - Failed to set target temperature to 19 [1/17/2021, 9:46:09 PM] [TadoPlatform] 1 - Failed to switch target state to HEATING [1/17/2021, 9:46:09 PM] [TadoPlatform] 2 - Failed to set target temperature to 19 [1/18/2021, 10:13:39 AM] [TadoPlatform] 2 - Failed to set target temperature to 19 [1/18/2021, 3:19:17 PM] [TadoPlatform] 5 - Failed to switch target state to AUTO

I am not sure where this issue comes from but since I have multiple thermostats triggered at the same time in my scenes, I guess that maybe a delay between each request might solve the issue?

lukasroegner commented 3 years ago

I've added advanced error output to the latest plugin version 0.8.1. Please start Homebridge in debug mode (parameter -D) to get the whole output. We can check the errors that occur afterwards.

I created test scenes that set all of my 6 Tado devices at once, I didn't have any issue, even when pressing "Test scene" multiple times in a row to cause a lot of requests.

bxlouis commented 3 years ago

Thanks for your prompt feedback @lukasroegner! I turned on Debug mode. I also noticed that the request seem to be sent twice everytime which seems new (or I did not notice before?).

I'm able to reproduce the error by going from HEAT to AUTO status almost every time.

`[1/21/2021, 3:25:49 PM] [TadoPlatform] 3 - Switch target state to AUTO [1/21/2021, 3:25:49 PM] [TadoPlatform] 3 - Switch target state to AUTO [1/21/2021, 3:25:49 PM] [TadoPlatform] 3 - Failed to switch target state to AUTO [1/21/2021, 3:25:49 PM] [TadoPlatform] Error: Request failed with status code 500 at createError (/homebridge/node_modules/homebridge-tado-smart-thermostat/node_modules/axios/lib/core/createError.js:16:15) at settle (/homebridge/node_modules/homebridge-tado-smart-thermostat/node_modules/axios/lib/core/settle.js:18:12) at IncomingMessage.handleStreamEnd (/homebridge/node_modules/homebridge-tado-smart-thermostat/node_modules/axios/lib/adapters/http.js:202:11) at IncomingMessage.emit (events.js:327:22) at endReadableNT (internal/streams/readable.js:1327:12) at processTicksAndRejections (internal/process/task_queues.js:80:21) { config: { adapter: [Function: httpAdapter], transformRequest: { '0': [Function: transformRequest] }, transformResponse: { '0': [Function: transformResponse] }, timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], headers: { Accept: 'application/json, text/plain, /', Authorization: 'Bearer XXX', 'Content-Type': 'application/json;charset=utf-8', 'User-Agent': 'axios/0.18.1', 'Content-Length': 2 }, method: 'delete', url: 'https://my.tado.com/api/v2/homes/402537/zones/3/overlay', data: '{}' }, request: <ref 1> ClientRequest { _events: [Object: null prototype] { socket: [Function (anonymous)], abort: [Function (anonymous)], aborted: [Function (anonymous)], error: [Function (anonymous)], timeout: [Function (anonymous)], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, secureConnecting: false, _SNICallback: null, servername: 'my.tado.com', alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object: null prototype], _eventsCount: 10, connecting: false, _hadError: false, _parent: null, _host: 'my.tado.com', _readableState: [ReadableState], _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: false, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: [TLSWrap], _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Circular 1],

  [Symbol(verified)]: true,
  [Symbol(pendingSession)]: null,
  [Symbol(async_id_symbol)]: 8359,
  [Symbol(kHandle)]: [TLSWrap],
  [Symbol(kSetNoDelay)]: false,
  [Symbol(lastWriteQueueSize)]: 0,
  [Symbol(timeout)]: null,
  [Symbol(kBuffer)]: null,
  [Symbol(kBufferCb)]: null,
  [Symbol(kBufferGen)]: null,
  [Symbol(kCapture)]: false,
  [Symbol(kBytesRead)]: 0,
  [Symbol(kBytesWritten)]: 0,
  [Symbol(connect-options)]: [Object],
  [Symbol(RequestTimeout)]: undefined
},
_header: 'DELETE /api/v2/homes/402537/zones/3/overlay HTTP/1.1\r\n' +
  'Accept: application/json, text/plain, */*\r\n' +
  'Authorization: Bearer XXX' +
  'Content-Type: application/json;charset=utf-8\r\n' +
  'User-Agent: axios/0.18.1\r\n' +
  'Content-Length: 2\r\n' +
  'Host: my.tado.com\r\n' +
  'Connection: close\r\n' +
  '\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: noopPendingOutput],
agent: Agent {
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  defaultPort: 443,
  protocol: 'https:',
  options: [Object],
  requests: {},
  sockets: [Object],
  freeSockets: {},
  keepAliveMsecs: 1000,
  keepAlive: false,
  maxSockets: Infinity,
  maxFreeSockets: 256,
  scheduling: 'fifo',
  maxTotalSockets: Infinity,
  totalSocketCount: 2,
  maxCachedSessions: 100,
  _sessionCache: [Object],
  [Symbol(kCapture)]: false
},
socketPath: undefined,
method: 'DELETE',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/api/v2/homes/402537/zones/3/overlay',
_ended: true,
res: IncomingMessage {
  _readableState: [ReadableState],
  _events: [Object: null prototype],
  _eventsCount: 3,
  _maxListeners: undefined,
  socket: [TLSSocket],
  httpVersionMajor: 1,
  httpVersionMinor: 1,
  httpVersion: '1.1',
  complete: true,
  headers: [Object],
  rawHeaders: [Array],
  trailers: {},
  rawTrailers: [],
  aborted: false,
  upgrade: false,
  url: '',
  method: null,
  statusCode: 500,
  statusMessage: '',
  client: [TLSSocket],
  _consuming: true,
  _dumped: false,
  req: [Circular *1],
  responseUrl: 'https://my.tado.com/api/v2/homes/402537/zones/3/overlay',
  redirects: [],
  [Symbol(kCapture)]: false,
  [Symbol(RequestTimeout)]: undefined
},
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'my.tado.com',
protocol: 'https:',
_redirectable: Writable {
  _writableState: [WritableState],
  _events: [Object: null prototype],
  _eventsCount: 2,
  _maxListeners: undefined,
  _options: [Object],
  _redirectCount: 0,
  _redirects: [],
  _requestBodyLength: 2,
  _requestBodyBuffers: [],
  _onNativeResponse: [Function (anonymous)],
  _currentRequest: [Circular *1],
  _currentUrl: 'https://my.tado.com/api/v2/homes/402537/zones/3/overlay',
  [Symbol(kCapture)]: false
},
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype] {
  accept: [Array],
  authorization: [Array],
  'content-type': [Array],
  'user-agent': [Array],
  'content-length': [Array],
  host: [Array]
}

}, response: { status: 500, statusText: '', headers: { date: 'Thu, 21 Jan 2021 14:25:49 GMT', 'content-type': 'application/json;charset=UTF-8', 'transfer-encoding': 'chunked', connection: 'close', 'set-cookie': [Array], server: 'nginx', 'x-application-context': 'application:production', 'strict-transport-security': 'max-age=31536000' }, config: { adapter: [Function: httpAdapter], transformRequest: [Object], transformResponse: [Object], timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], headers: [Object], method: 'delete', url: 'https://my.tado.com/api/v2/homes/402537/zones/3/overlay', data: '{}' }, request: <ref 1> ClientRequest { _events: [Object: null prototype], _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, destroyed: false, _last: true, chunkedEncoding: false, shouldKeepAlive: false, _defaultKeepAlive: true, useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [TLSSocket], _header: 'DELETE /api/v2/homes/402537/zones/3/overlay HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /*\r\n' + 'Authorization: Bearer XXX' + 'Content-Type: application/json;charset=utf-8\r\n' + 'User-Agent: axios/0.18.1\r\n' + 'Content-Length: 2\r\n' + 'Host: my.tado.com\r\n' + 'Connection: close\r\n' + '\r\n', _keepAliveTimeout: 0, _onPendingData: [Function: noopPendingOutput], agent: [Agent], socketPath: undefined, method: 'DELETE', maxHeaderSize: undefined, insecureHTTPParser: undefined, path: '/api/v2/homes/402537/zones/3/overlay', _ended: true, res: [IncomingMessage], aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, host: 'my.tado.com', protocol: 'https:', _redirectable: [Writable],

  [Symbol(kNeedDrain)]: false,
  [Symbol(corked)]: 0,
  [Symbol(kOutHeaders)]: [Object: null prototype]
},
data: { errors: [Array] }

} } [1/21/2021, 3:25:49 PM] [TadoPlatform] 3 - Updated state. [1/21/2021, 3:25:49 PM] [TadoPlatform] 3 - new state: {"tadoMode":"HOME","geolocationOverride":false,"geolocationOverrideDisableTime":null,"preparation":null,"setting":{"type":"HEATING","power":"ON","temperature":{"celsius":23,"fahrenheit":73.4}},"overlayType":null,"overlay":null,"openWindow":null,"nextScheduleChange":{"start":"2021-01-21T21:00:00Z","setting":{"type":"HEATING","power":"ON","temperature":{"celsius":19,"fahrenheit":66.2}}},"nextTimeBlock":{"start":"2021-01-21T21:00:00.000Z"},"link":{"state":"ONLINE"},"activityDataPoints":{"heatingPower":{"type":"PERCENTAGE","percentage":0,"timestamp":"2021-01-21T14:06:51.159Z"}},"sensorDataPoints":{"insideTemperature":{"celsius":23.99,"fahrenheit":75.18,"timestamp":"2021-01-21T14:23:50.180Z","type":"TEMPERATURE","precision":{"celsius":1,"fahrenheit":1}},"humidity":{"type":"PERCENTAGE","percentage":47.8,"timestamp":"2021-01-21T14:23:50.180Z"}}}`