|
Page 1 of 2
|
[ 17 posts ] |
Go to page: 1, 2 Next |
Pioneer VSX-1021-K AV Receiver Integration
| Author |
Message |
|
nsheldon
Joined: Aug 09, 2010 Posts: 767 Location: CA
|
 Pioneer VSX-1021-K AV Receiver Integration
Part of my recent home theater upgrade included replacing my old AV receiver with the just-released Pioneer VSX-1021-K AV receiver. One of the reasons I chose that receiver was the availability of an iOS remote control app which operates over your home network. Like my recent Panasonic Blu-ray player to Indigo integration process, I did some packet sniffing on my network while the iPod app and the receiver were communicating to discover their communication protocol. What I later found out (and what's not in the manual) is that this receiver can also be integrated with whole-home automation systems using Pioneer's published command sets for their Elite series receivers (using a standard telnet connection, see these RS-232 commands for the similar 1120 model here) without affecting the iOS app or IR remote functions. So, I devised a way to both send commands to the VSX-1021-K and for all response messages from the receiver to be put immediately into an Indigo variable using a persistent telnet connection to the receiver in the background. Be forewarned, this is a somewhat advanced setup, so if you'd like to replicate this with the VSX-1021-K or other networked Pioneer receiver, be prepared to do quite a bit of command-line work on the Mac with Indigo running on it. Setup requirements:- Pioneer VSX-1021-K (or similar networkable Pioneer receiver. The command set is similar for all of them).
- Wired network connection to the receiver (a Wi-Fi connection may work with the optional wireless adapter, but I haven't tested this).
- Static IP address assigned to the receiver.
- Indigo 4 Pro (or later).
- The Mac running Indigo Pro will need to be on all the time.
1. Creating a Persistent Connection to the ReceiverThis is a 2 stage process. First, we need to create a shell script that will act as a receiver response proxy, sending all command responses from the receiver to a variable in Indigo. Second, we need to create a LaunchAgent definition for this shell script so whenever you restart the computer (or log out then back in), the connection to the receiver is re-estabilshed. Stage 1- Open the Indigo Pro client and create 2 variables. First, a variable named "ReceiverCommand" and second, a variable named "ReceiverCommandResponse".
- Open the Terminal application (/Applications/Utilities) on the Mac with Indigo server running on it. Be sure you're logged into the computer as the same user from which IndigoServer runs, otherwise none of this will work. In most cases, you will be logged into the computer as that user.
- Use the "vi" or "nano" command-line text editor to create the shell script. I prefer vi, but nano is simpler to use if you're new to command-line work. (The "^" character in the nano command list at the bottom of the main nano screen represents pressing the "control" key while pressing the letter immediately after the "^" character). Begin creating the shell script with the "vi" tool by typing
- Code: Select all
vi "/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/receiver_connect.sh"
or by typing the following for use with the "nano" tool
- Code: Select all
nano "/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/receiver_connect.sh"
From here on, I'll assume that you know how to insert text and save it once you're done with whichever editor you're using. Note that if you're doing this with Indigo 5, you'll need to change the "Indigo 4" path above to "Indigo 5" and be sure the "Scripts" and "Background Tasks" folders exist in the Indigo 5 folder. - Insert the following code into this new receiver_connect.sh file.
- Code: Select all
#!/bin/bash
nc -k -l 65023 | telnet 192.168.1.190 | while read line do /usr/bin/osascript -e "tell application \"IndigoServer\"" -e "set value of variable \"ReceiverCommandResponse\" to \"$line\"" -e "end tell" done
Replace the 192.168.1.190 IP address above with your receiver's actual IP address then save the file. This simple shell script uses the "nc" (netcat) tool to continuously listen for commands sent on TCP/IP port 65023 (this is a random number I picked) then re-send those commands to the telnet application, which is connected to the receiver. The telnet application sends those commands to the receiver which then produces a textual command response. The telnet application outputs those responses to the built-in shell "while" loop in the above script. The "while" loop reads one line of text from telnet at a time and uses the "osascript" tool to execute AppleScript telling IndigoServer to update the "ReceiverCommandResponse" variable with the receiver's response message. - Run the following command to make the shell script executable by the current user and group (being sure to replace "Indigo 4" with "Indigo 5" if you're using that version).
- Code: Select all
chmod ug+x "/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/receiver_connect.sh"
Stage 2- Open the Terminal application (if it's not already open). Again, you must be logged into the computer as the user under which IndigoServer is running.
- Create a new LaunchAgent file so that when you log out then back in or restart the computer, the connection to the receiver is re-established. The following command is for the "vi" tool, but just replace "vi" with "nano" if you prefer that text editor.
- Code: Select all
vi ~/Library/LaunchAgents/com.nathansheldon.receiver_connect.plist
- Insert the following code into that file. Be sure to change "Indigo 4" to "Indigo 5" if you're using Indigo 5.
- Code: Select all
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Disabled</key> <false/> <key>KeepAlive</key> <true/> <key>WorkingDirectory</key> <string>/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks</string> <key>Program</key> <string>/Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/receiver_connect.sh</string> <key>Label</key> <string>com.nathansheldon.receiver_connect</string> </dict> </plist>
Save the file. This XML code instructs the launchd process that always runs on Mac OS X to run the shell script you just created every time you log into the current user account. 2. Setting up a Trigger in Indigo to Send Commands- Open the Indigo Pro client (if it isn't already open).
- Create a new trigger with the following parameters.
Trigger tab Name: <whatever you like, I use "Send Receiver Command"> Type: "Variable Changed" Variable: "ReceiverCommand", "changes" radio button selected. Condition tab Upon trigger do actions: "If script returns true:" selected with the following code in the field below that button. - Code: Select all
if value of variable "ReceiverCommand" is not "" then return true else return false end if
Actions tab Type: "Execute AppleScript" Embedded: radio button selected, with the following code inserted in the text area below it. - Code: Select all
set theCommand to value of variable "ReceiverCommand"
-- Send the command to the receiver via netcat (nc). do shell script "echo \"" & theCommand & "\" | nc localhost 65023"
-- Reset the ReceiverCommand variable to blank. set value of variable "ReceiverCommand" to ""
This trigger activates whenever the "ReceiverCommand" variable changes (unless that variable contains nothing) then sends the content of the "ReceiverCommand" variable to the receiver using the "nc" (netcat) tool. It then clears the content of the "ReceiverCommand" variable.
The list of commands that can be sent are pretty extensive. You'll need to reference the Pioneer RS-232 command set for one of their existing receivers (I used the reference for the VSX-1120-K receiver in this PDF). Some basic commands include (without the quotes) "PO" (Power On), "PF" (Power ofF), "VU" (Volume Up 0.5 dB), "VD" (Volume Down 0.5 dB), "?P" (returns the current power state of "PWR1" for power off or "PWR0" for power on), "?V" (returns the current numeric volume level from "VOL0" to "VOL185" which represent 0.5 dB increments from -80.5 dB), and "?FN" (returns the current input selection as a number such as "FN02" for the radio tuner). To send a command, simply change the value of the "ReceiverCommand" variable to one of the above (or other valid) commands. The receiver's response to those commands will almost instantly appear as the value for the "ReceiverCommandResponse" variable. 3. Logout then Login or Restart the ComputerThis is the easiest way to start the background connection to the receiver (though you could also just run the launchctl command with the appropriate parameters, but this is easier). 4. Setting up a Trigger in Indigo to Handle Command ResponsesThis is where a lot of customization for your specific setup comes in. For my setup, I created the following trigger. Trigger tabName: <whatever you like. I used "Receiver Command Response"> Type: "Variable Changed" Variable: "ReceiverCommandResponse", "changes" radio button selected. Condition tabUpon trigger do actions: "If script returns true:" selected with the following code in the field below that button. - Code: Select all
if value of variable "ReceiverCommandResponse" is not "" then return true else return false end if
Actions tabType: "Execute AppleScript" Embedded: radio button selected, with the following code inserted in the text area below it. - Code: Select all
-- Custom actions based on responses. if value of variable "ReceiverCommandResponse" is "BridgeCo AG Telnet server" then -- Receiver Connection Initiated -- To work around a bug that causes an E04 (unknown command) error response on the first command when the receiver_connect.sh daemon first connects to the receiver, send a ?P power status request to clear the error. set value of variable "ReceiverCommand" to "?P" else if value of variable "ReceiverCommandResponse" is "PWR0" then -- Power On set value of variable "isReceiverPowerOn" to "true" set value of variable "ReceiverCommand" to "?V" delay 0.1 set value of variable "ReceiverCommand" to "?M" else if value of variable "ReceiverCommandResponse" is "PWR1" then -- Power Off
else if value of variable "ReceiverCommandResponse" is "MUT0" then -- Mute On
else if value of variable "ReceiverCommandResponse" is "MUT1" then -- Mute Off
else if value of variable "ReceiverCommandResponse" starts with "FN" then -- Input Change set i to value of variable "ReceiverCommandResponse" set i to (characters 3 through 4 of i) as text if i is "01" then -- CD else if i is "02" then -- TUNER -- Request the current band/frequency set value of variable "ReceiverCommand" to "?FR" delay 0.1 set value of variable "ReceiverCommand" to "?PR" else if i is "03" then -- CD-R/TAPE else if i is "04" then -- DVD else if i is "05" then -- TV/SAT else if i is "10" then -- VIDEO 1 else if i is "14" then -- VIDEO 2 else if i is "15" then -- DVR/BDR else if i is "17" then -- iPod/USB else if i is "19" then -- HDMI 1 else if i is "25" then -- BD else if i is "26" then -- Home Media Gallery else if i is "27" then -- SIRIUS end if -- Now request the input name of the current input. set value of variable "ReceiverCommand" to "?RGB" & i
else if value of variable "ReceiverCommandResponse" starts with "RGB" then -- Input Name Request set t to value of variable "ReceiverCommandResponse" set l to (count of characters in t) set n to (characters 7 through l of t) as text set v to (characters 4 through 5 of t) as text -- n is the input name. -- v is the input number. else if value of variable "ReceiverCommandResponse" starts with "VOL" then -- Volume Level set receiverVolume to value of variable "ReceiverCommandResponse" set receiverVolume to (characters 4 through 6 of receiverVolume) as text set receiverVolume to (receiverVolume) as number -- Convert volume to dB. if receiverVolume > 0 then set receiverVolumeDB to -80.5 + 0.5 * receiverVolume else set receiverVolumeDB to "-∞" end if -- receiverVolume is the numerical volume -- receiverVolumeDB is the associated decibel volume trip or amplification level (-infinity to +12 dB).
else if value of variable "ReceiverCommandResponse" starts with "FL" then -- Fluoro-Luminescent Display Content Request set theString to value of variable "ReceiverCommandResponse" set theString to (characters 5 through 32 of theString) as text set theResult to "" set i to 1 repeat until i > 28 set x to character i of theString set i to i + 1 set y to character i of theString if x is "A" then set x to 10 else if x is "B" then set x to 11 else if x is "C" then set x to 12 else if x is "D" then set x to 13 else if x is "E" then set x to 14 else if x is "F" then set x to 15 end if set x to x * 16 if y is "A" then set y to 10 else if y is "B" then set y to 11 else if y is "C" then set y to 12 else if y is "D" then set y to 13 else if y is "E" then set y to 14 else if y is "F" then set y to 15 end if set theNum to x + y -- Special character handling. if theNum is 1 then set theChar to "rp/sh " else if theNum is 2 then set theChar to "rp " else if theNum is 3 then set theChar to "sh " else if theNum is 4 then set theChar to "◊ " else if theNum is 5 then set theChar to "[)" else if theNum is 6 then set theChar to "(]" else if theNum is 7 then set theChar to "I" else if theNum is 8 then set theChar to "II" else if theNum is 9 then set theChar to "<" else if theNum is 10 then set theChar to ">" else if theNum is 11 then set theChar to "\\^^/" else if theNum is 12 then set theChar to "." else if theNum is 13 then set theChar to ".0" else if theNum is 14 then set theChar to ".5" else if theNum is 15 then set theChar to "Ω" else if theNum is 16 then set theChar to "0" else if theNum is 17 then set theChar to "1" else if theNum is 18 then set theChar to "2" else if theNum is 19 then set theChar to "3" else if theNum is 20 then set theChar to "4" else if theNum is 21 then set theChar to "5" else if theNum is 22 then set theChar to "6" else if theNum is 23 then set theChar to "7" else if theNum is 24 then set theChar to "8" else if theNum is 25 then set theChar to "9" else if theNum is 26 then set theChar to "A" else if theNum is 27 then set theChar to "B" else if theNum is 28 then set theChar to "C" else if theNum is 29 then set theChar to "F" else if theNum is 30 then set theChar to "M" else if theNum is 31 then set theChar to "¯" else set theChar to ASCII character theNum end if set theResult to theResult & theChar set i to i + 1 end repeat -- theResult is the ASCII equivalent of what's displayed on the receiver display. else if value of variable "ReceiverCommandResponse" starts with "MC" then -- MCACC Memory Change set m to value of variable "ReceiverCommandResponse" set m to character 3 of m if m is "1" then -- MCACC Memory 1 selected else if m is "2" then -- MCACC Memory 2 selected else if m is "3" then -- MCACC Memory 3 selected else if m is "4" then -- MCACC Memory 4 selected else if m is "5" then -- MCACC Memory 5 selected else if m is "6" then -- MCACC Memory 6 selected end if else if value of variable "ReceiverCommandResponse" starts with "IS" then -- Phase Control Update set p to value of variable "ReceiverCommandResponse" set p to character 3 of p -- p = 0: Phase Control Off -- p = 1: Phase Control On -- p = 2: Full Band Phase Control On else if value of variable "ReceiverCommandResponse" starts with "VSB" then -- Virtual Sound Back Update set sb to value of variable "ReceiverCommandResponse" set sb to character 4 of sb -- sb = 0: Off -- sb = 1: On else if value of variable "ReceiverCommandResponse" starts with "VHT" then -- Virtual Height Update set h to value of variable "ReceiverCommandResponse" -- h = 0: Off -- h = 1: On else if value of variable "ReceiverCommandResponse" starts with "CLV" then -- Speaker Channel Volume Level Update set c to value of variable "ReceiverCommandResponse" set l to (characters 7 through 8 of c) as text set l to (l) as number set c to (characters 4 through 6 of c) as text -- c = L__: Front Left -- c = R__: Front Right -- c = C__: Center -- c = SL_: Surround Left -- c = SR_: Surround Right -- c = SBL: Surround Back Left -- c = SBR: Surround Back Right -- c = SW_: Subwoofer -- c = LH_: Front Left Height -- c = RH_: Front Right Height -- c = LW_: Front Left Wide -- c = RW_: Front Right Wide -- l = 26 - 74: channel volume from -12 dB to +12 dB (in 0.5 dB increments) else if value of variable "ReceiverCommandResponse" starts with "SPK" then -- Speaker Status Update set s to value of variable "ReceiverCommandResponse" set s to character 4 of s -- s = 0: Speakers Off -- s = 1: Speakers A On -- s = 2: Speakers B On -- s = 3: Speakers A+B On else if value of variable "ReceiverCommandResponse" starts with "HA" then -- HDMI Audio Select Update set h to value of variable "ReceiverCommandResponse" set h to character 3 of h -- h = 0: Amp -- h = 1: Through else if value of variable "ReceiverCommandResponse" starts with "PQ" then -- PQLS Status Update set p to value of variable "ReceiverCommandResponse" set p to character 3 of p -- p = 0: Off -- p = 1: Auto else if value of variable "ReceiverCommandResponse" starts with "PKL" then -- Panel Key Lock Status Update set p to value of variable "ReceiverCommandResponse" set p to character 4 of p -- p = 0: Panel Key and Volume Lock Off -- p = 1: Panel Key Lock On -- p = 2: Panel Key and Volume Lock On else if value of variable "ReceiverCommandResponse" starts with "RML" then -- Remote Lock Status Update set r to value of variable "ReceiverCOmmandResponse" set r to character 4 of r -- r = 0: Off -- r = 1: On else if value of variable "ReceiverCommandResponse" is "APR0" then -- Zone 2 Power On else if value of variable "ReceiverCommandResponse" is "APR1" then -- Zone 2 Power Off else if value of variable "ReceiverCommandResponse" starts with "Z2F" then -- Zone 2 Input Select Update set z to value of variable "ReceiverCommandResponse" set z to (characters 4 through 5 of z) as text -- See "Input Change" definitions for the "FN*" response above else if value of variable "ReceiverCommandResponse" starts with "FR" then -- Tuner Frequence Change set f to value of variable "ReceiverCommandResponse" set b to character 3 of f set f to (characters 4 through 8 of f) as text if b is "F" then set tmp to (characters 1 through 3 of f) as text set tmp to tmp & "." set tmp to tmp & (characters 4 through 5 of f) as text set f to (tmp) as number else set f to (f) as number end if -- b = A: AM -- b = F: FM -- f = frequency (either in kHz for AM or MHz for FM). else if value of variable "ReceiverCommandResponse" starts with "PR" then -- Tuner Preset Change set p to value of variable "ReceiverCommandResponse" set n to (characters 4 through 5 of p) as text set n to (n) as number set p to character 3 of p -- p = A - G: Preset Class A through G -- n = 0 - 9: Preset Number (within class) 0 through 9 -- Request the band and frequency of this preset. set value of variable "ReceiverCommand" to "?FR" else if value of variable "ReceiverCommandResponse" starts with "SIR" then -- Sirius Satellite Radio Channel Change set s to value of variable "ReceiverCommandResponse" set s to (characters 4 through 7 of s) as text set s to (s) as number -- s: Sirius channel number end if
Happy hacking! 
|
| Tue Jun 07, 2011 10:18 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Excellent! Given any thought to making a plugin for this?
_________________ Jay (Indigo Support)
|
| Tue Jun 07, 2011 10:45 pm |
|
 |
|
nsheldon
Joined: Aug 09, 2010 Posts: 767 Location: CA
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Hey Jay.
Thanks. Yea, I've thought about it, along with a plug-in for the Panasonic DMP-BDT210 Blu-ray player from my other post. I have one more home theater component to integrate, though (a Panasonic TC-P65VT30 TV). Once I've got all those integrated into my setup, I may start messing around with Indigo 5 plug-ins.
|
| Wed Jun 08, 2011 4:34 pm |
|
 |
|
maven
Joined: Nov 15, 2010 Posts: 2
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Just wanted to follow up with nsheldon. I also have a Pioneer VSK-1021 and would love this plugin. Any chance in making a Indigo 5 plugin? My hope would be to create a Indigo Control Screen with buttons to change from TV mode to Movie mode. Turning the unit on/off and switching inputs would be great. It would be most appreciated.
|
| Wed Jan 11, 2012 5:30 pm |
|
 |
|
nsheldon
Joined: Aug 09, 2010 Posts: 767 Location: CA
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Hi maven.
I'm still thinking about the plug-in. I don't know much Python, so it'll take a while to get this done. As for your envisioned use, that's pretty much what I do. I use an iPod touch with Indigo Touch and Indigo Control Pages with custom remote control button images I created to control my home theater setup (receiver, blu-ray player, TV and room lighting). I had that set up in Indigo 4, so it's possible to do without a plug-in, but certainly not as turn-key. I'll post here when I eventually get a plug-in developed.
Regards, Nathan
|
| Thu Feb 09, 2012 6:38 pm |
|
 |
|
finkej
Joined: Jan 28, 2012 Posts: 10 Location: Troy NY
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
If you need beta testers for the AV plug in, let me know. I just got that receiver yesterday. I expect I will be playing with your code you already posted.
|
| Wed Feb 15, 2012 11:40 am |
|
 |
|
Juju
Joined: Aug 31, 2011 Posts: 56 Location: Toulouse - FRANCE
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Hello everybody,
I'm working on several plugins at this time, so I know a little bit the Indigo plugin architecture and python. As I have a Pioneer VSX-920 AV receiver, I will have a look on the informations you gave nsheldon, and see if I can start a plugin.
I will keep you informed.
|
| Fri Feb 17, 2012 7:09 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11697 Location: Texas
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Terrific!
_________________
|
| Fri Feb 17, 2012 7:47 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
When you're ready, we can create a forum for you (or your company) in the 3rd Party Developers section where you can provide documentation and support for your plugins if you like - others have found it useful I think. We look forward to seeing all the plugins that you've been working on!
_________________ Jay (Indigo Support)
|
| Fri Feb 17, 2012 12:34 pm |
|
 |
|
Juju
Joined: Aug 31, 2011 Posts: 56 Location: Toulouse - FRANCE
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
I made some tests on my AV receiver. I reached to open a telnet connection with Terminal and send commands.
Is there an existing Indigo plugin which enable a telnet connection with a device ? I had a look on Cynical Network, but I think it is very complex for this need.
|
| Sat Feb 18, 2012 2:41 am |
|
 |
|
berkinet
Joined: Nov 18, 2008 Posts: 1721 Location: Berkeley, CA
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Take a look at the ad2usb plugin. You won't need serial support. But, that is easy to delete.
|
| Sat Feb 18, 2012 5:34 am |
|
 |
|
Juju
Joined: Aug 31, 2011 Posts: 56 Location: Toulouse - FRANCE
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
I saw there is also a telnet library included in Python. I will have a look on this too.
|
| Sat Feb 18, 2012 9:47 am |
|
 |
|
berkinet
Joined: Nov 18, 2008 Posts: 1721 Location: Berkeley, CA
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
I think you will find the pyserial module will be the easiest way to go. For one thing, it is already included with Indigo. If you PM me your email address I can send a very basic example that should get you started. \
|
| Sat Feb 18, 2012 11:01 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6662 Location: Austin, Texas
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
Actually using a telnet connection in Python is super simple - PySerial seems like overkill (depending on what the API looks like perhaps).
_________________ Jay (Indigo Support)
|
| Sat Feb 18, 2012 6:25 pm |
|
 |
|
Juju
Joined: Aug 31, 2011 Posts: 56 Location: Toulouse - FRANCE
|
 Re: Pioneer VSX-1021-K AV Receiver Integration
berkinet, PM sent. Jay, your example uses telnetlib, and that's what I saw.
I will try the two solutions (pyserial and telnetlib) and see what's the best one.
|
| Sun Feb 19, 2012 4:37 am |
|
|
|
Page 1 of 2
|
[ 17 posts ] |
Go to page: 1, 2 Next |
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|