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
#10
I've tried the following 

Code:
  socket = require('socket')
  ssl = require('ssl')
 
  client = socket.tcp()
  client:settimeout(1)

  ip = 'POWERWALLGATEWAYIP'
  token = GetUserParam('Wired', 'TeslaPowerwallLocalAccessToken')
  params = {mode='client', protocol='tlsv1_2',verify='none',}
 
 
  res, err = client:connect(ip, 443)
  ctx = ssl.newcontext(params)

  client = ssl.wrap(client, ctx)
  client:settimeout(1)
  res, err = client:dohandshake()

  res, err = client:send(
  'GET /api/system_status/soe HTTP/1.1' .. '\r\n' ..
  'Host: ' .. ip .. '\r\n' ..
  'Set-Cookie: ' .. token .. '\r\n' ..   
  'User-Agent: curl/7.64.1' .. '\r\n' ..
  'Accept: */*' .. '\r\n' ..
  'Connection: close' .. '\r\n\r\n'
   )

  res, err, partial = client:receive('*a')
  log('receive', res, err, partial)

  client:close()

however the way I'm passing the AuthCookie token doesn't seem correct as this is the error I get back from the Powerwall

Code:
* arg: 1
  * string: receive
* arg: 2
  * string: HTTP/1.1 403 Forbidden
Content-Type: application/json
X-Content-Type-Options: nosniff
Date: Mon, 05 Jul 2021 13:44:08 GMT
Content-Length: 102
Connection: close

{"code":403,"error":"Unable to GET to resource","message":"User does not have adequate access rights"}
* arg: 3
  * nil
* arg: 4
  * nil

How should the cookie / token value be set in the request header?

Kind Regards
James
Reply


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

Forum Jump: