Function to control Panasonic TV via IP

Thought i would share my function to control a Panasonic TV via IP Just change TV_IP_ADDRESS to your TVs IP and away you go.

[code]function TVControl(KeyPress)
local DeviceIpAddress = TV_IP_ADDRESS
local http = require “socket.http”
local ltn12 = require"ltn12"

local h_ds = "\045"
local h_lt = "\060"
local h_qm = "\063"
local h_gt = "\062"
local h_qt = "\034"						
local req = h_lt..h_qm.."xml version="..h_qt..'1.0'..h_qt.." encoding="..h_qt..'UTF-8'..h_qt..h_qm..h_gt
req = req .. h_lt.."s:Envelope xmlns:s="..h_qt.."http://schemas.xmlsoap.org/soap/envelope/"..h_qt.." s:encodingStyle="..h_qt.."http://schemas.xmlsoap.org/soap/envelope/"..h_qt..h_gt
req = req .. h_lt.."s:Body"..h_gt
req = req .. h_lt.."u:X_SendKey xmlns:u="..h_qt.. "urn:panasonic-com:service:p00NetworkControl:1" .. h_qt..h_gt
req = req .. h_lt.."X_KeyEvent" .. h_gt.. KeyPress .. h_lt .."/X_KeyEvent" .. h_gt
req = req .. h_lt.."/u:X_SendKey"  .. h_gt
    req = req .. h_lt.."/s:Body"..h_gt
    req = req .. h_lt.."/s:Envelope"..h_gt

