We have moved at community.getvera.com

Author Topic: Vera (Luup) Control of Denon A/V receiver over serial/ethernet  (Read 199609 times)

Offline radarengineer

  • Moderator
  • Sr. Member
  • *****
  • Posts: 402
  • Karma: +4/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #45 on: September 16, 2011, 12:21:20 pm »
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
« Last Edit: September 16, 2011, 12:58:52 pm by radarengineer »

Offline zoot1612

  • Moderator
  • Hero Member
  • *****
  • Posts: 603
  • Karma: +21/-2
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #46 on: September 16, 2011, 09:52:26 pm »
@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  ;)

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

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #47 on: September 18, 2011, 03:14:51 pm »
A few comments:

  • Correct the <protocol> tag in D_DenonReceiver1.xml to "cr", instead of "cf"
  • Add declaration for SwitchPower1 to D_DenonReceiver1.xml
    You implement this, but needs to be added to the Declaration file as well.
  • 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.
  • in L_DenonReceiver1.xml, the vars buffer, sendCommand, http,  aren't used.
  • 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.

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

Offline radarengineer

  • Moderator
  • Sr. Member
  • *****
  • Posts: 402
  • Karma: +4/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #48 on: September 18, 2011, 04:22:42 pm »
@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!

Offline zoot1612

  • Moderator
  • Hero Member
  • *****
  • Posts: 603
  • Karma: +21/-2
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #49 on: September 18, 2011, 07:54:59 pm »
Code: [Select]
Correct the <protocol> tag in D_DenonReceiver1.xml to "cr", instead of "cf"
Why did it work at all ;)

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

Offline radarengineer

  • Moderator
  • Sr. Member
  • *****
  • Posts: 402
  • Karma: +4/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #50 on: September 18, 2011, 08:21:01 pm »
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?  ???


Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #51 on: September 18, 2011, 09:10:14 pm »
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 <startup> and call_timer/call_delay 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. setVolume after sendZoneCommand, then the latter can be made local (etc)
eg. sendZoneCommand after denon3800ReceiverSend, 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.

Code: [Select]
Correct the <protocol> tag in D_DenonReceiver1.xml to "cr", instead of "cf"
Why did it work at all ;)
« Last Edit: September 18, 2011, 09:11:54 pm by guessed »

Offline zoot1612

  • Moderator
  • Hero Member
  • *****
  • Posts: 603
  • Karma: +21/-2
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #52 on: September 18, 2011, 09:23:45 pm »
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.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #53 on: September 18, 2011, 09:35:18 pm »
So does that mean it does not need to be in the device file at all?

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)

Offline The-Source

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #54 on: December 04, 2011, 10:04:21 am »
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 ;) (not that i can do that, but i could learn ;) )
there are only 10 types of people in the world those who understand binary and those who don't ;)

Offline zoot1612

  • Moderator
  • Hero Member
  • *****
  • Posts: 603
  • Karma: +21/-2
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #55 on: December 06, 2011, 09:56:40 pm »
Can you tell me exactly what you want and if I get my sh*t together I might have a look.

Offline radarengineer

  • Moderator
  • Sr. Member
  • *****
  • Posts: 402
  • Karma: +4/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #56 on: December 07, 2011, 09:42:21 am »
@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.

Offline The-Source

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #57 on: December 07, 2011, 12:48:01 pm »
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 ;) ) 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 :P

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..
there are only 10 types of people in the world those who understand binary and those who don't ;)

Offline dfad1469

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #58 on: December 08, 2011, 01:22:19 am »
@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.

Offline The-Source

  • Jr. Member
  • **
  • Posts: 74
  • Karma: +0/-0
Re: Vera (Luup) Control of Denon A/V receiver over serial/ethernet
« Reply #59 on: December 08, 2011, 12:46:44 pm »
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?
there are only 10 types of people in the world those who understand binary and those who don't ;)