j3dog
Posts: 2
Joined: Thu May 11, 2017 7:04 pm

Help regarding Panasonic Vierra Televisions

Thu May 11, 2017 7:10 pm

Hi all

I found this script that purports to control Panasonic Vierra Televisions. It was posted on VERA smarter home control forums and my question(s) is

1) Does anyone know how to utilise this on the Raspberry Pi? (convert to a Python program or another recommendation?)
2) Would it be something that could be voice controlled?

I realise i'm asking a lot of big questions here but I'm trying to make a disabled persons life a little better. Any suggestions or pointers would be very welcome
Thanks J3dog

Code: Select all

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	

"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", 

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Help regarding Panasonic Vierra Televisions

Fri May 12, 2017 1:20 pm

Hi,
change the title of the thread to something more meaningful, in order to direct more responsive help.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

Return to “General programming discussion”