local reqHeaders = {
	["HOST"] = DeviceIpAddress..":55000",
	["USER-AGENT"] = "Panasonic iOS VR-CP UPnP/2.0",
	["SOAPACTION"] = h_qt .. "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey" .. h_qt,
	["Content-Type"] = "text/xml;charset="..h_qt.."utf-8"..h_qt,
	["Content-Length"] = tostring(#req)
}

local respBody = { }
local rHeaders, rCode, rError = socket.http.request
   {
	method = "POST";
	url = "http://"..DeviceIpAddress..":55000/nrc/control_0";
	headers = reqHeaders;
	source = ltn12.source.string(req);
	sink = ltn12.sink.table(respBody)
}

end [/code]

“NRC_CH_DOWN-ONOFF”, // channel down
“NRC_CH_UP-ONOFF”, // channel up
“NRC_VOLUP-ONOFF”, // volume up
“NRC_VOLDOWN-ONOFF”, // volume down
“NRC_MUTE-ONOFF”, // mute
“NRC_TV-ONOFF”, // TV
“NRC_CHG_INPUT-ONOFF”, // AV,
“NRC_RED-ONOFF”, // red
“NRC_GREEN-ONOFF”, // green
“NRC_YELLOW-ONOFF”, // yellow
“NRC_BLUE-ONOFF”, // blue
“NRC_VTOOLS-ONOFF”, // VIERA tools
“NRC_CANCEL-ONOFF”, // Cancel / Exit
“NRC_SUBMENU-ONOFF”, // Option
“NRC_RETURN-ONOFF”, // Return
“NRC_ENTER-ONOFF”, // Control Center click / enter
“NRC_RIGHT-ONOFF”, // Control RIGHT
“NRC_LEFT-ONOFF”, // Control LEFT
“NRC_UP-ONOFF”, // Control UP
“NRC_DOWN-ONOFF”, // Control DOWN
“NRC_3D-ONOFF”, // 3D button
“NRC_SD_CARD-ONOFF”, // SD-card
“NRC_DISP_MODE-ONOFF”, // Display mode / Aspect ratio
“NRC_MENU-ONOFF”, // Menu
“NRC_INTERNET-ONOFF”, // VIERA connect
“NRC_VIERA_LINK-ONOFF”, // VIERA link
“NRC_EPG-ONOFF”, // Guide / EPG
“NRC_TEXT-ONOFF”, // Text / TTV
“NRC_STTL-ONOFF”, // STTL / Subtitles
“NRC_INFO-ONOFF”, // info
“NRC_INDEX-ONOFF”, // TTV index
“NRC_HOLD-ONOFF”, // TTV hold / image freeze
“NRC_R_TUNE-ONOFF”, // Last view
“NRC_POWER-ONOFF”, // Power off

“NRC_REW-ONOFF”, // rewind
“NRC_PLAY-ONOFF”, // play
“NRC_FF-ONOFF”, // fast forward
“NRC_SKIP_PREV-ONOFF”, // skip previous
“NRC_PAUSE-ONOFF”, // pause
“NRC_SKIP_NEXT-ONOFF”, // skip next
“NRC_STOP-ONOFF”, // stop
“NRC_REC-ONOFF”, // record

// numeric buttons
“NRC_D1-ONOFF”, “NRC_D2-ONOFF”, “NRC_D3-ONOFF”, “NRC_D4-ONOFF”, “NRC_D5-ONOFF”,
“NRC_D6-ONOFF”, “NRC_D7-ONOFF”, “NRC_D8-ONOFF”, “NRC_D9-ONOFF”, “NRC_D0-ONOFF”,

Wow this is great. Thanks so much.
Wish it could power on from Wifi ;D

We need to get this into a pluggin it would be great.
I will need to start reading about that.

hmm… that code looks awfully familiar…

Yes it was “borrowed” and modified from another thread, Thanks…

[quote=“joer., post:2, topic:188581”]Wow this is great. Thanks so much.
Wish it could power on from Wifi ;D

We need to get this into a pluggin it would be great.
I will need to start reading about that.[/quote]

I can turn mine on via wifi once i enabled “Power on by Apps” from the “Tv Remote App settings” menu in the “Network” menu.

I have used the Virtual Panel plugin to make a virtual remote for the TV.

[url=http://forum.micasaverde.com/index.php/topic,31128.0.html]http://forum.micasaverde.com/index.php/topic,31128.0.html[/url]

I wonder if this will work on my Sanyo TV which is a Panasonic sub brand and has a network connection and apps.
I just have to figure out it’s IP address…

Update: so much for that. Nothing on port 55000 or 80 or 23 or 8080. I can ping it and that is about it. Looks like this model can’t be controlled via network. Pity…

OK… pardon my ignorance here folks!

did you just put the code into startup, or create a new device and put it there?

Also, searching on “sending HTML” give me a gazillion threads that don’t seem to help. Where/how do you put the individual commands?

I believe he put them in a .lua file then called them from Virtual Panel using a require statement. This allows a single function to be called with parameters. See the post below.

http://forum.micasaverde.com/index.php/topic,31128.msg246606.html#msg246606

[quote=“rstrouse, post:8, topic:188581”]I believe he put them in a .lua file then called them from Virtual Panel using a require statement. This allows a single function to be called with parameters. See the post below.

http://forum.micasaverde.com/index.php/topic,31128.msg246606.html#msg246606[/quote]

Ah yes… Virtual Panel. I’ve been dying to try this, but sadly am still on U15 (he says a bit ironically :slight_smile: )

I’m solid on UI7 and have been for a while. But then again I didn’t update to 7.10.

Hi,

Sorry I’m a newbie on LUA.
I’ve not understood how I need to do the create this function for Panasonic TV.

Can you kindly help me?

TNX

Can you power on the TV via IP?
what model and year is your tv?
I’m looking to by a new panasonic tv, but can’t the answer is it can be turned on by IP, went to store a salesman told that it was notpossible, but no sure i can thrust him.
I’m looking to buy a TX-40cx700
thanks

Mine doesnt support it. I think some models do.

Hi Everyone
I have a newbie question regarding Skipp’s post from some time ago. I found if because I was looking for an easy way for a disabled person to remote control a Panasonic TV by voice

The question is Can Skipp’s script be adapted to an action on a Amazon echo so it directly controls a tv? Panasonic TV’s can be controlled from a smart phone app but to get the app to ‘listen’ the user needs dexterity to open phone/open app/ navigate/click.

Can anyone guide me to a solution please ?

J3dog

[quote=“skipp, post:1, topic:188581”]Thought i would share my function to control a Panasonic TV via IP Just change TV_IP_ADDRESS to your TVs IP and away you go.

[code]function TVControl(KeyPress)
local DeviceIpAddress = TV_IP_ADDRESS
local http = require “socket.http”
local ltn12 = require"ltn12"

local h_ds = "\045"
local h_lt = "\060"
local h_qm = "\063"
local h_gt = "\062"
local h_qt = "\034"						
local req = h_lt..h_qm.."xml version="..h_qt..'1.0'..h_qt.." encoding="..h_qt..'UTF-8'..h_qt..h_qm..h_gt
req = req .. h_lt.."s:Envelope xmlns:s="..h_qt.."http://schemas.xmlsoap.org/soap/envelope/"..h_qt.." s:encodingStyle="..h_qt.."http://schemas.xmlsoap.org/soap/envelope/"..h_qt..h_gt
req = req .. h_lt.."s:Body"..h_gt
req = req .. h_lt.."u:X_SendKey xmlns:u="..h_qt.. "urn:panasonic-com:service:p00NetworkControl:1" .. h_qt..h_gt
req = req .. h_lt.."X_KeyEvent" .. h_gt.. KeyPress .. h_lt .."/X_KeyEvent" .. h_gt
req = req .. h_lt.."/u:X_SendKey"  .. h_gt
    req = req .. h_lt.."/s:Body"..h_gt
    req = req .. h_lt.."/s:Envelope"..h_gt

local reqHeaders = {
	["HOST"] = DeviceIpAddress..":55000",
	["USER-AGENT"] = "Panasonic iOS VR-CP UPnP/2.0",
	["SOAPACTION"] = h_qt .. "urn:panasonic-com:service:p00NetworkControl:1#X_SendKey" .. h_qt,
	["Content-Type"] = "text/xml;charset="..h_qt.."utf-8"..h_qt,
	["Content-Length"] = tostring(#req)
}

local respBody = { }
local rHeaders, rCode, rError = socket.http.request
   {
	method = "POST";
	url = "http://"..DeviceIpAddress..":55000/nrc/control_0";
	headers = reqHeaders;
	source = ltn12.source.string(req);
	sink = ltn12.sink.table(respBody)
}

end [/code]

“NRC_CH_DOWN-ONOFF”, // channel down
“NRC_CH_UP-ONOFF”, // channel up
“NRC_VOLUP-ONOFF”, // volume up
“NRC_VOLDOWN-ONOFF”, // volume down
“NRC_MUTE-ONOFF”, // mute
“NRC_TV-ONOFF”, // TV
“NRC_CHG_INPUT-ONOFF”, // AV,
“NRC_RED-ONOFF”, // red
“NRC_GREEN-ONOFF”, // green
“NRC_YELLOW-ONOFF”, // yellow
“NRC_BLUE-ONOFF”, // blue
“NRC_VTOOLS-ONOFF”, // VIERA tools
“NRC_CANCEL-ONOFF”, // Cancel / Exit
“NRC_SUBMENU-ONOFF”, // Option
“NRC_RETURN-ONOFF”, // Return
“NRC_ENTER-ONOFF”, // Control Center click / enter
“NRC_RIGHT-ONOFF”, // Control RIGHT
“NRC_LEFT-ONOFF”, // Control LEFT
“NRC_UP-ONOFF”, // Control UP
“NRC_DOWN-ONOFF”, // Control DOWN
“NRC_3D-ONOFF”, // 3D button
“NRC_SD_CARD-ONOFF”, // SD-card
“NRC_DISP_MODE-ONOFF”, // Display mode / Aspect ratio
“NRC_MENU-ONOFF”, // Menu
“NRC_INTERNET-ONOFF”, // VIERA connect
“NRC_VIERA_LINK-ONOFF”, // VIERA link
“NRC_EPG-ONOFF”, // Guide / EPG
“NRC_TEXT-ONOFF”, // Text / TTV
“NRC_STTL-ONOFF”, // STTL / Subtitles
“NRC_INFO-ONOFF”, // info
“NRC_INDEX-ONOFF”, // TTV index
“NRC_HOLD-ONOFF”, // TTV hold / image freeze
“NRC_R_TUNE-ONOFF”, // Last view
“NRC_POWER-ONOFF”, // Power off

“NRC_REW-ONOFF”, // rewind
“NRC_PLAY-ONOFF”, // play
“NRC_FF-ONOFF”, // fast forward
“NRC_SKIP_PREV-ONOFF”, // skip previous
“NRC_PAUSE-ONOFF”, // pause
“NRC_SKIP_NEXT-ONOFF”, // skip next
“NRC_STOP-ONOFF”, // stop
“NRC_REC-ONOFF”, // record

// numeric buttons
“NRC_D1-ONOFF”, “NRC_D2-ONOFF”, “NRC_D3-ONOFF”, “NRC_D4-ONOFF”, “NRC_D5-ONOFF”,
“NRC_D6-ONOFF”, “NRC_D7-ONOFF”, “NRC_D8-ONOFF”, “NRC_D9-ONOFF”, “NRC_D0-ONOFF”,[/quote]