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.

Panasonic Viera TV IP control
#2
Try these functions, they are untested so might not work at all. You have to parse any XML response manually
Code:
function request(host, url, urn, action, args)
  local body, http, ltn12, sink, res, err

  ltn12 = require('ltn12')
  http = require('socket.http')
  body = [[<?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <s:Body><u:]] .. action .. [[ xmlns:u="urn:]] .. urn .. [[">]] .. args .. [[</u:]] .. action .. [[></s:Body>
  </s:Envelope>]]

  sink = {}

  res, err = http.request({
    url = 'http://' .. host .. ':55000/' .. url,
    method = 'POST',
    headers = {
      ['soapaction'] = '"urn:' .. urn .. '#' .. action .. '"',
      ['Content-Length'] = #body,
    },
    sink = ltn12.sink.table(sink),
    source = ltn12.source.string(body),
  })

  if res then
    return table.concat(sink)
  else
    return nil, err
  end
end

function sendkey(host, code)
  local args = '<X_KeyEvent>' .. code .. '</X_KeyEvent>'
  return request(host, 'nrc/control_0', 'panasonic-com:service:p00NetworkControl:1', 'X_SendKey', args)
end

function getmute(host)
  return request(host, 'dmr/control_0', 'schemas-upnp-org:service:RenderingControl:1', 'GetMute', '<InstanceID>0</InstanceID><Channel>Master</Channel>')
end

IP = '192.168.1.2'
log(getmute(IP))
Reply


Messages In This Thread
Panasonic Viera TV IP control - by jetsetter - 29.02.2016, 11:54
RE: Panasonic Viera TV IP control - by admin - 10.03.2016, 14:32
RE: Panasonic Viera TV IP control - by admin - 16.03.2016, 08:25
RE: Panasonic Viera TV IP control - by andeug - 10.10.2016, 14:41
RE: Panasonic Viera TV IP control - by Habib - 08.04.2018, 11:32
RE: Panasonic Viera TV IP control - by admin - 08.04.2018, 11:58
RE: Panasonic Viera TV IP control - by Habib - 08.04.2018, 13:37
RE: Panasonic Viera TV IP control - by admin - 20.01.2020, 08:32
RE: Panasonic Viera TV IP control - by admin - 14.04.2020, 07:57
RE: Panasonic Viera TV IP control - by admin - 25.12.2020, 13:49
RE: Panasonic Viera TV IP control - by admin - 28.12.2020, 07:46
RE: Panasonic Viera TV IP control - by admin - 06.04.2021, 05:43
RE: Panasonic Viera TV IP control - by admin - 06.04.2021, 09:39

Forum Jump: