DENON AVR Control Working

Posted on
Sat Feb 14, 2009 12:31 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

DENON AVR Control Working

This morning I finally sat down and resolved the problems I have had getting applescript to control my Denon AVR (a 3808ci). It now works, though it is a bit of a kludge.

First, I have a simple shell script to pass the commands to the AVR using netcat:
Code: Select all
#!/bin/bash
echo -ne $1\\r| /usr/bin/nc -w1  denon 23

This just takes the first argument ($1) and passes it to the AVR on the telnet port (23). I named the shell "dencmd" and, for now, I have left it in my home directory. The -ne arg for echo tells it to not add any line ending character and the \\r places a carriage return alone after $1 (the command). The -w1 arg for nc tells it to quit 1 second after sending it's input. The arg denon is the host name I created in /etc/hosts and 23 is the port number to connect to.

Then, I created actions for all of the commands I wanted and used the following embedded applescript as the action of the action:
Code: Select all
do shell script "/Users/rdp/dencmd CMDPRM"

Where CMD is the command and PAR is the parameter from the Denon AVR command set. For example, to turn on the AVR I used:
Code: Select all
do shell script "/Users/rdp/dencmd PWON"
PW is the command (for power) and ON is the parameter.
The commands and parameters are the same as for the RS-232 interface. For my AVR they are listed here.

I placed all of actions in a folder for convenience and can now control my AVR from my iPod Touch. I will probably create a web page do provide the interface, but that will have to wait a while.

Richard

Posted on
Thu Jun 17, 2010 5:02 am
screen offline
Posts: 31
Joined: Feb 19, 2009

Re: DENON AVR Control Working

Hi Richard,

Thanks for posting this script. I was using it for a while but I wanted to be able to read responses and sync states from my receiver to variables within Indigo. I tested out using netcat but had problems getting responses. I settled on using expect. Here's the script I'm using now:

Code: Select all
#!/usr/bin/expect
set timeout 20
set dencmd [lindex $argv 0]
log_user 0

spawn telnet 192.168.1.11
expect "Trying"
expect {
  timeout {
    send_user "\rTimeout waiting for Denon response.\r"
    send_user "$expect_out(buffer)\r"
    exit
  }
  "Connection refused" {
    send_user "UNABLE\n"
    exit
  }
  "BridgeCo AG Telnet server\r\n"
}
send "$dencmd\r"
expect "$dencmd\r\n"
expect "*\r"
send_user "$expect_out(buffer)\n"
exit


I'm syncing power status, mute status and current volume. Here's an example applescript that queries the current volume and stores it in a variable:

Code: Select all
set Response to do shell script "/Users/lucas/bin/dencmd MV? | tr \"\\r\" \"\\n\" | head -n 1"
if Response is "UNABLE" then
else if Response starts with "MV" then
    set VolA to character 3 of Response & character 4 of Response
    set VolB to ""
    try
        if character 5 of Response is not "" then
            set VolB to "." & character 5 of Response
        end if
    end try
    set value of variable "curDenonVolume" to VolA & VolB
end if


Volume status requests return multiple values, we must change \r to \n and use only the first line in this case. I have this hooked up to a Time/Date action in Indigo. Since I'm syncing multiple variables, every 5 minutes, I set the interval to 5 then each following Denon event to a fraction like 5.17, 5.33 etc. This avoids UNABLE failures during the timer events. Unfortunately Indigo doesn't (yet?) support decimal notation in the "Randomize by" field.

A simple command to turn on the receiver is similar to what you have and since I'm tracking the status of what I'm changing I also update the associated variable:

Code: Select all
if value of variable "isDenonOn" is not "true" then
    do shell script "/Users/lucas/bin/dencmd PWON"
    set value of variable "isDenonOn" to "true"
end if
Attachments
Denon Indigo Touch Contral Page.png
Here's the control page I use with Indigo touch to control the receiver when I want to run iTunes remote or stream bluetooth audio to it.
Denon Indigo Touch Contral Page.png (81.25 KiB) Viewed 6621 times

Posted on
Thu Jun 17, 2010 10:26 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: DENON AVR Control Working

thanks screen. I finally abandoned my earlier attempt, it was too kludgy and , as you noted, there was no feedback. Expect seems like a good way to go. seanadams has a Perl script (actually a set of scripts) that can manage communications with the a variety of devices - but, it is fairly complex and I haven't really dug into it yet.

Posted on
Wed Aug 29, 2012 2:02 pm
veshman offline
Posts: 10
Joined: Aug 02, 2012

Re: DENON AVR Control Working

Thank you!

This little snippet of code (at the top) was perfect for my needs. I just want to change modes on my Denon (like reference level offset) so I don't have need for feedback. This is great since I can just do a "do shell script" command in Remote Buddy.

Thanks again!

bhavesh

Posted on
Wed Aug 29, 2012 2:25 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: DENON AVR Control Working

Glad it was useful.

BTW, if you are running Indigo 5.x pro, you might want to take a look at the Cynical Denon - Denon and Marantz AV Receiver control plugin.

Posted on
Wed Aug 29, 2012 2:58 pm
veshman offline
Posts: 10
Joined: Aug 02, 2012

Re: DENON AVR Control Working

..... much to my chagrin, I have to take that back..... it works for a command or two, but then it craps out and the Denon stops responding to anything except IR. To get it work with Roomie or other IP based controllers, I have to unplug the Denon.

Any thoughts? Maybe the connection needs closing?

Posted on
Thu Aug 30, 2012 12:56 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: DENON AVR Control Working

Sorry, not much I can suggest. I am not at a location where I can test this. Also, as I noted, I dropped this approach a while ago. I think the plugin is the way to go.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 21 guests