Vera (Luup) Control of Denon A/V receiver over serial/ethernet

Thx again. Updated it, see attached.

[quote=“zoot1612, post:111, topic:167791”]By the way if you want a device to appear in the “AV Gear” tab in UI5

luup.attr_set("category_num","15",k)

cheers

Zoot[/quote]
Thank you! This was bugging me and I was about to post a question.
One thing to note for newbies, replace “k” with the device number (Wrench → Settings tab → Device #).

Do you think it would be worthwhile to have a script that generated a JSON from the labels stored on the receiver?

I could throw together a quick perl script (or Java, etc?) program for that. You would have to run it on a host computer while the Vera was not connected to the Denon.

Why not rewriting the static json file from within the Luup plugin?

When i do

local inputDenon = luup.variable_get("urn:micasaverde-com:serviceId:InputSelection1", 16)

The code doesn’t accept “Input” before the ,16 which in my logic would be needed ???

The test luup code accepts the command but when i want to check inputDenon in a if statement is cant get a working value. When testing my receiver is on the Tuner/ Input5 but checking on those names dont give me a good equation.
I hope its even possible to receive the current input, i think it is because in the the startup code its all being received.

@The-Source,
The variable they’re setting is [tt]Input[/tt] and it lives in the ServiceId [tt]urn:micasaverde-com:serviceId:InputSelection1[/tt].

You could retrieve this value using:

local inputDenon = luup.variable_get("urn:micasaverde-com:serviceId:InputSelection1", "Input", 16)

you mentioned that you tried that but the code “doesn’t accept … before the ,16…”. You may need to clarify what you mean by that, and what you observed when you tried this.

For reference you can see it being set on this callback in their code:
L_DenonReceiver1.lua in trunk – Denon Receiver Control Plugin

@zoot1612, @radarengineer,
By convention, you probably should avoid having your plugin set StateVariables back against a ServiceId you don’t own (like the AV ones here). Consider using a custom ServiceId to contain the Denon-specific stateVariables, to avoid any stateVariable naming, or general upgrade, conflicts in future releases…

Well shoot me then, because after copying your line it does work ???
I already noticed that Lua is case sensitive ( Starting with If doesn’t must be if :wink: )

I think is didn’t had the space after the , but i dont know for sure.
For the people interested in what i do with it… (the code is checked every 2 minutes with a scene timer)

local statusDenon = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 16)
local inputDenon = luup.variable_get("urn:micasaverde-com:serviceId:InputSelection1", "Input", 16)

if (statusDenon == "0") then
  luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1","Watts",5,16)
else
  if inputDenon == "TUNER" then
    luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1","Watts",112,16)
  end
  if inputDenon == "HDP" then
    luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1","Watts",280,16)
  end
  if inputDenon == "TV/CBL" then
    luup.variable_set("urn:micasaverde-com:serviceId:EnergyMetering1","Watts",285,16)
  end
end

The standby usage is a guess but I will hook up a meter when i have time. Why the HDP & TV/CBL have a higher wattage is because i know my tv is also turned on then and i took that wattage also in consideration :wink:

@The-Source, thanks for sharing your scene code, always nice to see what people are doing with the Vera.

Denon claims 0.3w in standby, a user in avsforum reported 1.8w. The thought there was that Denon was reporting power without an active network link. I’ve been meaning to hook up my kill-a-watt to the Denon again but like you haven’t had the time. Would be interested in your number if you do get a chance.

@guessed, thanks for keeping us honest with the ServiceIds. Once my life outside vera clears up a bit I will try do that and other housekeeping on this code.

@radarengineer
And I still haven’t uploaded my changes as I am still not sure if this is a better way to go. Have you had a look at the code?

[url=http://forum.micasaverde.com/index.php/topic,5863.msg59628.html#msg59628]http://forum.micasaverde.com/index.php/topic,5863.msg59628.html#msg59628[/url]

2 Days ago i upgraded from UI4 to UI5 and the denon plugin of UI4 did offcourse not work. And i deleted device with id 16 (the id of UI4) but after installing the new plugin from the apps section i did get the main zone working. But the ‘child zones’ arent visible. The new device id is 41 so its really the new plugin and control of the main zone works fine.

(my previous wattage registration also works again, so its only the child zone)

@The-Source
Try the plugin here: -
[url=http://forum.micasaverde.com/index.php/topic,5863.msg59628.html#msg59628]http://forum.micasaverde.com/index.php/topic,5863.msg59628.html#msg59628[/url]

It is substantially different so if you don’t like it re-install from app store

The reason the child devices are not been created is that the routine for forcing the receiver to send zones via Telnet is not behaving the same as it does in UI4 so it is down to a timing issue. The disconnect between sending a http request and receiving data on telnet made it difficult to resolve so I threw the whole lot out and went back to creating zones based on model.

Besides actually working this has the benefit of also theoretically working for serial connected receivers.

@zoot1612, I think we should probably go ahead and update the plugin to your code. I don’t have any better ideas!

@Ap15e

Why not rewriting the static json file from within the Luup plugin?

Are there any of code examples of this floating around the forum or in a plugin?

[tt]http://forum.micasaverde.com/index.php/topic,5709.0.html[/tt] - a Luup plugin that creates a static json file. After writing your static json file to the filesystem, you would have to invoke the UPnP action [tt]Reload[/tt].

BTW, you could use multiline quotes ([tt]http://lua-users.org/wiki/StringsTutorial[/tt]) to make the parts of your source code that would write the static jason file more readable/maintainable.

@zoot1612, I just uploaded a new version of this plugin to the trunk.

I used a call to luup.call_delay (with a 10 second delay) to fix the timing issue. Unfortanetly, I need to go back and tweak it a bit to make it work right with serially attached receivers.

I also made some major changes to the function to handle incoming data. I hope you don’t mind; I think it is a little easier to read / modify but I know that is probably up for debate!

EDIT: I also added a ‘test.lua’ file in the repository that can be used to test some of the functionality of the plugin by running it with a lua installation on a PC.

@radarengineer

You won’t get any flack from me regarding code changes, I’m a newbie at this stuff.

Regarding serial connection it is not the timing so much it is the fact that your require a http session to push out the variables on the serial/ethernet connection. So it will not work for serial only connected receivers unless someone finds the code for getting the zone info out of the receiver.

@zoot1612, I need to go back and add a fall back for serially connected receivers.

Also, I am thinking it might be a good idea to split off zone 1 into a separate device. I still need to play around a bit with that, but when I turn off zone 1 I get a ‘ZMOFF’ instead of a ‘MUOFF’. I could add ‘ZMON/ZMOFF’ as aliases of ‘MUON/MUOFF’, but how the Denon really seems to work is that MUON is on if any of the zones are on (Z1-Z3) and then MUOFF turns off all zones. To really get this behavior right I think you need to have an extra device.

This would be nice for things such as a ‘goodnight scene’ where you would want to turn off everything but you don’t care what zone are on.

Any thoughts on that change?

yes, that was one of the shortcomings of my original implementation. But I was lazy and couldn’t decide how to tackle it.

This sounds like a good solution just create a binary switch for main zone and zone 1 only responds to ZM not MU.

I finally finished writing a telnet proxy program to use with the Denon. This lets you connect multiple clients to a receiver at once.

I wanted to be able to use the Vera plugin, Command3808, Eventghost’s Denon plugin, and an Android Denon utility at the same time. I used Python Twisted and I’ve only tested it under Windows, but I plan on daemonizing it and sticking it on a Pogoplug.

Is anyone else interested? If so I’ll try to clean it up a bit to share.

If I understand correctly a pc must run continuous to let the proxy work?
I did use the AVR-remote app for android alot but since my vera was hooked to my Denon it didn’t work anymore.
I think im going to give it a try next weekend.