This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Has someone already integrated LG ThinQ
#1
Hi All,

I like to integrate my LG devices like AC for example by the LG Thinq API. Has someone already done this and could share the script here?
I found a start at this website https://forum.fibaro.com/topic/51441-hc3...martthinq/ with the script below. Would be great if we can get it to work.

The script berlow is not mine but copied from the website i shared. It seems you'll need a secret key and client key but i'm not sure where to get it as i could not find clear information about it. So all help is much appriciated to get this work.

Code:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
OAUTH_SECRET_KEY = "c053c2a6ddeb7ad97cb0eed0dcb31cf8" OAUTH_CLIENT_KEY = "LGAO221A02" DATE_FORMAT = "!%a, %d %b %Y %H:%M:%S" V2_AUTH_PATH = "/oauth/1.0/oauth2/token" function oauth2_signature(message, secret)     local hmac = sha.hmac     local hashed = hmac(sha.sha1, secret, message)     local binary_hash = sha.hex2bin(hmac(sha.sha1, secret, message))     return sha.bin2base64(binary_hash) end function auth_request(oauth_url, reqdata)     if string.sub(oauth_url, -1):lower() == "/" then  oauth_url = string.sub(oauth_url, 0, #oauth_url-1) end     local url = oauth_url .. V2_AUTH_PATH     local timestamp = tostring(os.date(DATE_FORMAT, os.time())) .. " +0000"     local data_list = {}     for k, v in pairs(reqdata) do  table.insert(data_list, string.format("%s=%s", k, v)) end     local req_url = string.format("%s?%s", V2_AUTH_PATH, table.concat(data_list, "&"))     local message = string.format("%s\n%s", req_url, timestamp)     local sig = oauth2_signature(message, OAUTH_SECRET_KEY)     local headers = {         ["x-lge-appkey"] = OAUTH_CLIENT_KEY,         ["x-lge-oauth-signature"] = sig,         ["x-lge-oauth-date"] = timestamp,         ["Content-Type"] = "application/x-www-form-urlencoded",         ["Accept"] = "application/json"     }     castdata = table.concat(data_list, "&")     self.http:request(url,{         options = {             headers = headers,             data = castdata,             method = "POST",             timeout = 5000,         },         success = function(response)             log("auth_request success", response.data)         end,         error = function(error)             self:debug('error: ' .. json.encode(error))         end     })    end    local requestBody = {         grant_type = "refresh_token",         refresh_token = "4ed29cb48cc1cb6228658d50817b789d67d37dbad56bf561cc6389a4ab69070d8ee808edb3377ad3b07e243c467f1d36"     }     auth_request("https://us.lgeapi.com/", requestBody)
Reply


Messages In This Thread
Has someone already integrated LG ThinQ - by Joep - 06.05.2023, 09:49

Forum Jump: