Panasonic TC-P65VT30 Integration

Posted on
Sat Jun 25, 2011 8:43 pm
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Panasonic TC-P65VT30 Integration

This should work with any 2011 Panasonic VT30-series flat-screen TV that includes a serial port for computer control. Yes, the VT30 TVs can be controlled through a network connection (a la iPhone app), but only if they are already turned on. The TC-P65VT30 turns off the network listener when the power is off, so you have to turn it on with another method (sending a command using a RS-232C serial connection is one such method). I don't know if the TC-P55VT30 or other VT30 TVs have serial connections. If they don't this method won't work.

This integration method is an advanced solution that requires the use of any 3rd party USB to 9-pin serial adapter, adding serial support into Python on Mac OS X, creating a small Python serial command-sending script, and creating both send and response triggers within Indigo to send TV commands and respond to the results of sending those commands. As an alternative, you could likely devise a less complex (and less functional) solution that uses an Insteon-to-IR device.

Serial-to-TV Connection

You'll first need to attach the TV's serial port to your Mac. The Panasonic TC-P65VT30 comes with a RS-232C adapter that must be plugged into it's proprietary dedicated 1/8" RS-232C plug. The adapter has a 1/8" stereo plug on one end and a female 9-pin serial port on the other end. You'll need to find or buy a USB-to-serial adapter. I use a rather generic PL2303 based USB-to-serial adapter. The biggest issue with that type of adapter is that the official PL2303 drivers for Mac OS X 10.6 don't actually work properly (at least they don't for me), so I had to find free alternative (beta) drivers. If you have a PL2303-based USB-to-serial adapter (commonly branded by companies like IOData, Samsung, Siemens, Nokia, RadioShack, and others), you can download the free SourceForge Mac OS X drivers (that work better for me) from here. Once you've connected everything (proprietary adapter into TV, serial cable into proprietary adapter, other end of serial cable into USB-to-serial adapter, USB-to-serial adapter into Mac running Indigo, USB adapter drivers installed), you can move on to the next phase of setup.

Install Pyserial for Python

Every Mac OS X installation (from at least 10.3 on, perhaps even earlier) includes the Python scripting language pre-installed. However, it doesn't include the required extension to access serial ports through Python, so you'll need to add that extension yourself. You can download the free "pyserial" extension from this page. Download the latest .tar.gz version of the pyserial extension (this is the version that's compatible with Mac OS X). Once downloaded, double-click on the resulting file to expand the tar.gz file. Use the Terminal application to execute the setup.py script.
Code: Select all
cd ~/Downloads/pyserial-2.5
python serup.py install

Note that the above "pyserial-2.5" part of the first command assumes you've downloaded version 2.5 of the pyserial extension (the latest version as of this writing). If you've downloaded a newer version, use that version number. If you've placed your expanded pyserial extension download somewhere other than your Downloads folder, use the full path to that folder with the "cd" command above. Once you've executed the setup.py script, that should be all you need to do to install the extension.

Create the TV Command Sending Python Script

We now need to find out what name your system uses to refer to the USB-to-serial adapter. This could be difficult, especially if your adapter uses the same FTDI drivers used by Indigo to communicate with Insteon/X10 modules. In my case, since I used a PL2303-based USB-to-serial adapter, the name of the serial port was obvious. With the Terminal application still open, change to the "/dev" directory and list all the character devices.
Code: Select all
cd /dev
ls -l cu*

You'll probably see something similar to what I do.
Code: Select all
crw-rw-rw-  1 root  wheel   10,   7 Jun 25 01:26 cu.Bluetooth-Modem
crw-rw-rw-  1 root  wheel   10,   5 Jun 25 01:26 cu.Bluetooth-PDA-Sync
crw-rw-rw-  1 root  wheel   10,   3 Jun 25 11:31 cu.PL2303-0000205D
crw-rw-rw-  1 root  wheel   10,   1 Jun 25 11:31 cu.usbserial-A60089RB

In the above listing, the "usbserial-..." serial port is my USB PowerLinc Modem (2413U). The "PL2303-..." device is my USB-to-serial adapter. Write down or copy the full name of your USB-to-serial adapter in the listed output (for me that'd be "cu.PL2303-0000205D").

With the Terminal application still open, change working directories to an appropriate location for storing a background process script. I'm using Indigo Pro 4, so I put my script in the Indigo 4 background scripts folder
Code: Select all
cd "/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks"

Use the "vi" command-line utility to create the script that actually connects to the TV via serial connection, sends commands, and waits for responses to give back to Indigo. You can use another command-line text editor if you like (perhaps "nano") but all the instructions here will use vi.
Code: Select all
vi tv-send-command.py

I used the file name "tv-send-command.py" but you can use any file name you prefer. It should, however, end with ".py" to designate it as a Python script. Insert the following Python script into the newly created file.
Code: Select all
#!/usr/bin/python

import sys;
import time;
import serial;

theCommand = "\x02" + sys.argv[1] + "\x03"

ser = serial.Serial("/dev/cu.PL2303-0000205D", 9600, timeout=1)

if ser.readable() == True:
   if ser.writable() == True:
      ser.write(theCommand)
      time.sleep(0.25)
      n = ser.inWaiting()
      x = ser.read(n)
      x = x.strip("\x02")
      x = x.strip("\x03")
      print x

ser.close()

Note the serial port name in the above script. Be sure and change that "cu.PL2303..." name to the name of your USB-to-serial device. The above code takes whatever textual command you send the tv-send-command script, inserts the required special characters before and after that command, sends the full command to the TV, waits for the TV's response to that command, then removes the special characters the TV inserts before and after the response before returning the textual response as the output from the tv-send-command.

Now make the Python script executable by everyone. This is needed so Indigo can use it.
Code: Select all
chmod a+x tv-send-command.py

You can now quit the Terminal application.

Create Indigo Variables and Triggers

Open the Indigo client. Create 2 new variables (Window menu, Variable List, click New, you can place the variables in any folder you deem appropriate, if you like). The first should be named "TVCommand" and the second should be named "TVCommandResponse".

Now, we're going to create 2 new triggers. The first will send whatever command is placed in the "TVCommand" variable to the TV and place the TV's response in the "TVCommandResponse" variable. The second will process the response placed in the "TVCommandResponse" variable to provide feedback within Indigo.

Create the first trigger with the following settings.
Name: Send TV Command
Trigger tab
Type: Variable Changed
Variable: TVCommand
"changes" radio button selected.
Condition tab
Upon trigger do action: "If script returns true" radio button selected, with the following code in the text entry area.
Code: Select all
if value of variable "TVCommand" is not "" then
    return true
else
    return false
end if

Action tab
Type: Execute AppleScript
"Embedded:" radio button selected with the following code in the text entry area.
Code: Select all
set theCommand to value of variable "TVCommand"

-- Send the command to the TV using the custom Python script that connects to the TV via serial connection.
set theResponse to do shell script "/Library/Application\\ Support/Perceptive\\ Automation/Indigo\\ 4/Scripts/Background\\ Tasks/tv-send-command.py " & theCommand

-- Assign the response value to an Indigo variable.
set value of variable "TVCommandResponse" to theResponse

-- Reset the TVCommand variable to blank.
set value of variable "TVCommand" to ""

Note that the above code assumes 1) you named the Python script the same way I did, 2) you put the tv-send-command.py file in the same location I did, and 3) you're using Indigo Pro 4. Adjust the "do shell script" command as necessary for your setup.

Create the second trigger with the following parameters.
Name: TV Command Response
Trigger tab
Type: Variable Changed
Variable: TVCommandResponse
"changes" radio button selected.
Condition tab
Upon trigger do action: "If script returns true" radio button selected, with the following code in the text entry area.
Code: Select all
if value of variable "TVCommandResponse" is not "" then
    return true
else
    return false
end if

Action tab
Type: Execute AppleScript
"Embedded:" radio button selected with the following code in the text entry area.
Code: Select all
-- Custom actions based on responses.
if value of variable "TVCommandResponse" starts with "ER" then
    
    -- Invalid Command... Ignore it.
    
else if value of variable "TVCommandResponse" starts with "QPW" then
    
    -- Power Query Response
    
    if value of variable "TVCommandResponse" is "QPW:1" then
        -- Power is On
    else
        -- Power is Off
    end if
    
else if value of variable "TVCommandResponse" is "PON" then
    
    -- Power is On
    
else if value of variable "TVCommandResponse" is "POF" then
    
    -- Power is Off
    
else if value of variable "TVCommandResponse" starts with "AVL" then

    -- Volume Change
    
else if value of variable "TVCommandResponse" starts with "QAV" then
    
    -- Volume Query Response
    
else if value of variable "TVCommandResponse" is "AUU" then
    
    -- Volume Up
    
else if value of variable "TVCommandResponse" is "AUD" then
    
    -- Volume Down
    
else if value of variable "TVCommandResponse" starts with "QAM" then
    
    -- Mute Query Response
    
else if value of variable "TVCommandResponse" starts with "AMT" then

    -- Mute Toggle

else if value of variable "TVCommandResponse" starts with "IMS" then
    
    -- Input Select Change
    if value of variable "TVCommandResponse" is "IMS:TV" then
        -- TV Input Selected
    else if value of variable "TVCommandResponse" is "IMS:C1" then
        -- Component Input Selected
    else if value of variable "TVCommandResponse" is "IMS:V1" then
        -- Composite Video Input Selected
    else if value of variable "TVCommandResponse" is "IMS:H1" then
        -- HDMI 1 Input Selected
    else if value of variable "TVCommandResponse" is "IMS:H2" then
        -- HDMI 2 Input Selected
    else if value of variable "TVCommandResponse" is "IMS:H3" then
        -- HDMI 3 Input Selected
    else if value of variable "TVCommandResponse" is "IMS:H4" then
        -- HDMI 4 Input Selected
    else if value of variable "TVCommandResponse" is "IMS:PC" then
        -- PC (VGA) Input Selected
    else if value of variable "TVCommandResponse" is "IMS:SP" then
        -- Photo Media Player Input Selected
    else if value of variable "TVCommandResponse" is "IMS:SM" then
        -- Video Media Player Input Selected
    else if value of variable "TVCommandResponse" is "IMS:MC" then
        -- Music Media Player Input Selected
    else if value of variable "TVCommandResponse" is "IMS:VC" then
        -- VIERA Connect (Internet) Input Selected
    end if
    
else if value of variable "TVCommandResponse" starts with "QMI" then
    
    -- Input Query Response (same input names as above)
    if value of variable "TVCommandResponse" is "QMI:TV" then
        -- TV Input Selected
    else if value of variable "TVCommandResponse" is "QMI:C1" then
        -- Component Input Selected
    else if value of variable "TVCommandResponse" is "QMI:V1" then
        -- Composite Video Input Selected
    else if value of variable "TVCommandResponse" is "QMI:H1" then
        -- HDMI 1 Input Selected
    else if value of variable "TVCommandResponse" is "QMI:H2" then
        -- HDMI 2 Input Selected
    else if value of variable "TVCommandResponse" is "QMI:H3" then
        -- HDMI 3 Input Selected
    else if value of variable "TVCommandResponse" is "QMI:H4" then
        -- HDMI 4 Input Selected
    else if value of variable "TVCommandResponse" is "QMI:PC" then
        -- PC (VGA) Input Selected
    else if value of variable "TVCommandResponse" is "QMI:SP" then
        -- Photo Media Player Input Selected
    else if value of variable "TVCommandResponse" is "QMI:SM" then
        -- Video Media Player Input Selected
    else if value of variable "TVCommandResponse" is "QMI:MC" then
        -- Music Media Player Input Selected
    else if value of variable "TVCommandResponse" is "QMI:VC" then
        -- VIERA Connect (Internet) Input Selected
    end if
    
else if value of variable "TVCommandResponse" starts with "VPC" then
    
    -- Picture Mode Change
    if value of variable "TVCommandResponse" is "VPC:VVT" then
        -- Vivid
    else if value of variable "TVCommandResponse" is "VPC:STD" then
        -- Standard
    else if value of variable "TVCommandResponse" is "VPC:THX" then
        -- THX
    else if value of variable "TVCommandResponse" is "VPC:CNM" then
        -- Cinema
    else if value of variable "TVCommandResponse" is "VPC:GAM" then
        -- Game
    else if value of variable "TVCommandResponse" is "VPC:CST" then
        -- Custom
    end if
    
else if value of variable "TVCommandResponse" starts with "QPC" then
    
    -- Picture Mode Query Response (same mode names as above).
    if value of variable "TVCommandResponse" is "QPC:VVT" then
        -- Vivid
    else if value of variable "TVCommandResponse" is "QPC:STD" then
        -- Standard
    else if value of variable "TVCommandResponse" is "QPC:THX" then
        -- THX
    else if value of variable "TVCommandResponse" is "QPC:CNM" then
        -- Cinema
    else if value of variable "TVCommandResponse" is "QPC:GAM" then
        -- Game
    else if value of variable "TVCommandResponse" is "QPC:CST" then
        -- Custom
    end if
    
else if value of variable "TVCommandResponse" starts with "DAM" then
    
    -- Aspect Mode Change
    if value of variable "TVCommandResponse" is "DAS:ZOOM" then
        -- Zoom
    else if value of variable "TVCommandResponse" is "DAS:FULL" then
        -- Full Screen
    else if value of variable "TVCommandResponse" is "DAS:JUST" then
        -- Justified (Stretch)
    else if value of variable "TVCommandResponse" is "DAS:NORM" then
        -- 4:3
    else if value of variable "TVCommandResponse" is "DAS:HFIL" then
        -- Fill (Stretch)
    end if
    
else if value of variable "TVCommandResponse" starts with "QAS" then
    
    -- Aspect Mode Request Response (same values as above).
    if value of variable "TVCommandResponse" is "QAS:ZOOM" then
        -- Zoom
    else if value of variable "TVCommandResponse" is "QAS:FULL" then
        -- Full Screen
    else if value of variable "TVCommandResponse" is "QAS:JUST" then
        -- Justified (Stretch)
    else if value of variable "TVCommandResponse" is "QAS:NORM" then
        -- 4:3
    else if value of variable "TVCommandResponse" is "QAS:HFIL" then
        -- Fill (Stretch)
    end if
    
else if value of variable "TVCommandResponse" starts with "INF" then
    
    -- Info (Resolution) Request Response.
    set t to value of variable "TVCommandResponse"
    set l to (count of characters in t)
    set n to (characters 5 through l of t) as text
    -- n is the current TV resolution.
    
else if value of variable "TVCommandResponse" starts with "QIF" then
    
    -- Resolution Request Response (same as above)
    set t to value of variable "TVCommandResponse"
    set l to (count of characters in t)
    set n to (characters 5 through l of t) as text
    -- n is the current TV resolution.
    
end if

You can add your own AppleScript code to the areas above where I've left comments about what information was returned. For me, I assign values such as current input selection and picture mode into other Indigo variables for display on a control page viewable from my iPhone (or web browser, or other iOS device).

That should be it! For my setup, I use an iPod touch as an Indigo Touch client that views a control page I set up just for the TV. It shows the TV's current input, resolution, picture mode, and aspect mode and allows me to emulate a TV remote control with the iPod touch using an Indigo control page.

Posted on
Sat Jun 25, 2011 10:12 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Panasonic TC-P65VT30 Integration

Have you considered making this into an Indigo 5 plugin?

Note that pyserial is included as part of the plugin architecture (for v5 only). The EasyDAQ Plugin uses it -- you can access its source code by opening up the bundle (via right-clicking on it).

Image

Posted on
Tue Jun 28, 2011 10:07 am
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Panasonic TC-P65VT30 Integration

A plugin would be really cool... ;)

And a lot easier to use for others!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 29, 2011 1:20 am
nsheldon offline
Posts: 2469
Joined: Aug 09, 2010
Location: CA

