Control Denon AVR (plugin-free solution)

Hi,

As an alternative to the Denon Plugin, here is a LUUP-scene based implementation that allows control of a Denon A/V receiver.

The idea of not using the plugin is to avoid a persistent connection to the AVR (and errors when it’s not powered on) & remove a dependency.
This LUUP code provides a short & simple solution, which allows scenes as “Turn AVR ON if currently OFF, set volume to xx and switch to favorite station x”.

Common code that can either be put in Startup LUA, or at the beginning of the scene:

[tt]
local socket = require “socket”
local denon_tcp

function logDenon(msg)
luup.log("DENON: " … msg)
end

function connectDenon()
if denon_tcp then
logDenon(“Already connected”)
return false
else
logDenon(“Connecting…”)
denon_tcp = assert(socket.tcp())
denon_tcp:settimeout(0.5)
local status, error = denon_tcp:connect(“”, 23)
if status then
logDenon(“Connected”)
return true
else
denon_tcp = nil
logDenon("Error connecting: " … error)
return false
end
end
end

function sendDenon(cmd)
local buf = “”, s, status, partial
status = nil
logDenon("Sending " … cmd)
denon_tcp:send(cmd … “\r”)
while not status do
s, status, partial = denon_tcp:receive(1)
if s == “\r” then
status = true
else
if not status then
buf = buf … s
else
logDenon("Error receiving: " … status)
end
end
end
logDenon("Received " … buf)
sleepDenon()
return buf
end

function disconnectDenon()
logDenon(“Disconnecting…”)
denon_tcp:close()
denon_tcp = nil
logDenon(“Disconnected”)
end

function sleepDenon()
luup.sleep(500)
end

function powerOnDenon()
local pw_status = sendDenon(“PW?”)
if pw_status == “PWSTANDBY” then
sendDenon(“PWON”)
sleepDenon()
end
end

function powerOffDenon()
sendDenon(“PWSTANDBY”)
end
[/tt]

Example of use:
[tt]
if connectDenon() then
powerOnDenon()
sendDenon(“MV15”) – set volume to 15
sendDenon(“ZMFAVORITE3”) – switch to favorite station 3
disconnectDenon()
end
[/tt]

thanks! i will test with an AVR 4520 and let you know how it goes.

@cedricm

do i need to worry about “LEAK” in my log? Thanks!

50 02/03/14 22:58:24.337 luup_log:0: DENON: Sending Z2? __LEAK__ this:77824 start:2199552 to 0x26cc000 <0x33cec680> 50 02/03/14 22:58:24.364 luup_log:0: DENON: Received Z2OFF __LEAK__ this:4096 start:2203648 to 0x26cd000 <0x33cec680> 50 02/03/14 22:58:24.880 luup_log:0: DENON: Disconnecting... <0x33cec680> 50 02/03/14 22:58:24.910 luup_log:0: DENON: Disconnected <0x33cec680> 50 02/03/14 22:58:48.287 luup_log:0: DENON: Connecting... <0x33cec680> 50 02/03/14 22:58:48.420 luup_log:0: DENON: Connected <0x33cec680> 50 02/03/14 22:58:48.432 luup_log:0: DENON: Sending Z2? <0x33cec680> 50 02/03/14 22:58:48.446 luup_log:0: DENON: Received <0x33cec680> 50 02/03/14 22:58:48.960 luup_log:0: DENON: Disconnecting... <0x33cec680> 50 02/03/14 22:58:48.972 luup_log:0: DENON: Disconnected <0x33cec680> 50 02/03/14 22:59:22.237 luup_log:0: DENON: Connecting... <0x33cec680> 50 02/03/14 22:59:22.318 luup_log:0: DENON: Connected __LEAK__ this:28672 start:2277376 to 0x26df000 <0x33cec680> 50 02/03/14 22:59:22.330 luup_log:0: DENON: Sending MVUP <0x33cec680> 50 02/03/14 22:59:22.344 luup_log:0: DENON: Received <0x33cec680> 50 02/03/14 22:59:22.859 luup_log:0: DENON: Disconnecting... <0x33cec680> 50 02/03/14 22:59:22.871 luup_log:0: DENON: Disconnected <0x33cec680> 50 02/03/14 23:02:48.215 luup_log:0: DENON: Connecting... <0x33cec680> 50 02/03/14 23:02:48.248 luup_log:0: DENON: Connected __LEAK__ this:53248 start:2662400 to 0x273d000 <0x33cec680> 50 02/03/14 23:02:48.269 luup_log:0: DENON: Sending MVUP __LEAK__ this:16384 start:2678784 to 0x2741000 <0x33cec680> 50 02/03/14 23:02:48.296 luup_log:0: DENON: Received <0x33cec680> 50 02/03/14 23:02:48.949 luup_log:0: DENON: Disconnecting... <0x33cec680> 50 02/03/14 23:02:48.961 luup_log:0: DENON: Disconnected __LEAK__ this:8192 start:2764800 to 0x2756000 <0x33cec680> root@MiOS_30003318:~#

@cedricm

I seem to be having trouble receiving feedback.

[code]50 02/03/14 23:07:02.826 luup_log:0: DENON: Connecting… <0x33cec680>
50 02/03/14 23:07:02.901 luup_log:0: DENON: Connected <0x33cec680>
50 02/03/14 23:07:02.913 luup_log:0: DENON: Sending MV? <0x33cec680>

50 02/03/14 23:07:02.927 luup_log:0: DENON: Received <0x33cec680>

50 02/03/14 23:07:03.441 luup_log:0: DENON: Disconnecting… <0x33cec680>
50 02/03/14 23:07:03.460 luup_log:0: DENON: Disconnected <0x33cec680>
50 02/03/14 23:07:25.561 luup_log:0: DENON: Connecting… <0x33cec680>
50 02/03/14 23:07:25.637 luup_log:0: DENON: Connected <0x33cec680>
50 02/03/14 23:07:25.649 luup_log:0: DENON: Sending PW? <0x33cec680>

50 02/03/14 23:07:25.663 luup_log:0: DENON: Received <0x33cec680>

50 02/03/14 23:07:26.177 luup_log:0: DENON: Disconnecting… <0x33cec680>
50 02/03/14 23:07:26.191 luup_log:0: DENON: Disconnected <0x33cec680>
[/code]

the denon 4520 is on and does, for example change the volume when i tell it to so i know it is connecting.

50 02/03/14 23:10:12.391 luup_log:0: DENON: Connecting... <0x33cec680> 50 02/03/14 23:10:12.580 luup_log:0: DENON: Connected <0x33cec680> 50 02/03/14 23:10:13.381 luup_log:0: DENON: Sending MV32 <0x33cec680> 50 02/03/14 23:10:13.397 luup_log:0: DENON: Received <0x33cec680> 50 02/03/14 23:10:13.911 luup_log:0: DENON: Disconnecting... <0x33cec680> 50 02/03/14 23:10:13.924 luup_log:0: DENON: Disconnected <0x33cec680>

if i restart Lua, i can receive feedback once, but not again until i restart Lua

[code]50 02/03/14 23:13:32.432 luup_log:0: DENON: Connecting… <0x32c32680>
50 02/03/14 23:13:32.593 luup_log:0: DENON: Connected <0x32c32680>
50 02/03/14 23:13:32.609 luup_log:0: DENON: Sending MV? <0x32c32680>

50 02/03/14 23:13:32.634 luup_log:0: DENON: Received MV32 <0x32c32680>

50 02/03/14 23:13:33.151 luup_log:0: DENON: Disconnecting… <0x32c32680>
50 02/03/14 23:13:33.163 luup_log:0: DENON: Disconnected <0x32c32680>
50 02/03/14 23:15:14.201 luup_log:0: DENON: Connecting… <0x32c32680>
50 02/03/14 23:15:14.276 luup_log:0: DENON: Connected <0x32c32680>
50 02/03/14 23:15:14.288 luup_log:0: DENON: Sending MV? <0x32c32680>

50 02/03/14 23:15:14.300 luup_log:0: DENON: Received <0x32c32680>

50 02/03/14 23:15:14.819 luup_log:0: DENON: Disconnecting… <0x32c32680>
50 02/03/14 23:15:14.832 luup_log:0: DENON: Disconnected <0x32c32680>
[/code]

Please let me know if there is anything i can do to help figure this out !

Thanks

Hi!

Hmm, thinking about it: it seems to me that the Denon AVR doesn’t really like having multiple simultaneous TCP connections.
On my 2313, if I telnet to the denon:23, I can send commands & receive results. However, if I keep it open, this blocks other clients.

That was one reason for me to write this scene: it just connects while performing requested actions and disconnect right away… so that I can also use my laptop media keys to control volume playback on the Denon too.

Make sure that nothing else tries to connect to the Denon (and keeps a connection open), e.g., the plugin or whatever.

i do not think there is anything else connecting to it. curiously it receives info back after a luup restart, but then it does not. if i then restart luup it immediately receives just once then stops receiving again. however, it will respond to commands (e.g. to change the volume) even when it is not receiving responses. So it does not feel like it is something else getting in the way as best i can tell.

if we can’t figure it out on port 23 (which would be ideal if we can of course), i wonder if we should try connecting on Port 80 per this post?.. http://www.roomieremote.com/faq/#denon

thanks

Are you sure that the plugin is not trying to connect too?

The code should properly release the connection (at least, that’s the case here).

Can you run from the console :
$ netstat -an | grep

  1. just before the first execution of the scene
    => no connection should be shown. If you see one, restart LUUP or reboot and try again.

  2. during/right after the execution of the scene
    => a connection to :23 should be visible

  3. a couple of minutes after
    => no connection should be shown

Using the undocumented protocol on :80 might be easier/more robust… if you find some documentation somewhere! (in that case, calling luup.inet.wget with the right parameters might be just what is needed).

Sorry, I missed the part where you are saying that it’s responding to commands even if reply can’t be read.
This code stops reading the reply as soon as it receives a carriage return (\r) character. Maybe your unit sends more than one or whatever.
Might need to change the code to read as much data as it can until it blocks.

Is there anything I can do to help test whether the problem is extra r 's?

Sent from my iPhone using Tapatalk

I confirmed no connection to the denon before I run the scene or after I run it (and a connection when running it). The same when it responds and when it does not-- so I think you are probably right about the content received being the issue, perhaps with extra r’s

Sent from my iPhone using Tapatalk

Start coding :wink:

I don’t have much time to invest in this (and since it’s working for me… :wink: ).
You may want to try changing the sendDenon code to something like (totally untested):

[tt]function sendDenon(cmd)
local buf = “”, s, status, partial
logDenon("Sending " … cmd)
denon_tcp:send(cmd … “\r”)
while not status do
s, status, partial = denon_tcp:receive(1)
if not status then
buf = buf … s
else
logDenon("Error receiving: " … status)
end
end
logDenon("Received " … buf)
sleepDenon()
return buf
end[/tt]

You should get a timeout error after half a second, but this should also read as much data as it can (including trailing \r that would need to be removed later).
Might be interesting to see if it gets any the second time you run the scene.

Start coding ;)

trying :slight_smile:

i tried the new code and it does not work either. i put some logging code into the original and discovered that on the second try, it never gets past

while not status do

i wish i knew enough Lua to have a clue what might be going on :wink:

hmm, replace

[tt]local buf = “”, s, status, partial
[/tt]

with

[tt]local buf = “”, s, status = nil, partial
[/tt]

Quick comment on the code: it’s currently reading the reply coming from the AVR one char at a time in the “while… do … end” loop. So it needs to know when to stop:

[tt]while not status do[/tt]

simply loops as long as the “status” variable is null. If an error happens (connection lost, timeout…), status will be a string containing the error name… which will stop the loop.

Yes that’s it! Thanks so much.

EDIT: actually that gave me a lua error on startup, but adding " status = false " below that original line worked.

Oh, that’s great!
I didn’t know that LUA could play such tricks with uninitialized variables :smiley: Thanks for helping debugging!

I’m updating my first post then.

FYI, the timeout specified in the first post was using the wrong unit (should be sec instead of msec): this should be “denon_tcp:settimeout(0.5)” – fixed my first post.

On a related subject, I have improved upon this scene by mapping the Denon AVR to a standard Dimmer: dimming level is mapped to the AVR volume + 0% and OFF/ON buttons mapped to power OFF/ON.

The idea of using a standard Dimmer control is that no work is required to get it properly managed by third party remote apps: I can now control the ON/OFF state & volume directly from AutHomation.
And I can still write some scenes to switch the AVR to some known state (volume, favorite station, …).
The “Denon Dimmer” will also regularly query the AVR to update it’s state (useful if changed directly on the AVR or some other app) (and without keeping a connection open), and respond to the Poll commands to immediately update it’s state.

Ok that sounds like the beginning of a new plugin, but my goal is not to make it a full featured control, as I don’t use the Vera UI to control my devices.
If anybody is interested… contact me!

@cedricm ? very interested in the mapping to dimmer and on/off switch for each zone as well as periodic updating/polling, yes ! what do i need to do in order to set those up? Thanks!

Ok, here it is:

  • Save the following code as /etc/cmh-ludl/I_DenonDimmer.xml and set the appropriate IP address in this file.

  • Manually create a new device (Apps / Develop Apps / Create device) with:
    . device type: urn:schemas-upnp-org:device:DimmableLight:1
    . device file: D_DimmableLight1.xml
    . implementation file: I_DenonDimmer.xml

  • Reload the interface if needed, you should see the dimmer :wink:

  • To send commands from a scene, use the following luup code:
    luup.call_action(“urn:micasaverde-com:serviceId:HaDevice1”, “Poll”, {command = “PWON MV10 ZMFAVORITE1”}, )

    (replace with the id of the dimmer you just created. You can send multiple commands in a single call by separting them with a space.

No need for my previous code, you can remove it as it’s redundant.

If you want a Zone ON/OFF functionnality, you may use virtual switches devices (and call the appropriate luup code upon state change).

Let me know how it goes for you!

[tt]<?xml version="1.0"?>

local socket = require "socket"
local denon_tcp
local denon_ip = "<ip address>"

function logDenon(msg)
    luup.log("DENON: " .. msg)
end

function connectDenon()
    if denon_tcp then
        logDenon("Already connected")
        return false
    else
        logDenon("Connecting...")
        denon_tcp = assert(socket.tcp())
        denon_tcp:settimeout(0.5)
        local status, error = denon_tcp:connect(denon_ip, 23)
        if status then
            --logDenon("Connected")
            return true
        else
            denon_tcp = nil
            logDenon("Error connecting: " .. error)
            return false
        end
    end
end

function sendDenon(cmd)
    local buf = "", s, status, partial
    status = nil
    logDenon("Sending " .. cmd)

    denon_tcp:settimeout(0)
    buf, status, partial = denon_tcp:receive(9999)

    denon_tcp:settimeout(0.1)
    denon_tcp:send(cmd .. "\r")
    buf, status, partial = denon_tcp:receive(9999)
    if status then
        buf = partial
        if status ~= "timeout" then
            logDenon("Error receiving: " .. status .. ", partial: " .. partial)
        end
    end
    buf = string.gsub(buf, "\r", "")
    logDenon("Received " .. buf)
    sleepDenon()
    return buf
end

function disconnectDenon()
    --logDenon("Disconnecting...")
    denon_tcp:close()
    denon_tcp = nil
    logDenon("Disconnected")
end

function sleepDenon()
    luup.sleep(500)
end

function powerOnDenon()
    local pw_status = sendDenon("PW?")
    if pw_status == "PWSTANDBY" then
        sendDenon("PWON")
        sleepDenon()
    else
        logDenon("Not powering on, current status is " .. pw_status)
    end
end

function powerOffDenon()
    sendDenon("PWSTANDBY")
end

function initDenon(lul_device)
	if connectDenon() then
        updateDenonStatus(tonumber(lul_device))
        disconnectDenon()
    end
    luup.call_timer('initDenon', 1, "5m", "", lul_device)
end

function updateDenonStatus(lul_device)
    local pw_status = sendDenon("PW?")
    if pw_status == "PWSTANDBY" then
        luup.variable_set("urn:upnp-org:serviceId:SwitchPower1", "Status", "0", lul_device)
    elseif pw_status == "PWON" then
        luup.variable_set("urn:upnp-org:serviceId:SwitchPower1", "Status", "1", lul_device)
    end

    local mv_status = sendDenon("MV?")
    local vol_string = string.match(mv_status, "MV(%d*)")
    local vol = tonumber(vol_string)
    if vol then
        if string.len(vol_string) > 2 then
            vol = vol / 10
        end
        local vol_max = tonumber(string.match(mv_status, "MVMAX *(%d*)"))
        if vol_max then
            luup.variable_set("urn:upnp-org:serviceId:Dimming1", "LoadLevelStatus", tostring(math.floor(vol*100/vol_max)), lul_device)
        end
    end

    luup.variable_set("urn:micasaverde-com:serviceId:HaDevice1", "LastUpdate", os.time())
end
initDenon
<action>
 <serviceId>urn:upnp-org:serviceId:SwitchPower1</serviceId>
 <name>SetTarget</name>
  <run>
      if connectDenon() then
        if lul_settings.newTargetValue == "1" then
            powerOnDenon()
        else
            powerOffDenon()
        end
        updateDenonStatus(lul_device)
        disconnectDenon()
      end
  </run>
</action>

<action>
 <serviceId>urn:upnp-org:serviceId:Dimming1</serviceId>
 <name>SetLoadLevelTarget</name>
  <run>
      if connectDenon() then
        local mv_status = sendDenon("MV?")
        local vol = tonumber(lul_settings.newLoadlevelTarget)
        if vol then
            if vol == 0 then
                powerOffDenon()
            elseif vol == 100 then
                powerOnDenon()
            else
                local vol_max = tonumber(string.match(mv_status, "MVMAX *(%d*)"))
                if vol_max then
                    local vol_percent = math.floor((vol * vol_max / 100) * 2) / 2
                    local vol_string = string.format("%02i", math.floor(vol_percent))
                    if (vol_percent - math.floor(vol_percent) > 0) then
                        vol_string = vol_string .. math.floor((vol_percent - math.floor(vol_percent)) * 10)
                    end
                    sendDenon("MV" .. vol_string)
                end
            end
        end
        updateDenonStatus(lul_device)
        disconnectDenon()
      end
  </run>
</action>

<action>
 <serviceId>urn:micasaverde-com:serviceId:HaDevice1</serviceId>
 <name>Poll</name>
  <run>
      if connectDenon() then
          if lul_settings.command then
              local cmd
              for cmd in string.gmatch(lul_settings.command, "%S+") do
                  sendDenon(cmd)
              end
          end
          updateDenonStatus(lul_device)
          disconnectDenon()
      end
  </run>
</action>
[/tt]

thanks !

i set it up and did a test while listening to zone 2 with the main zone off. i dragged the volume slider (which i expected to do nothing as it controls the main zone) and it did indeed do nothing :wink: i then clicked ON and here is what i got in the log:

50 02/08/14 13:14:39.844 luup_log:289: DENON: Connecting... <0x340ca680> 50 02/08/14 13:14:39.846 luup_log:289: DENON: Sending MV? <0x340ca680> 50 02/08/14 13:14:39.947 luup_log:289: DENON: Received MV43MVMAX 74 <0x340ca680> 50 02/08/14 13:14:40.449 luup_log:289: DENON: Sending MV295 <0x340ca680> 50 02/08/14 13:14:40.550 luup_log:289: DENON: Received MV295MVMAX 72 <0x340ca680> 50 02/08/14 13:14:41.051 luup_log:289: DENON: Sending PW? <0x340ca680> 50 02/08/14 13:14:41.152 luup_log:289: DENON: Received PWONZ2ON <0x340ca680> 50 02/08/14 13:14:41.653 luup_log:289: DENON: Sending MV? <0x340ca680> 50 02/08/14 13:14:41.754 luup_log:289: DENON: Received MV295MVMAX 72 <0x340ca680> 50 02/08/14 13:14:42.257 luup_log:289: DENON: Disconnected <0x340ca680> 50 02/08/14 13:15:35.219 luup_log:289: DENON: Connecting... <0x33cca680> 50 02/08/14 13:15:35.221 luup_log:289: DENON: Sending MV? <0x33cca680> 50 02/08/14 13:15:35.322 luup_log:289: DENON: Received MV295MVMAX 72 <0x33cca680> 50 02/08/14 13:15:35.823 luup_log:289: DENON: Sending PW? <0x33cca680> 50 02/08/14 13:15:35.924 luup_log:289: DENON: Received PWONZ2ON <0x33cca680> 50 02/08/14 13:15:36.425 luup_log:289: DENON: Not powering on, current status is PWONZ2ON <0x33cca680> 50 02/08/14 13:15:36.425 luup_log:289: DENON: Sending PW? <0x33cca680> 50 02/08/14 13:15:36.526 luup_log:289: DENON: Received PWONZ2ON <0x33cca680> 50 02/08/14 13:15:37.027 luup_log:289: DENON: Sending MV? <0x33cca680> 50 02/08/14 13:15:37.128 luup_log:289: DENON: Received MV295MVMAX 72 <0x33cca680> 50 02/08/14 13:15:37.641 luup_log:289: DENON: Disconnected <0x33cca680> 50 02/08/14 13:15:37.651 luup_log:289: DENON: Connecting... <0x32cca680> 50 02/08/14 13:15:37.653 luup_log:289: DENON: Error connecting: connection refused <0x32cca680>

i imagine i need to make a copy of the I_ file and tweak the commands for each of zone 2 and 3 then create a device with each of those tweaked I_ files to control the other zones, yes? I will give a try if that makes sense and let you know how it goes. Thanks.

EDIT: just saw this __LEAK__line in the log. Do i need to worry about that? Thanks.

50 02/08/14 13:17:25.100 luup_log:289: DENON: Connecting... <0x32647680> 50 02/08/14 13:17:25.102 luup_log:289: DENON: Sending PW? <0x32647680> 50 02/08/14 13:17:25.204 luup_log:289: DENON: Received PWONZ2ON <0x32647680> 50 02/08/14 13:17:25.705 luup_log:289: DENON: Sending MV? <0x32647680> 50 02/08/14 13:17:25.806 luup_log:289: DENON: Received MV295MVMAX 72 __LEAK__ this:4096 start:2281472 to 0x26b3000 <0x32647680> 50 02/08/14 13:17:26.309 luup_log:289: DENON: Disconnected <0x32647680>

EDIT: I clicked “off” and it turned all zones off, but “off” was not showing in UI5. I clicked “on” – on/off status and volume is not reflected in UI5 (it says vol is 40 when main zone vol is actually 29.5). I think it is getting responses from the Denon it is not expecting. Perhaps it needs to look for substrings within the received response?

50 02/08/14 14:10:47.800 luup_log:289: DENON: Sending PWSTANDBY <0x33d76680> 50 02/08/14 14:10:48.831 luup_log:289: DENON: Received ZMOFFMNMEN OFFPWSTANDBY <0x33d76680> 50 02/08/14 14:10:49.333 luup_log:289: DENON: Sending PW? <0x33d76680> 50 02/08/14 14:10:49.434 luup_log:289: DENON: Received PWSTANDBYZ2OFF <0x33d76680> 50 02/08/14 14:10:49.935 luup_log:289: DENON: Sending MV? <0x33d76680> 50 02/08/14 14:10:50.036 luup_log:289: DENON: Received MV295MVMAX 72 <0x33d76680> 50 02/08/14 14:10:50.539 luup_log:289: DENON: Disconnected <0x33d76680> 50 02/08/14 14:11:36.636 luup_log:289: DENON: Connecting... <0x33f76680> 50 02/08/14 14:11:36.638 luup_log:289: DENON: Sending MV? <0x33f76680> 50 02/08/14 14:11:36.739 luup_log:289: DENON: Received MV295MVMAX 72 <0x33f76680> 50 02/08/14 14:11:37.240 luup_log:289: DENON: Sending PW? <0x33f76680> 50 02/08/14 14:11:37.341 luup_log:289: DENON: Received PWSTANDBYZ2OFF <0x33f76680> 50 02/08/14 14:11:37.842 luup_log:289: DENON: Not powering on, current status is PWSTANDBYZ2OFF <0x33f76680> 50 02/08/14 14:11:37.842 luup_log:289: DENON: Sending PW? <0x33f76680> 50 02/08/14 14:11:37.943 luup_log:289: DENON: Received PWSTANDBYZ2OFF <0x33f76680> 50 02/08/14 14:11:38.444 luup_log:289: DENON: Sending MV? <0x33f76680> 50 02/08/14 14:11:38.545 luup_log:289: DENON: Received MV295MVMAX 72 <0x33f76680> 50 02/08/14 14:11:39.049 luup_log:289: DENON: Disconnected <0x33f76680>

for example: i think it is looking for a response of PWSTANDBY to set the “off” button on the vera device but it gets “MNMEN OFFPWSTANDBYZ2OFFZ3OFF” so does not catch it. Similar situation with MV295 vs “MV295MVMAX 755”

50 02/08/14 14:22:58.690 luup_log:289: DENON: Sending PWSTANDBY <0x33976680> 50 02/08/14 14:22:58.791 luup_log:289: DENON: Received MNMEN OFFPWSTANDBYZ2OFFZ3OFF <0x33976680> 50 02/08/14 14:22:59.292 luup_log:289: DENON: Sending PW? <0x33976680> 50 02/08/14 14:22:59.393 luup_log:289: DENON: Received PWSTANDBYZ2OFF <0x33976680> 50 02/08/14 14:22:59.894 luup_log:289: DENON: Sending MV? <0x33976680> 50 02/08/14 14:22:59.996 luup_log:289: DENON: Received MV295MVMAX 755 <0x33976680>

EDIT: it also might not be computing the volume to send based on slider location correctly. i dragged the volume slider to about 50% (maybe less) and in UI5 the slider jumped down to the 3%. Looking at the log i think it sent an MV value the Denon did not understand and got no response:

50 02/08/14 14:19:21.473 luup_log:289: DENON: Sending MV3775 <0x33d76680> 50 02/08/14 14:19:21.574 luup_log:289: DENON: Received <0x33d76680> 50 02/08/14 14:19:22.075 luup_log:289: DENON: Sending PW? <0x33d76680> 50 02/08/14 14:19:22.176 luup_log:289: DENON: Received PWONZ2ONZ3ON <0x33d76680> 50 02/08/14 14:19:22.677 luup_log:289: DENON: Sending MV? <0x33d76680> 50 02/08/14 14:19:22.778 luup_log:289: DENON: Received MV295MVMAX 755 <0x33d76680> 50 02/08/14 14:19:23.281 luup_log:289: DENON: Disconnected <0x33d76680>

Hi!

I didn’t play yet with a second zone here, so I’ve no first hand experience on what is doable and best strategy.
However, I’m currently extending my house, and will add this second zone in April :wink:
If a second zone can be managed exactly as it was a separate AVR, ie, independent ON/OFF/Volume (albeit with slightly different commands), I guess that your approach is right (building a 2nd instance of the dimmer device).

About the LEAK, as far as I know, there’s nothing that can be in the LUUP code (which by itself is clean). This is most probably some kind of LUUP bug… but I would not worry about this.

Reading further your post: indeed if you get ‘PWSTANDBYZ2OFF’, this is not properly managed by my code (which is looking for the exact PWSTANDBY string). Some tweaks in the string comparison logic is indeed required. Nothing difficult, but some time is needed to properly implement & test this :wink:

And if you have issues with the volume %, I guess that it’s because of ‘MVMAX 755’… here I’m have for a ‘MVMAX 60’… I didn’t expect a 3 digit max volume here :wink:
So I guess you need to modify the code a bit to divide MVMAX by 10 if reading a 3 digit string (just like I did for the current volume) – should be done in updateDenonStatus and SetLoadLevelTarget.

I’m sorry for not being able to implement all of this right now. Currently very busy. But I’ll probably get back to this (and maybe implement a ZONE2) in April/May… if you want to wait! (no promises though)