homebridge-lg-thinq-ac
homebridge-lg-thinq-ac copied to clipboard
Snapshot missing for Thinq1 devices: 'airState.operation' of undefined
After authentication logs give a lot of error. But my ac appear at my home app. Status or temp does not work.
`[2020-5-12 22:41:02] [LgThinqAirConditioner] Initializing LgThinqAirConditioner platform...
[2020-5-12 22:41:04] [LgThinqAirConditioner] Error: Auth not ready yet, please log in. at ExampleHomebridgePlatform.inititializeAuth (/usr/local/lib/node_modules/homebridge-lg-thinq-ac/src/platform.ts:129:13) at ExampleHomebridgePlatform.initialize (/usr/local/lib/node_modules/homebridge-lg-thinq-ac/src/platform.ts:85:18) at processTicksAndRejections (internal/process/task_queues.js:97:5)
[2020-5-12 22:42:58] [LgThinqAirConditioner] Error: getaddrinfo EAI_AGAIN route.lgthinq.com at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:64:26) { errno: ‘EAI_AGAIN’, code: ‘EAI_AGAIN’, syscall: ‘getaddrinfo’, hostname: ‘route.lgthinq.com’, config: { url: ‘https://route.lgthinq.com:46030/v1/service/application/gateway-uri’, method: ‘get’, headers: { Accept: ‘application/json’, ‘X-Thinq-App-Ver’: ‘3.0.2100’, ‘X-Thinq-App-Type’: ‘NUTS’, ‘X-Language-Code’: ‘tr-TR’, ‘X-Client-Id’: ‘dda6bf26a674a02bc1e8612e9884b2253fda2b2fbc57b47702a80011b72f02ca’, ‘X-Thinq-App-Level’: ‘PRD’, ‘X-Service-Code’: ‘SVC202’, ‘Accept-Language’: ‘tr-TR’, ‘X-Message-Id’: ‘89ZfpKmsH8qXUmar7uQkX.’, ‘Content-Type’: ‘application/json;charset=UTF-8’, ‘X-Api-Key’: ‘VGhpblEyLjAgU0VSVklDRQ==‘, ‘X-Thinq-App-Os’: ‘IOS’, ‘X-Country-Code’: ‘TR’, ‘X-Service-Phase’: ‘OP’, ‘Accept-Encoding’: ‘gzip’, ‘User-Agent’: ‘axios/0.19.2’ }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 0, adapter: [Function: httpAdapter], responseType: ‘json’, xsrfCookieName: ‘XSRF-TOKEN’, xsrfHeaderName: ‘X-XSRF-TOKEN’, maxContentLength: -1, validateStatus: [Function: validateStatus], data: undefined }, request: Writable { _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: false, needDrain: false, ending: false, ended: false, finished: false, destroyed: false, decodeStrings: true, defaultEncoding: ‘utf8’, length: 0, writing: false, corked: 0, sync: true, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, bufferedRequest: null, lastBufferedRequest: null, pendingcb: 0, prefinished: false, errorEmitted: false, emitClose: true, autoDestroy: false, bufferedRequestCount: 0, corkedRequestsFree: [Object] }, writable: true, _events: [Object: null prototype] { response: [Function: handleResponse], error: [Function: handleRequestError] }, _eventsCount: 2, _maxListeners: undefined, _options: { protocol: ‘https:’, maxRedirects: 21, maxBodyLength: 10485760, path: ‘/v1/service/application/gateway-uri’, method: ‘GET’, headers: [Object], agent: undefined, agents: [Object], auth: undefined, hostname: ‘route.lgthinq.com’, port: ‘46030’, nativeProtocols: [Object], pathname: ‘/v1/service/application/gateway-uri’ }, _redirectCount: 0, _redirects: [], _requestBodyLength: 0, _requestBodyBuffers: [], _onNativeResponse: [Function], _currentRequest: ClientRequest { _events: [Object: null prototype], _eventsCount: 6, _maxListeners: undefined, outputData: [], outputSize: 0, writable: true, _last: true, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: false, sendDate: false, _removedConnection: false, _removedContLen: false, _removedTE: false, _contentLength: 0, _hasBody: true, _trailer: ‘’, finished: true, _headerSent: true, socket: [TLSSocket], connection: [TLSSocket], _header: ‘GET /v1/service/application/gateway-uri HTTP/1.1\r\n’ + ‘Accept: application/json\r\n’ + ‘X-Thinq-App-Ver: 3.0.2100\r\n’ + ‘X-Thinq-App-Type: NUTS\r\n’ + ‘X-Language-Code: tr-TR\r\n’ + ‘X-Client-Id: dda6bf26a674a02bc1e8612e9884b2253fda2b2fbc57b47702a80011b72f02ca\r\n’ + ‘X-Thinq-App-Level: PRD\r\n’ + ‘X-Service-Code: SVC202\r\n’ + ‘Accept-Language: tr-TR\r\n’ + ‘X-Message-Id: 89ZfpKmsH8qXUmar7uQkX.\r\n’ + ‘Content-Type: application/json;charset=UTF-8\r\n’ + ‘X-Api-Key: VGhpblEyLjAgU0VSVklDRQ==\r\n’ + ‘X-Thinq-App-Os: IOS\r\n’ + ‘X-Country-Code: TR\r\n’ + ‘X-Service-Phase: OP\r\n’ + ‘Accept-Encoding: gzip\r\n’ + ‘User-Agent: axios/0.19.2\r\n’ + ‘Host: route.lgthinq.com:46030\r\n’ + ‘Connection: close\r\n’ + ‘\r\n’, _onPendingData: [Function: noopPendingOutput], agent: [Agent], socketPath: undefined, method: ‘GET’, insecureHTTPParser: undefined, path: ‘/v1/service/application/gateway-uri’, _ended: false, res: null, aborted: false, timeoutCb: null, upgradeOrConnect: false, parser: null, maxHeadersCount: null, reusedSocket: false, _redirectable: [Circular], [Symbol(kCapture)]: false, [Symbol(kNeedDrain)]: false, [Symbol(corked)]: 0, [Symbol(kOutHeaders)]: [Object: null prototype] }, _currentUrl: ‘https://route.lgthinq.com:46030/v1/service/application/gateway-uri’, [Symbol(kCapture)]: false }, response: undefined, isAxiosError: true, toJSON: [Function] }
[2020-5-12 22:44:29] [LgThinqAirConditioner] Initializing LgThinqAirConditioner platform... [2020-5-12 22:44:29] Loading 1 accessories...
[2020-5-12 22:44:32] [LgThinqAirConditioner] Initiating auth with provided redirect URL
[2020-5-12 22:44:45] [LgThinqAirConditioner] Discover found 1 total devices [2020-5-12 22:44:45] [LgThinqAirConditioner] Registering new accessory: KLİMA [2020-5-12 22:44:45] [LgThinqAirConditioner] Starting refresh interval (set to 1 minutes) [2020-5-12 22:44:47] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property ‘airState.operation’ of undefined [2020-5-12 22:45:46] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property ‘airState.operation’ of undefined [2020-5-12 22:46:06] [LgThinqAirConditioner] Failed to set power state off Error: Request failed with status code 400 [2020-5-12 22:46:46] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property ‘airState.operation’ of undefined
`
What model air conditioner do you have? Have you tried restarting Homebridge again?
Yes I tried restart. My model is ES-W12GJ2F0
Ok that’s good to know- I’ll be curious to see if the API for that model is slightly different and causing this conflict. I’ll try to add some debugging here for us to investigate further, stay tuned
Ok, I just published version 0.3.3 with additional debug logging. Could you:
- Upgrade to 0.3.3
- Enable debug mode on Homebridge (start with
homebridge -D
or go to the/settings
Homebridge settings page in the UI to turn it on and restart) - View the logs, looking for the most recent logs around
Getting device status
,device response
, anddevice response.result.snapshot
Hi, you can find at below. If you need anything just ask me 😀
[2020-5-13 8:56:55] Loaded plugin: homebridge-lg-thinq-ac
[2020-5-13 8:56:55] Registering platform 'homebridge-lg-thinq-ac.LgThinqAirConditioner'
[2020-5-13 8:56:55] ---
[2020-5-13 8:57:08] [LgThinqAirConditioner] Initializing LgThinqAirConditioner platform...
[2020-5-13 8:57:08] [LgThinqAirConditioner] Finished initializing platform: undefined
[2020-5-13 8:57:08] Loading 1 accessories...
[2020-5-13 8:57:08] [LgThinqAirConditioner] Restoring accessory from cache: KLİMA
[2020-5-13 8:57:08] [LgThinqAirConditioner] Not logged in; skipping updateCharacteristics()
[2020-5-13 8:57:08] [LgThinqAirConditioner] Starting refresh interval (set to 1 minutes)
[2020-5-13 8:57:08] [LgThinqAirConditioner] Executed didFinishLaunching callback
[2020-5-13 8:57:10] [LgThinqAirConditioner] Already logged into ThinQ
[2020-5-13 8:57:10] [LgThinqAirConditioner] refreshAuth()
[2020-5-13 8:58:08] [LgThinqAirConditioner] Getting device status d27c0210-7149-11d3-80b1-a06faae9be90
[2020-5-13 8:58:10] [LgThinqAirConditioner] device response {
resultCode: '0000',
result: {
modelName: 'RAC_056905_TR',
subModelName: '',
deviceType: 401,
deviceCode: 'AI01',
alias: 'KLİMA',
deviceId: 'd27c0210-7149-11d3-80b1-a06faae9be90',
fwVer: '2.5.8_RTOS_3K',
imageUrl: 'ac_home_wall_airconditioner_img.png',
ssid: 'Micro',
macAddress: 'a0:6f:aa:e9:be:90',
networkType: '02',
timezoneCode: 'Europe/Istanbul',
timezoneCodeAlias: 'Europe/Istanbul',
utcOffset: 3,
utcOffsetDisplay: '+03:00',
dstOffset: 3,
dstOffsetDisplay: '+03:00',
curOffset: 3,
curOffsetDisplay: '+03:00',
sdsGuide: '{"deviceCode":"AI01"}',
newRegYn: 'N',
remoteControlType: '',
online: false,
platformType: 'thinq1',
regDt: 20200105121139,
modelProtocol: 'STANDARD',
order: 0,
drServiceYn: 'N',
regDtUtc: '20200105091139',
tclcount: 0
}
}
[2020-5-13 8:58:10] [LgThinqAirConditioner] device response.result.snapshot undefined
[2020-5-13 8:58:10] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property 'airState.operation' of undefined
Hmm that's very interesting -- the response is successful, but snapshot
is missing 🤔 usually that is where the temperature, fan speed, status, etc is.
Just to confirm, you've successfully controlled this A/C unit with the "LG ThinQ" app, correct? If you haven't yet, could you try opening the app, view the A/C controls, and then watch the Homebridge logs for ~60 seconds to see if the interval error comes up again?
There's one API that I didn't enable yet because it didn't seem required, but maybe this device model relies on it...
Yes I am using LG Thinq app for a long time. I open my AC device with it and send some commands. I am pasting some logs after the operation.
btw, I just noticed that when I send heat command from Apple Home, logs shows dry command instead heat. I don't know if it is expected behaviour. Just want to let you know.
[2020-5-13 9:25:08] [LgThinqAirConditioner] Getting device status d27c0210-7149-11d3-80b1-a06faae9be90
[2020-5-13 9:25:11] [LgThinqAirConditioner] device response {
resultCode: '0000',
result: {
modelName: 'RAC_056905_TR',
subModelName: '',
deviceType: 401,
deviceCode: 'AI01',
alias: 'KLİMA',
deviceId: 'd27c0210-7149-11d3-80b1-a06faae9be90',
fwVer: '2.5.8_RTOS_3K',
imageUrl: 'ac_home_wall_airconditioner_img.png',
ssid: 'Micro',
macAddress: 'a0:6f:aa:e9:be:90',
networkType: '02',
timezoneCode: 'Europe/Istanbul',
timezoneCodeAlias: 'Europe/Istanbul',
utcOffset: 3,
utcOffsetDisplay: '+03:00',
dstOffset: 3,
dstOffsetDisplay: '+03:00',
curOffset: 3,
curOffsetDisplay: '+03:00',
sdsGuide: '{"deviceCode":"AI01"}',
newRegYn: 'N',
remoteControlType: '',
online: false,
platformType: 'thinq1',
regDt: 20200105121139,
modelProtocol: 'STANDARD',
order: 0,
drServiceYn: 'N',
regDtUtc: '20200105091139',
tclcount: 0
}
}
[2020-5-13 9:25:11] [LgThinqAirConditioner] device response.result.snapshot undefined
[2020-5-13 9:25:11] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property 'airState.operation' of undefined
[2020-5-13 9:26:08] [LgThinqAirConditioner] Getting device status d27c0210-7149-11d3-80b1-a06faae9be90
[2020-5-13 9:26:09] [LgThinqAirConditioner] device response {
resultCode: '0000',
result: {
modelName: 'RAC_056905_TR',
subModelName: '',
deviceType: 401,
deviceCode: 'AI01',
alias: 'KLİMA',
deviceId: 'd27c0210-7149-11d3-80b1-a06faae9be90',
fwVer: '2.5.8_RTOS_3K',
imageUrl: 'ac_home_wall_airconditioner_img.png',
ssid: 'Micro',
macAddress: 'a0:6f:aa:e9:be:90',
networkType: '02',
timezoneCode: 'Europe/Istanbul',
timezoneCodeAlias: 'Europe/Istanbul',
utcOffset: 3,
utcOffsetDisplay: '+03:00',
dstOffset: 3,
dstOffsetDisplay: '+03:00',
curOffset: 3,
curOffsetDisplay: '+03:00',
sdsGuide: '{"deviceCode":"AI01"}',
newRegYn: 'N',
remoteControlType: '',
online: false,
platformType: 'thinq1',
regDt: 20200105121139,
modelProtocol: 'STANDARD',
order: 0,
drServiceYn: 'N',
regDtUtc: '20200105091139',
tclcount: 0
}
}
[2020-5-13 9:26:09] [LgThinqAirConditioner] device response.result.snapshot undefined
[2020-5-13 9:26:09] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property 'airState.operation' of undefined
Cool, thanks for confirming! I just pushed version 0.3.4, which includes the API I didn't previously include. Could you try updating to 0.3.4, restart, and wait ~2 minutes to see if it comes up? You should see a successful [LgThinqAirConditioner] Renewing monitoring
line pop up in the logs
The other thing that stands out to me is online: false
in the response, and platformType
is thinq1
. I haven't tried this with a thinq1 device, so if this still doesn't work, this plugin might need to switch between APIs for thinq1 / thinq2
On the dry vs heat piece: my A/C unit calls this a “dry” mode, so I wrote it as “dry” internally. But heat/dry do share the same low-level API values so it should work the same
Hi, I assume 0.3.4 is not available on npm. Also I cannot see update on homebridge gui.
Sorry, forgot to publish -- 0.3.4 should be up now
New logs coming ☺️
[2020-5-13 10:05:22] [LgThinqAirConditioner] Getting device status d27c0210-7149-11d3-80b1-a06faae9be90
[2020-5-13 10:05:22] [LgThinqAirConditioner] Renewing monitoring d27c0210-7149-11d3-80b1-a06faae9be90
[2020-5-13 10:05:22] [LgThinqAirConditioner] device response {
resultCode: '0000',
result: {
modelName: 'RAC_056905_TR',
subModelName: '',
deviceType: 401,
deviceCode: 'AI01',
alias: 'KLİMA',
deviceId: 'd27c0210-7149-11d3-80b1-a06faae9be90',
fwVer: '2.5.8_RTOS_3K',
imageUrl: 'ac_home_wall_airconditioner_img.png',
ssid: 'Micro',
macAddress: 'a0:6f:aa:e9:be:90',
networkType: '02',
timezoneCode: 'Europe/Istanbul',
timezoneCodeAlias: 'Europe/Istanbul',
utcOffset: 3,
utcOffsetDisplay: '+03:00',
dstOffset: 3,
dstOffsetDisplay: '+03:00',
curOffset: 3,
curOffsetDisplay: '+03:00',
sdsGuide: '{"deviceCode":"AI01"}',
newRegYn: 'N',
remoteControlType: '',
online: false,
platformType: 'thinq1',
regDt: 20200105121139,
modelProtocol: 'STANDARD',
order: 0,
drServiceYn: 'N',
regDtUtc: '20200105091139',
tclcount: 0
}
}
[2020-5-13 10:05:22] [LgThinqAirConditioner] device response.result.snapshot undefined
[2020-5-13 10:05:22] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property 'airState.operation' of undefined
(node:16020) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
at createError (/usr/local/lib/node_modules/homebridge-lg-thinq-ac/node_modules/axios/lib/core/createError.js:16:15)
at settle (/usr/local/lib/node_modules/homebridge-lg-thinq-ac/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/usr/local/lib/node_modules/homebridge-lg-thinq-ac/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:322:22)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:16020) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 11)
Gotcha, looks like this might be a ThinQ 1 vs ThinQ 2 issue 😞
Have you tried this plugin before? I couldn’t get it working because my device is on ThinQ 2, but it might work for your A/C on ThinQ 1: https://github.com/beele/HomebridgeLgSmartThinqAirco
Otherwise I can try to get this plugin working for ThinQ 1, but I may need your help 😅
Hi, yes this plugin works for me. But some functions don't work with this plugin like mode switch. So I wanted to try alternatives and your one is very promising. ☺️ If you want to get ThinQ 1 working, I can help you with pleasure.
I have 2 ACs, both of them connects to v2:
platformType: 'thinq2'
I can turn on/off the devices, but there is no temp status :(
Also, I receive [LgThinqAirConditioner] Error during interval update Error: invalid
error message.
Thanks! 👍
@vaxi87 Do you see this same error?
Cannot read property 'airState.operation' of undefined
If not, would you mind opening a new issue for this? Please include the model of your two A/C units as well
@sman591 You mentioned Charles Proxy. I've got it set up on my machine with my iOS device proxying to it. I've never used it before so I'm not sure of the steps that are best for getting you helpful logs.
I've also got SSL proxying enabled so I can actually see the content that the LG Thinq app is sending/receiving.
@jakemauer Perfect! If Charles Proxy is working, we can figure out what the thinq1
devices are expecting. We'd be looking at:
- What action was taken on the device (e.g. status refresh, tapped power on/off, changed mode, changed temp, changed fan speed)
- The full URL requested
- The HTTP method used
- The request body sent (if any; not used if HTTP method is
GET
) - All HTTP headers included in the request
- Usually the same per-request, so we don't need to copy & paste each unless they're different
- These do include sensitive auth credentials/secrets which must be redacted
If you want to try it out and share the results, I'd maybe suggest putting them in "summary" blocks or create a Gist of each and share it
@sman591 I'm planning on working on this this weekend. What servers should I be looking at traffic from/to?
I’m not sure which exactly, but you’ll probably end up whitelisting a few for SSL to find it. I found the easiest way is to tap controls on the phone and see which HTTP request is sent immediately with it
I'm having the same issue with a LW8017ERSM. I'm more than happy to do any testing you may need.
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Getting device status bc343550-ee86-11e7-b0fd-7c1c4ec13713
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Renewing monitoring bc343550-ee86-11e7-b0fd-7c1c4ec13713
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Error renewing monitor Error: Request failed with status code 400
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] device response {
resultCode: '0000',
result: {
modelName: 'WIN_056905_CA',
deviceType: 401,
deviceCode: 'AI01',
alias: 'Air Conditioner',
deviceId: 'bc343550-ee86-11e7-b0fd-7c1c4ec13713',
fwVer: '2.6.2_RTOS_3K',
imageUrl: 'ac_home_window_airconditioner_img.png',
ssid: 'NachoWiFi',
macAddress: '7c:1c:4e:c1:37:13',
networkType: '02',
timezoneCode: 'America/Toronto',
timezoneCodeAlias: 'USA/Toronto',
utcOffset: -5,
utcOffsetDisplay: '-05:00',
dstOffset: -4,
dstOffsetDisplay: '-04:00',
curOffset: -4,
curOffsetDisplay: '-04:00',
sdsGuide: '{"deviceCode":"AI01"}',
newRegYn: 'N',
online: false,
platformType: 'thinq1',
regDt: 20200526211129,
modelProtocol: 'STANDARD',
order: 0,
drServiceYn: 'N',
regDtUtc: '20200527011129',
tclcount: 0
}
}
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] device response.result.snapshot undefined
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Error parsing power state TypeError: Cannot read property 'airState.operation' of undefined
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Error parsing mode TypeError: Cannot read property 'airState.opMode' of undefined
[5/27/2020, 12:34:47 AM] [LgThinqAirConditioner] Error during interval update TypeError: Cannot read property 'airState.tempState.current' of undefined```
Hi - I tried getting this set up for my AC but seems like mine is using the Thinq V1 API. I have charles proxying set up. Do you still need some help debugging this? Happy to help.
Here's a gist with some of the major API calls being made https://gist.github.com/caseypugh/279ef3d1db5a87173a5d0819d5974dd5 - hope this helps
Hey @caseypugh, thanks for providing the gist! That's super helpful, and I think should cover exactly what we need to get this working for ThinQ 1. I'll dig into it
I also have an AC with ThinQ1, apparently. Mine is an LW1517IVSM and it shows as WIN_056905_CA on the homebridge logs. Thanks for the support @sman591. Eager to see this updated.
Would love to see support for ThinQ1. Mine is RAC_056905_US as well
Would also like support for ThinkQ1. ModelRAC_056905_WW
Would also like support for ThinkQ1. model PAC_910604_WW and RAC_056905_KR
I'm on RAC_056905_WW, would love to have it working