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.

Solis inverter for solar panels
Has anyone made script for connecting to Solis inverter via API?

Attached the api manual.

I know the inverter can be accessed via modbus rtu but cannot do that and the solis cloud at the same time so I would like to only get this via api.

Attached Files
.pdf   SolisCloud API 1.0.8 (1).pdf (Size: 435.42 KB / Downloads: 10)
Try this, change key_id/key_secret as needed. request function accepts two parameters - request URI (starting with /v1/api/...) and request body (either a table which is converted to JSON or a string which is sent as is).
The calculated signature differs from documented example even though it is calculated the same way. Might be an error in the documentation.

host = ''
key_id = '2424'
key_secret = '6680182547'

function request(uri, body)
  local method = 'POST'

  if type(body) ~= 'string' then
    body = json.encode(body)

  local content_md5 = encdec.md5(body, true)
  content_md5 = encdec.base64enc(content_md5)

  local content_type = 'application/json'
  local date ='!%a, %d %b %Y %X GMT')
  local sign = method .. '\n' ..
    content_md5 .. '\n' ..
    content_type .. '\n' ..
    date .. '\n' ..

  sign = encdec.hmacsha1(sign, key_secret, true)

  local url = host .. uri
  local auth = 'API ' .. key_id .. ':' .. encdec.base64enc(sign)

  local headers = {
    ['Content-MD5'] = content_md5,
    ['Content-Type'] = content_type,
    ['Date'] = date,
    ['Authorization'] = auth,
    ['Content-Length'] = #body,

  local resp = {}

  local res, code = socket.http.request({
    url = url,
    method = method,
    source = ltn12.source.string(body),
    sink = ltn12.sink.table(resp),
    headers = headers

  if res and code == 200 then
    return table.concat(resp)
    return nil, code

res, err = request('/v1/api/userStationList', { userId = '1145611319416590338' })
log(res, err)
Thanks. Will try this

Forum Jump: