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.

Tesla Powerwall Local Connection broken with New Release
#9
That works and I can grab the AuthCookie as follows

res:match('(AuthCookie=[^;]+)'..';')

Many thanks!


My previous logic to retrieve info from the various API endpoints on the Powerwall also needs to be updated to pass the AuthCookie.

How can I use client : send to send the cooke as part of a GET request?

And also is there an easy way to return the result to a table to allow easy extraction of the returned data?


Here's the old code I'm trying to update

Code:
requestURL = 'https://POWERWALLGATEWAYIP/api/meters/aggregates'
requestData = ''
requestPostResponse = {}
token = GetUserParam('Wired', 'TeslaPowerwallLocalAccessToken')

res, err, commandPostHeaders, status = https.request
  {
    url = requestURL,
    method = 'GET',
    protocol = 'tlsv12',
    headers =
      {
        cookie = token,
        ['Accept'] = '*/*',
        ['Content-Type'] = 'application/json',
        ['Content-Length'] = requestData:len()
      },
    source = ltn12.source.string(requestURL),     
    sink = ltn12.sink.table(requestPostResponse)
  }
   
if err == 200 then
   
  mydata = json.pdecode(table.concat(requestPostResponse))
 
  teslaPowerwallPercentCharged = mydata.percentage
     
else
 
  log('Error retrieving Tesla Powerwall Battery Charge ' .. tostring(err))
 
  getTeslaPowerwallLocalAccessToken();
 
end


Many thanks

Kind Regards
James
Reply


Messages In This Thread
RE: Tesla Powerwall Local Connection broken with New Release - by jamesng - 05.07.2021, 12:15

Forum Jump: