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

I am having computer issues at home as was unable to upload files to TRAC so I am attaching the latest iteration here. If someone can upload it that would be great.

This has only been tested via an IP link so not sure how it will go with a serial connection.

Please note this is a work in progress and still requires a lot of error trapping to be put in place etc.

To use with a IP link.

[ul][li]Upload all the attached files to your Vera[/li]
[li]Create device with the following information[/li][/ul]

      device_file    D_DenonReceiver1.xml
      impl_file        I_DenonReceiver1.xml
      IP                e.g. 192.168.0.96

[ul][li]restart[/li][/ul]

Notes: -
Tail light guarantee
Mileage may vary (sometimes start up fails but I have not found where the issue is yet, just try restarting.)
Any constructive criticism welcome :wink:

Cheers

John

Fixed my issue and have uploaded to TRAC, please feel free to fix :slight_smile:

Thanks John!

Just got a chance to sit down and load your new code. I haven’t played with it too much but you have clearly put a lot of work into this, really good stuff!

I am getting a Z4 child device created which is weird… do you see this too? It isn’t really a bug in your code, my Denon returns Z4 even though I have a 3808ci and it only have 3 zones.

I think it makes sense to build a lookup table instead of looping through all devices for “findZone”. I’ll make that pretty small change.

Is there anything else you can think off? I’ll try to go through myself. It might be nice to add a drop down to the front of the device with input, something like the drop downs on the Thermostat devices. I could probably add that pretty easily. I also might look into a new icon to replace the lightbulb?

The zones are created from what comes back from the AVR. For whatever reason there are four zones in the software so currently (because I am lazy) it just builds all the child devices based on the info feed back from the wget (@radarengineer Thanks for that)

A look up table would be great (cut down on overhead) and a new icon also.

Other things that I would like to do is have the inputs named in the UI as setup in AVR by user. There is a table created for this but because the UI relies on the static json file so I don’t know if this is possible. Also ZMON & ZMOFF have not been implemented as I am not sure how to add a second switch to the same device.

Other things you have mentioned in the past also like creating inputs based on model would be good but again had a quick look and couldn’t see an easy way of implementing this.

By the way did it parse the Model number and the zone names correctly?

John,

Made quite a bit of changes, hope you don’t mind! Just a few things I’ve picked up from other people here on the forum.

I moved the lua code into a seperate lua file that gets loaded from the implementation file, incorporated a couple of helper log function that @guessed recommended using, added a lookup table for child devices, and the moved some of the code that was run for any zone command into a common function.

I also changed some of the “if () then x=a else x=b end” to the Lua ternary function:

http://lua-users.org/wiki/TernaryOperator

Again, hope you don’t mind any of those. If you do lets talk about what to back out, and otherwise, I’ll be trying to figure out how to change the picture and maybe the zone labels in the json.

I wonder if it is possible to change the json to be a symbolic link to a file in /tmp/. That way we could generate a new json when we run receiver startup, and since it would be in /tmp/ it wouldn’t wear about the vera’s flash memory…

Thanks!

EDIT: Here is some really good info from @futzle on modifying icons: http://wiki.micasaverde.com/index.php/Luup_plugin_icons

@radarengineer
No really happy about any improvements and help as I am still learning, anyway if I didn’t want it improved I shouldn’t have shared it :wink:

Thanks for the links will be looking to improve my knowledge.

All the json stuff is still a bit of a mystery to me, I’ve been standing on the shoulders of giants (thanks to all the help I have had from the people on this forum) with generous amounts of cut and paste.

Thanks

A few comments:

[ul][li]Correct the tag in D_DenonReceiver1.xml to “cr”, instead of “cf”
[/li][li]Add declaration for SwitchPower1 to D_DenonReceiver1.xml
You implement this, but needs to be added to the Declaration file as well.
[/li][li]You can declare more stuff as “local” in L_DenonReceiver1.xml if you want
It may come down to personal preference, but I tend to declare most of my functions as “local” and narrow down the width of the interface exposed.
[/li][li]in L_DenonReceiver1.xml, the vars buffer, sendCommand, http, aren’t used.
[/li][li]in L_DenonReceiver1.xml, denonDevice is initialized (during declaration) to lul_device…
This assumes lul_device is “global” at the time the lib is invoked, which may be true, but is never documented to be so may vary from release to release of MiOS (like anything really)
You later initialize it during the startup method, which I think is safer and more common practice.
[/li][/ul]

btw, much cleaner in the separate L_DenonReceiver1.xml file. I think I’ll go split Onkyo code out similarly…

@guessed, as always, thank you for the recommendations!

I just made those changes and checked them into svn. I did find that any function called by incoming couldn’t be local. Vera would complain about a calling a nil function. But I made local all functions that didn’t return errors.

The other advantage to breaking out the Lua code is that the line numbers are correct when Vera complains!

Correct the <protocol> tag in D_DenonReceiver1.xml to "cr", instead of "cf"

Why did it work at all :wink:

@radarengineer
Is there anything else I can help out on?

Two good questions! I think @guessed told me before that the protocol in the I_DenonReceiver1.xml file takes precedent over the device file.

As far what to do next… I suppose it would be good if we looked at setting the surround processing mode? That shouldn’t be to hard, although I’m not sure how necessary it is. I’m hoping that with UI5 we have more space to put device options on the main page.

Do you have any ideas for needed features? ???

The mysteries of MiOS… 8)

There was a point where one of the MCV lads (@mcvflorin, I think) indicated that the Implementation version was effectively an override of the Device declaration version. A little validation in the MCV framework code would never go astray…

For the others, yes, I forgot to mention that anything directly called by the MiOS stuff needs to be “public” (or whatever non-Local is called). These are called directly by MiOS, so things like [tt][/tt] and [tt]call_timer[/tt]/[tt]call_delay[/tt] blocks are like that.

Everything else should be fine though, since their ACTION blocks/wrappers are code-gen’d into your namespace. They will need to be sequenced correctly based upon calls made within the L_ file (ie. declare before use)

eg. [tt]setVolume[/tt] after [tt]sendZoneCommand[/tt], then the latter can be made local (etc)
eg. [tt]sendZoneCommand[/tt] after [tt]denon3800ReceiverSend[/tt], etc, etc

It’s been a while though, so I could be wrong…

… oops, forgot that anything you actually intend to call within the L_xxx.xml file also needs to be public, but presumably that’s a narrow interface anyhow.

[quote=“zoot1612, post:50, topic:167791”]Correct the <protocol> tag in D_DenonReceiver1.xml to "cr", instead of "cf"

Why did it work at all ;)[/quote]

So does that mean it does not need to be in the device file at all?

No idea regarding needed features it was more for the learning part then anything for me.

When I get a chance will look at the surround implementation but I am with you on the necessity of it.

Maybe if someone else uses the plugin they can put forward some ideas.

Probably.

I just got into the habit of putting it in both, and making the same value. I’ve been bitten a few times by “bad” values [that I put in there] so that’s why I notice when the values are out of whack… For me, and likely for a few others, it’s been discovery (trial and error style)… eventually settling on patterns that work reliably… or at least appear to 8)

Well i also added the code to my Vera and my Denon 3808 is showing in me Vera webinterface.

I also can add it to a scene but i can only change the on/off state of it. Is this still under development or do i have to code lua for my wishes :wink: (not that i can do that, but i could learn :wink: )

Can you tell me exactly what you want and if I get my sh*t together I might have a look.

@The-Source, I was just messing around (I’m not sure about zoot1612) when writing this plugin and don’t use it much myself. That doesn’t mean I don’t want it to work, it is just that we basically hit a point where the basics worked and there wasn’t any requests, so we stopped.

You should be able to change more than just on/off. Do all the other controls (accessed when you click the wrench in the upper right hand corner of the device) work? I think with UI5 (coming out this week?) we should have a lot more control over the UI element for the receiver, and I think we can make some good improvements.

To second zoot1612, tell us what you are trying to do and we can see what we need to do to get you going.

When i click on the wrench i can select the different inputs so that work.
Here is my list of things i noticed…

1: The current volume setting of the zone 2 isn’t updated when i power-on then zone (my receiver only has 3 zones but 4 are showing (not that i really bother :wink: ) only after pressing the refresh button it changes :?
2: When using i a scene, you can only select on/off
I would like to be able to select input as well (and when possible a volume lvl)
3: There is no value visible of the current volume (all zones) like -38 using the slider could result is neighborhood harassment :stuck_out_tongue:

4: i dont know if this is plugin related, but i use homebuddy for control with my Android phone and the denon isn’t showing in the device list. But i must say, the W.O.L plugin (also from code.mios.com) isn’t also so i think that its a general plugin thing…

@The-Source

I was working real part time on this app. I have some answers to your questions:

  1. I am pretty sure that multiple zones aren’t supported. I had some mods to add this, but they were real buggy and the code got too stale for me to debug it. Is this a feature you would like?
  2. This should be pretty easy to add…I think.
  3. This is something that would be easier to wait and see how easy that would be in UI5. UI4 is a real pain to do stuff like that.
  4. Homebuddy only recognizes stuff that the author puts in. He is currently re-writing his source, so I don’t think he will add stuff. He also won’t open up his code base (I asked him) so you can’t add in either. Sorry, but this one is out.

Well i did a greater loop at the volume update/ zone thing but when i manually refresh the vera interface then its updated correctly. So i think that there is now auto-update/ auto-poll within the plugin so that vera knows the current value?