-
Notifications
You must be signed in to change notification settings - Fork 46
Bridge
The current release of rethink includes a "bridge" utility, which allows a single device to be "bridged" to the official services, while it is still provisioned to the local rethink instance.
The utility registers with the ThinQ cloud in the role of a device, adds the device to your ThinQ account, and forwards the control messages to/from the device (via rethink-cloud's mqtt interface). This serves two purposes:
- The device may be controlled both via rethink/HomeAssistant and the official LG app
- The communications triggered by the offical app can be observed and reverse-engineered.
It is a very early release, I hope that having such tool available will allow others to reverse-engineer the protocols of other devices - ones that I don't have access to.
First, the rethink-cloud server needs to be installed, and the device must complete the provisioning process. See the installation guide for details.
Note that the provisioning process appears to be common between various ThinQ devices, and so it may actually work even if the device isn't supported by rethink.
The bridge utility can be started by the following command:
node dist/experimental/bridge/bridge.js [rethinkMqtt] [countryCode] [deviceType] [modelName] [deviceId]
Options:
-
rethinkMqtt- mqtt (unencrypted) url to a local rethink server -
countryCode- two-character country code identifier matching your ThinQ account -
deviceType- device type identifier, usually consists of three digits, this is a constant value provided by the device during provisioning -
modelName- device model identifier, alphanumeric, this is a constant value provided by the device during provisioning
for example:
node dist/experimental/bridge/bridge.js mqtt://rethink.lan:1884/ PL 401 RAC_056905_WW 68b5784e-3ae6-40ce-86d6-111fec8838e8
On the initial invocation, the script will need to obtain OAuth tokens for your ThinQ account, in order to register the device with your account. An URL will be printed on stdout:
Connecting to mqtt://kukuck:1884
Trying to register device with ThinQ cloud
Use your browser to log in at https://.../
Paste the post-login URL here:
You need to open the URL in a web browser and complete the login process. A blank-ish page with a complex URL (like https://kr.m.lgaccount.com/login/iabClose?...) will appear. Copy the URL back to the terminal.
Found code: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Welcome you@youremail.something!
Listing devices
[
'68b5784e-3ae6-40ce-86d6-111fec8838e8'
]
Removing device from home
Fetching otp key
Registering new device
Fetching API urls
Fetching CA cert
Trying to generate a certificate with otp XXXXXXXXXXXXXXXXXXXXXX...
Adding device to home
Starting bridging
Starting simulated appliance
Connecting to ssl://a3phael99lf879.iot.eu-west-1.amazonaws.com:8883
connected
(mqtt messages will be logged here)
The OAuth2 tokens will be cached in .oauth2.json. Device-specific credentials will be stored in .bridge_${deviceId}.json. On subsequent runs, the authentication & registration process will be skipped.