Tester(s) wanted: new denonavr component

Hi there,

I’m currently developing a custom component for my Denon reciever. The current one (denon) has limited support for Denon AVR’s. This component doesn’t use the telnet interface, it uses the XML endpoints from the web UI.

Feautures supported:

  • Input & Input select
  • play/pause/next/prev
  • album art (where possible)
  • on/off
  • volume set/up/down/mute
    Volume has a hard coded limit of 50 ( 50 - 80 = -30 dB) because the full 100% percent is loud. I mean, loud to pop your ears out. I would like to hear your thoughts on this limit.

You can find the component here: https://gist.github.com/subutux/59f9d4f5fd8196c849a892a56ba90baf
The python class i’ve written for this can be found here https://github.com/subutux/denonavr , and is currently in the last development stage. There are some smal things to do, mostly error handling where possible.

So my question is, who has a Denon AVR & is intrested in testing this? I currently have this running at home, with some minor hiccups.

Hi, in the past I’ve done some work on creating a component of my own. Unfortunately due to some unforeseen changes in my personal life I haven’t gotten to fixing/upgrading it to the latest standards.

I’m using a Marantz AVR (SR6008) myself, but seeing as how that’s a Denon subsidiary your component might work as well. I’ll give it a go and update you on any findings.

Hi, I have Denon AVR-X2200W, I will give it a try and let you know about my observations :slight_smile:

I’ve installed component without any problems. For now I have tested changing volume, which happens to work much better then on current Denon component included in HASS. I had some trouble with source changes though, I can normally change source to anything but “Media Player” and “Blu-ray”, every other source is working, but I have zero success when selecting one of those two.

I will enable debug log and check if anything gets in there, for now I have error log only and there is nothing in it.

Nothing useful in logs even in debug mode, that is all I can see, and it is same as for the working sources:

16-11-08 21:48:17 homeassistant.components.http: Serving /api/services/media_player/select_source to xxx.xxx.xxx.xxx (auth: True)
16-11-08 21:48:17 homeassistant.core: Bus:Handling <Event call_service[L]: service_data=source=Media Player, entity_id=media_player.denon_avrx2200w, domain=media_player, service=select_source, service_call_id=1976369040-1>
16-11-08 21:48:19 homeassistant.core: Bus:Handling <Event service_executed[L]: service_call_id=1976369040-1>

Yeah, I’m a lousy Developer who forgets about logging completely.

My first thought is that the source is set to the new one, an update is executed, but the new source isn’t set yet on the Denon. I’ll take a look at it tomorrow. (It’s 22:30 here)
& include some logging.

But thanks for finding this bug!

yes, they use the same XML end points. Thank you!

Just installed your component, and at first glance it seems to be working. Will test some more in the next few days and get back with any findings.

As for the volume limit: on one hand it’s nice that you put it in, but maybe you can make the min and max volume (optional) configuration parameters? Then you can convert the given min/max scale to the home-assistant scale so all sliders would work as expected.

Looking at the code, apart from the logging mentioned earlier I would put some effort into making the code PEP8 compliant, that will save you some headaches when submit a PR to get the component into Home Assistant. :slight_smile:

I’ve created a fork of your Gist (maybe you could create a repo instead so people can submit Pull Requests on your code?), and fixed all the PEP8 style errors, have a look here

1 Like

Nice one! I’m thinking about putting this component into my denon module repo.

Hi!

Interested in this improved behavior but don’t have any network access to my denon receiver to help you test it right now. :frowning:

Is this perhaps similar to this commit? https://github.com/home-assistant/home-assistant/pull/4260/commits/664ae83927aca390d078ef882fef952238911be4

Best regards

/R

So I’ve updated my code.

  • The home assistant component is now located in here: https://github.com/subutux/denonavr/tree/master/extras/home-assistant
    I’ve put it as an extra with the main denonavr module.
  • Logging! The module now uses logging. If you run into troubles, please enable logging for it in your configuration.yaml
  • The input select should work & doens’t flap back to the previous one (I’ve tested this, but not visual. I’m not home right now, but the input stays set in the returned xml)

To enable debug logging, add this to your configuration.yaml

logger:
  default: info
  logs:
    denonavr.denon: debug

Please note: because there is a newer version of the denonavr module, you’ll need to manually remove de module from the deps folder of home assistant. You can do it by executing rm -r [your-hass-config-folder]/deps/denonavr*

Heh, yeah. Someone beat me to it apparently :slight_smile: I’ll look into the commit.

Hi,

I have installed new version, problem with input select remains for me, when I choose “Media Player”, source in Homeassistant now stays on Media Player, but source on receiver does not change. I turned on debug log, this is what is logged on input change:

16-11-09 18:01:27 denonavr.denon: Sending GET with data: {'cmd1': 'aspMainZone_WebUpdateStatus/', 'cmd0': 'PutZone_InputFunction/Media Player'}
16-11-09 18:01:28 denonavr.denon: status: 200 response: 
, url: http://192.168.0.187/MainZone/index.put.asp?cmd1=aspMainZone_WebUpdateStatus%2F&cmd0=PutZone_InputFunction%2FMedia+Player
16-11-09 18:01:28 denonavr.denon: GET http://192.168.0.187/goform/formMainZone_MainZoneXml.xml?ZoneName=MAIN+ZONE
16-11-09 18:01:28 denonavr.denon: FriendlyName = Denon AVR-X2200W
16-11-09 18:01:28 denonavr.denon: Power = ON
16-11-09 18:01:28 denonavr.denon: ZonePower = ON
16-11-09 18:01:28 denonavr.denon: RenameZone = MAIN ZONE

Additional observation: might be something in connection with source having space or - in it’s name, / does not seem to be problem, not working sources: “Blu-Ray”, “TV Audio”, “Media Player” and “Online Music”

I’ve found the problem.
These inputs need a short name for commands.
For example: Blu-Ray = BD, TV Audio = TV, Media Player = MPLAYER and Online Music = NETHOME. I think I’ve got 'm all, but not sure if the AUX1&AUX2 are returned in the /goform/formMainZone_MainZoneXmlStatus.xml request to a AVR-X2xxx. Could you please pm me the output of the xml file? You can do this in the browser or using cli:
curl http://[YOUR-DENON-IP]/goform/formMainZone_MainZoneXmlStatus.xml

Thank you for your help with this! I love this community! :smiley:

PS:If you’re wondering why I don’t hardcode the inputs, it’s because you can disable some inputs from your Denon AVR. Those that are disabled won’t shopw up in your input select. For example, on my Denon, I’ve disabled the “Tuner” input. Don’t need it because I use the online radio. (And don’t have an antenna connected).

Great job! Its working now, I can confirm that Blu-Ray, TV Audio and Media Player are working, the online one not working for me is Online Music. AUX1 and AUX2 were working already. I will send you the output of /goform/formMainZone_MainZoneXmlStatus.xml in a minute.

Thanks for great work!

I just stumbled on this as I was researching how to control my Denon volume using Alexa. Is there a way to raise and lower the volume by increments? For example if the volume is at 30 and it would step up by 5? Would I have to create a template switch and automation?

I have an AVR-X2000 and willing to help in any way possible. The primary functions work great so far, and displaying the custom input labels is a nice touch. Any chance of having separate volume, input and power selectors for Zone 2? If I’m understanding the class correctly, it looks like it’s hardcoded for Zone 1 at the moment.

I just started testing this component with my AVR-X1100W, and so far its working pretty well. I did have to make one modification because I was getting this error on the Bluetooth input:

Traceback (most recent call last):
  File "C:\Python34\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "C:\Python34\lib\site-packages\homeassistant\helpers\entity_component.py", line 335, in _async_process_entity
    new_entity, self, update_before_add=update_before_add
  File "C:\Python34\lib\site-packages\homeassistant\helpers\entity_component.py", line 204, in async_add_entity
    yield from entity.async_update_ha_state()
  File "C:\Python34\lib\site-packages\homeassistant\helpers\entity.py", line 224, in async_update_ha_state
    attr = self.state_attributes or {}
  File "C:\Python34\lib\site-packages\homeassistant\components\media_player\__init__.py", line 681, in state_attributes
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "C:\Python34\lib\site-packages\homeassistant\components\media_player\__init__.py", line 681, in <dictcomp>
    in ATTR_TO_PROPERTY if getattr(self, attr) is not None
  File "C:\Users\brg46_000\AppData\Roaming\.homeassistant\custom_components\media_player\denonavr.py", line 135, in media_title
    return self.denon.nowPlaying["ARTIST"] + ": " + self.denon.nowPlaying["SONG"]
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

This was how I fixed it:

@property
def media_title(self):
	if self.denon.input == "Bluetooth":
		return self.denon.nowPlaying["INPUT"]
	elif self.denon.nowPlaying["SONG"] == None:
		return self.denon.nowPlaying["INPUT"]
	else:
		return self.denon.nowPlaying["ARTIST"] + ": " + self.denon.nowPlaying["SONG"]

Hope this helps

I just installed your component. I’m trying it on a Denon AVR-2113, connected via LAN cable.

Turning on/off works as well as switching most sources, except for FM (Tuner), CBL/SAT, NETWORK, AUX. Also, setting the volume doesn’t work. I’ll investigate further.

@subutux What i see is, it is only working with the pre configured sources

self._source_list = {'TV': 'SITV', 'Tuner': 'SITUNER',
                             'Internet Radio': 'SIIRP', 'Favorites': 'SIFVP'}

Would be great if we could add our own source config like we add the name and host. So that only if nothing is added the pre configured source list shows up, else our list.

It looks like you only use the name and host from config

__init__(self, name, host):