Re: Panasonic TC-P65VT30 Integration

Hey guys.

Yea, a plugin would certainly be easier for everyone (with v5) to use. I'm considering making a plugin for this (and for the other hardware integration posts I've made recently). I was going to mess around with Indigo 5 using the trial key, but the limitations of the trial make that pretty much untenable with as many devices as I have. Maybe I'll buy a full key next month. We'll see how much I have left after making payments on all the other toys I've (obviously) recently acquired. Hahaha!

Posted on
Wed Jun 29, 2011 7:45 pm
matt (support) offline
Site Admin
User avatar
Posts: 21411
Joined: Jan 27, 2003
Location: Texas

Re: Panasonic TC-P65VT30 Integration

Note you can leave Indigo v4 installed on your system -- the v5 installer does not touch any v4 files. Just make sure you don't try to run them both at the same time (choose the Indigo->Stop Local Server menu item). Not ideal, but we have no way to generate a trial version currently that doesn't have the 20 device limitation. We've thought about removing it from the trial version, but I'm afraid quite a few Lite customers would be angry because they wouldn't realize they have 20+ devices until they purchase Lite and then some devices stop working. We could make that smarter with warnings, etc., but it isn't a priority at this point.

Image

Posted on
Fri Aug 26, 2011 8:47 pm
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

Re: Panasonic TC-P65VT30 Integration

Oh please, oh PLEASE make this a plugin.
It would be really great to be able to pop variables into a form and configure different RS232 scripts to go along with actions.

It would be great to be able to make these types of cross-device / system communications easy to accomplish. Personally, I am using a Lync6 from HTD.com and want to be able to switch a zone on or off, change it's source, and perhaps even run a "program schedule" for that room. Imagine in the morning if you went into the kitchen in the morning and when you flipped the light on, it turned the news on the speakers for 5 minutes, then switched over the audio input to the mac, which would read a traffice report and weather update to you that it scraped off the web. Then, back to the news.

It is all possible if you can get indigo to easily integrate with controllers/tuners that can talk over serial.

Any takers? Hell, I'd pay 100 bucks for that.

dave

Posted on
Sun Nov 13, 2011 12:43 am
Korey offline
User avatar
Posts: 811
Joined: Jun 04, 2008
Location: Henderson, NV

Re: Panasonic TC-P65VT30 Integration

dmeeker@mac.com wrote:
Oh please, oh PLEASE make this a plugin.
It would be really great to be able to pop variables into a form and configure different RS232 scripts to go along with actions.

It would be great to be able to make these types of cross-device / system communications easy to accomplish. Personally, I am using a Lync6 from HTD.com and want to be able to switch a zone on or off, change it's source, and perhaps even run a "program schedule" for that room. Imagine in the morning if you went into the kitchen in the morning and when you flipped the light on, it turned the news on the speakers for 5 minutes, then switched over the audio input to the mac, which would read a traffice report and weather update to you that it scraped off the web. Then, back to the news.

It is all possible if you can get indigo to easily integrate with controllers/tuners that can talk over serial.

Any takers? Hell, I'd pay 100 bucks for that.

dave


+1

A RS232 plugin like this would be a fantastic integration of home theater control into Indigo!
A plugin that could use USB to serial convertors ( Keyspan, ect) or the Global cache GC100 / iTach serial units would be great! :D

--
Korey

Posted on
Tue Nov 29, 2011 1:11 am
mat offline
Posts: 769
Joined: Nov 25, 2010
Location: Cambridgeshire - UK

Re: Panasonic TC-P65VT30 Integration

+1 for a plugin, considering a VT at the moment but was put off by the advertising on the tv guide. This would outweigh my concern!

Great work!

Late 2018 mini 10.14

Posted on
Tue Nov 29, 2011 10:49 am
dmeeker@mac.com offline
Posts: 85
Joined: Aug 26, 2011

Re: Panasonic TC-P65VT30 Integration

Jim has been working on a plugin: Simple Serial.

See this thread:

viewtopic.php?f=18&t=7355


Things are progressing well. Give it a shot!


Dave

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests