Closed cajuncoding closed 4 years ago
I've also been trying to debug my X4300H because the telnet interface is pretty unreliable. I took a tcpdump of some traffic between the Denon app and the receiver where I changed the source, power cycled, changed the volume, and muted/unmuted: x4300h.zip
Looks like the HTTP interface is still there, albeit without a UI and with a few syntactical changes. For example, it now uses port 8080, and certain commands like power on/off use a POST to AppCommand.xml with the command and zone encoded in the XML.
My python skills are pretty mediocre, but I can try out some changes later this week. In the meantime, let me know if you need any further network captures.
@arseneyr, that's great. I've been meaning to try to get a network capture done somehow, but my work hasn't provided any time in the past 6 months. I figured it was likely web based API's it was calling to be stable and responsive. How did you grab the captures?
I'll stay tuned to this, and if my work ever lets up a little I'll help iron out some of the python code too; though like you, Python isn't my strongest language.
is the publish control protocol not complete?
@Ltek That's the telnet interface the denon
component uses. In my experience, power on/off via the denon
component rarely works with the X4300H. I suppose I could spend time debugging it, but I would rather update denonavr
to support the HTTP interface variant that the native Denon app uses for the X4300H. The app has always worked without fail.
@raerae1616 I had to improvise the network capture by running tcpdump
directly on my Unifi access point. I'll probably look into setting up an HTTP proxy for future captures though.
I will have a look at this. If the old interface is still available on port 8080 it should not be too complicated.
If there is any need for testing I'm more than happy to help. My Denon AVR-X1400H has the same "feature" of not allowing the old RESTApi.
I attached some test I from the tcpdump data DenonAPI.zip
To turn it On and Off those Uri worked IP:8080/goform/formiPhoneAppPower.xml?1+PowerOn IP:8080/goform/formiPhoneAppPower.xml?1+PowerStandby
Mute On/Off IP:8080/goform/formiPhoneAppDirect.xml?MUON IP:8080/goform/formiPhoneAppDirect.xml?MUOFF
Consistent and reliable Power On/Standby, and Volume control and detection (for automations) is the biggest concern for me personally. Because the input selection and other elements can be well controlled via my Harmony Hub.
But this looks REALLY PROMISING, now that we know a working endpoint per @f-bader post above and the TcmDump from @arseneyr! This is super useful info. now that I've had time to dig in a little over the holidays.
IA quick google and I found this other spec. info. on the Denon AVR Protocol spec sheet that is working well with the spec sheet (it's the same as that posted above by @Ltek, but I found this copy first and it's a little easier to read (likely because it's older): http://openrb.com/wp-content/uploads/2012/02/AVR3312CI_AVR3312_PROTOCOL_V7.6.0.pdf
The following commands worked successfully on my AVR-X4300H, and resulted in fast updates to the Mobil App when I send the commands via Postman (e.g. the HEOS app gets the events raised by changing the values on the REST endpoint (Note: of these are using the same simple REST endpoint and the command spec above):
BUT, the following does NOT work as expected to query the current values:
But this is promising . . . even for simple REST buttons in HomeAssistant. I'm not sure why the RESPONSE's are not returned for the above command queries, the Http response code is 200 OK, but no content in the response. I'll keep fiddling with that.
I also found that the AVR-X4300H supports the (very robust) HEOS protocol documented here, and useable via SSDP and RESTFul calls, but not much info. on how to call the commands, but its seems to be a flavor of JSONRPC. I have not tested this out because the SSDP process is more involved than simple REST endpoint.
So, it appears like the RESTFul capabilities are all actually here, but perhaps the actual mechanisms have changed slightly from the older Denon models. Per my post above the RESTFul GET querystring requests for Status did NOT work for me, and this was also confirmed this person in German (Google Translated to English): http://blue-pc.net/2013/12/28/denon-av-reciever-ueber-http-steuern/
He provided lots of great information that was also confirmed in the TCP dump from @arseneyr above!
So the following WILL Work and I validated them on my Denon AVR-X4300H via Postman:
GET requests to get Device Info does work but the Url is case sensitive (woohoo): http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/Deviceinfo.xml
And retrieving status of Volume, Zone power, etc. can all be done with an Xml POST of valid xml commands as follows: POST requeste to: http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/AppCommand.xml BODY =
<?xml version="1.0" encoding="utf-8"?>
<tx>
<cmd id="1">GetZoneName</cmd>
<cmd id="1">GetAllZonePowerStatus</cmd>
<cmd id="1">GetAllZoneSource</cmd>
<cmd id="1">GetAllZoneVolume</cmd>
<cmd id="1">GetAllZoneMuteStatus</cmd>
</tx>
And Response will be something like this (containing pertinent information retrieved):
<?xml version="1.0" encoding="utf-8" ?>
<rx>
<cmd>
<zone1>Theater </zone1>
<zone2>Headphones</zone2>
<zone3>ZONE3 </zone3>
</cmd>
<cmd>
<zone1>ON</zone1>
<zone2>ON</zone2>
<zone3>OFF</zone3>
</cmd>
<cmd>
<zone1>
<source>MPLAY</source>
</zone1>
<zone2>
<source>SOURCE</source>
</zone2>
<zone3>
<source>SOURCE</source>
</zone3>
</cmd>
<cmd>
<zone1>
<volume>-40.0</volume>
<state>variable</state>
<limit>OFF</limit>
<disptype>ABSOLUTE</disptype>
<dispvalue>40.0</dispvalue>
</zone1>
<zone2>
<volume>-67</volume>
<state>variable</state>
<limit>0.0</limit>
<disptype>ABSOLUTE</disptype>
<dispvalue> 13</dispvalue>
</zone2>
<zone3>
<volume>-40</volume>
<state>variable</state>
<limit>-10.0</limit>
<disptype>ABSOLUTE</disptype>
<dispvalue> 40</dispvalue>
</zone3>
</cmd>
<cmd>
<zone1>off</zone1>
<zone2>off</zone2>
<zone3>off</zone3>
</cmd>
</rx>
There are other commands that are valid, but I simply tried out the primary ones to retrieve critical Media Player values such as (Power status, source input, Volume, etc.).
Postman Screenshots:
So, I don't know how HomeAssistant components work yet (don't have time to learn that with my current workload) . . . so I'm not able to jump into trying to fix the DenonAVR component itself. But, for now I was able to get my Denon AVR-X4300H working with spectacular responsiveness for On/Off control, input control, and finally direct Volume Control -- I always hoped it would/could work this well!
The beset thing so far has been the amazing integration with a Lutron Caseta Pico remote using REST Commands for the Denon, and Python_Script for logic, and the custom SmartBridge Pro hub component with details outlined here!
Hey well done raerae1616, I have a Marantz SR7012 which seems to work the same as your AVR (your commands above also work). Hoping someone finds the time to update the component in HA, or create a new one if need be :)
Would be really nice to have these models working on HA as well, as my AVR-X1400H does not work well in HA now. Hope that someone will be able to add compatibility for these newer models! Tested above commands, and work as well on my receiver!
Can confirm this also works for my AVR-X2400H. 👍
Would be really cool if someone could get this into the denonavr
component, as this seems the new method of choice for al these new Denons. 🙏
Haven't got the Python skills to fix this myself.
Man I wish I had the time, I'd love to either a) create a new custom component or b) try to merge into the existing denonavr component . . . if anything it'd be a chance to improve my limited python skills. For me, I don't fully understand how components in Home Assistant are designed to work and are intended to be designed/deployed, etc.... I have a lot to learn there.
I'm just sooo swamped with the day job pulling 15 hour coding for clients on top of other stuff, not sure when I'd have the chance...
@bartberden: Per your message, just in case you didn't see my link above, I've posted some samples of how to get the reciever working well with the use of REST Commands! I even sorted out passing volume as a parameter, and integrating with Python Scripts... so honestly I'm not even missing much from the denonavr component anymore; sure it's a little more automation work, but it does work very well and stable now. Even in the UI, the Volume, etc. can be easily solved with an input_slider, input_boolean, etc. and some automations with parameters, or Python Script, etc.
Check out my post here to get you started, I hope it helps: https://community.home-assistant.io/t/fixed-delay-between-hass-services-call-s-in-a-python-script/21121/8?u=raerae1616
hey guys, it took a while, but now I pushed some changes which hopefully make the supporting parts of the new AVR-X devices. I did not create a new version yet, because it is hard for me to test. Thus please include the lib manually to HA and tell me if it's working. Currently you probably won't be able to see any media information like the name of the song you playing because I could not find them in the AppCommand.xml interface.
@scarface-4711 Hi. I tried testing the changes, but the library still seems to use the old URLs (or do I somehow need specify the receiver type in the constructor?). This is the console output from python:
>>> import denonavr
>>> d = denonavr.DenonAVR("192.168.178.63")
Host 192.168.178.63 returned HTTP status code 403 when trying to receive data
Connection error: Receiver sources list empty. Please check if device is powered on.
Host 192.168.178.63 returned HTTP status code 403 when trying to receive data
Receiver name could not be determined. Using standard name: Denon AVR.
Host 192.168.178.63 returned HTTP status code 403 when trying to send POST commands
Host 192.168.178.63 returned malformed XML for: /goform/AppCommand.xml
Both are used because the pre 2016 receivers are working better with the other ones. The right URLs should be determined automatically in method __get_receiversources I did not know that the new receivers send a real 403 status at port 80, please try again.
The URLs are more or less the same, the major difference is that the post 2016 devices are listening to port 8080 instead of 80 and that some interfaces are disabled.
Thank you for the explanations. That's good to know. I can confirm that the new version works with an X-1400H on the command line. I suppose the first error message is still excepted. Not sure about the receiver name, I have something else set up as "Friendly name" in the "Network" settings, but I'm not sure if that is supposed to be the same thing.
I'm going to try it in HomeAssistant later tonight if I get to it.
For reference, this is the output of my tests:
>>> import denonavr
>>> d = denonavr.DenonAVR("192.168.178.63")
Host 192.168.178.63 returned HTTP status code 403 when trying to receive data
Receiver name could not be determined. Using standard name: Denon AVR.
>>> d.power_on()
True
>>> d.volume_up()
True
>>> d.volume_up()
True
>>> d.volume_down()
True
>>> d.name
'Denon AVR'
>>> d.mute(True)
True
>>> d.mute(False)
True
>>> d.input_func_list
['AUX', 'Bluetooth', 'CBL/SAT', 'Game', 'HEOS Music', 'Media Player', 'NES', 'Tuner']
>>> d.input_func = 'Media Player'
>>> d.power_off()
True
I tried the latest master branch in Home Assistant and I'm happy to report that power on/off, mute/unmute, volume up/down, setting source all work with my X-1400H. Great work, thank you.
I'm glad to here that. There is no FriendlyName in the interface for the new AVR-X, at least I did not find it. I used the zone name instead now. You should not get the first 403 error message anymore. And I did some cleanup stuff...if I did not mess up things, it should still work and I will create a new version for HA soon.
The new version works as expected for me and the error messages are also gone. Thank you.
Looks promising! I wanted to try it out, but currently have no clue how to test this in home assistant. Could someone tell me how to import this into homeassistant?
Thanks in advance!
The easiest way would be to wait for HA 0.64 which should be released soon. Other options depend on how you installed HA. Some ideas:
REQUIREMENTS = ['denonavr==0.5.5']
to REQUIREMENTS = ['denonavr==0.6.0']
. Restart homeassistant.Well, just a heads up that with the new version, it doesn't seem to work with a Marantz 6012. I get:
Host 192.168.1.98 returned HTTP status code 403 to GET request at end point /goform/formMainZone_MainZoneXmlStatus.xml
I'm having trouble following...
I have a Denon AVRX4300H (maybe I'm in the wrong thread?). I'm wanting to control it with siri/homekit. Is there a simple command and string to add to config.json?
something like: npm install -g homebridge (i've setup my wink hub2 with this kind of setup).
thanks in advance!
@mreassassin you won't be able to use this library to connect a Denon receiver to Homekit. It is primarly built to integrate those receivers to Homeassistant. Afaik there is an integration from homeassistant to homekit. You'll find it on the page.
Instead of getting the power on status using POST request method, you could also use GET with the following url (for Zone 1/Main Zone): http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/formMainZone_MainZoneXmlStatusLite.xml
Zone2:
http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/formZone2_Zone2XmlStatusLite.xml
@naartem: Great Feedback, thanks for the simplified GET request.
I can confirm that both of the links provided work for the AVR-X4300H. It reports the official name of the input, and not the Friendly name, but this is great.
Now, If ONLY the HomeAssistant RESTSensor supported something other than JSON (I hate it when developers ignore Xml as a valid REST protocol)... siiiiigh.
Zone 1/Main Zone: http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/formMainZone_MainZoneXmlStatusLite.xml
Zone2:
http://{{DENON_AVR_IP_ADDRESS}}:8080/goform/formZone2_Zone2XmlStatusLite.xml
@naartem URL is already used for the pre 2016 AVR-X receivers. Thus, it sounds like the interface did not change at all except from being moved from port 80 to port 8080. Did anyone try just changing ports in the library and see if it works?
Just go to line 27 of https://github.com/scarface-4711/denonavr/blob/master/denonavr/denonavr.py and change
AVR_X = ReceiverType(type="avr-x", port=80)
to
AVR_X = ReceiverType(type="avr-x", port=8080)
Where's that stored in Hass.io scarface-4711 (that file I mean)?
Can't find it but I think that'll work. Trying it in a browser works anyway (80 just gives the same error as above (a 403), 8080 seems the go for the new Marantz.
Never used hass.io, thus I don‘t know where to find the library there. If someone is able to test it, I could switch back to the same way the pre 2016 work, but on port 8080. This would bring back information about the current song, artist and other media information.
Why don't we just unit test the REST url that the old code used, to see if the method works on the newer models? Just like we have with several REST Api's above....
I don't have the time to read over the original Python code and find the Url, but if someone wasn't to find the base REST url used to retrieve that data, I"m happy to test it out a little on my AVR-X4300H...
@simonk83 you could also run the python script you find in the following repository and upload the .xml files it saves in its directory here. Those are the responses of your receiver. I'll be able to test it here then.
https://github.com/scarface-4711/misc_python_tools/tree/master/denonavr
Here you go. 403 for everything aside from:
AVR-AppCommand-8080-200.xml
AVR-Deviceinfo.xml-8080-200.xml
@simonk83 yes most of the endpoints are not available at your receiver. Thus, it makes no sense for me to change anything here because of this. @raerae1616 it seems that there are more endpoints available at your receiver. If you can run the script and upload the results, I would be able to find out more.
@scarface-4711: I tried many endpoints that I was able to find and listed the results of my investigation above int his thread.
Also, I have run that script for you before also, but am happy to run it again. Have you changed it to use port 8080, and/or added other ednpoints to test?
I'll try to run it again in the next several days.
Yes, it is querying each endpoint which is in use here on both ports, 80 and 8080.
Also got problems with a new model from Denon, using the X3400H. As you see in the screenshot the sound mode isnt set yet, is there anyway I can fix the bug? Thank you.
@scarface-4711 What's the latest update with support for the X4300h? Is there anything further we can do to help test things?
@simonk83 I just submitted PR #65 that brings detection of the SR6012 as a avr-x-2016 receiver. You'll still get 403 errors as sound mode doesn't work, but everything else does.
@andrewsayre, nice thanks 👍🏻
Are there any updates on this? @scarface-4711 @raerae1616 I am eyeing the new Denon AVR-X2500H but Home Assistant integration is a must have :)
My X6300H is working fine with Home Assistant. Starting with HASS 0.92 you'll also get HEOS support :)
@wilmardo my Denon AVR-X1400H does work fine HA 0.91.3. Did not yet try Heos in 0.92
@wilmardo to be honest my Denon has been rock solid with REST commands and python scripts (after sorting out the key rest api calls I needed; outlines in my investigations above)...so I haven’t switched back to the component since...
More info here: https://community.home-assistant.io/t/fixed-delay-between-hass-services-call-s-in-a-python-script/21121/8?u=raerae1616
But I’m always monitoring the updates and it does seem like most of the needed apis and component updates have all been made...
It’s Great that others like @klada and @f-bader were able to confirm above!
I have the SR7011 working with the denonavr component. I had to change this line in the denonavr.py file found in /srv/homeassistant/lib/python3.5/site-packages/denonavr:
DEVICEINFO_AVR_X_PATTERN = re.compile( r"(.AVR-X.|.SR500[6-9]|.SR60(07|08|09|10|11|12|13)|.*NR1604)
I changed SR60 to SR70 and everything works. The SR7011 is then using port 8080 instead of 80. The only problem I have right now is that my main home assistant device is using docker. And I cannot find the denonavr.py file in the docker system.
@scarface-4711 could you please add the 7011 to the denonavr component using port 8080
To add to the mess Denon is making: I just bought a Denon X3500h.
full web interface is now on ### port 10080
The cute thing is, this isn't referenced in the manual at all. Did a portscan to find it...
For some reason my Harmony Hub will randomly not turn off my receiver (even with a hardwired IR wire connected to the receiver; uggg)... so I've moved back to using the component with a nifty automation to validate the Receiver is always off when the Harmony status switches to "PowerOFF" . . .
Sorry to revive this ancient issue. Just tried to set up a script in Home-Assistant for my X4500H using denonavr.get_command service. Did get Logger: DenonAVR Source: deps/lib/python3.8/site-packages/denonavr/denonavr.py:438
& No connection to /goform/AppCommand.xml end point on host 192.168.178.xx
in the logs.
I do assume denonavr checks on the wrong port since the xml IS accessible on port 8080.
EDIT: HA is 0.108.2
@iophobia could you please run this python script and upload the XML files it is generating in its directory? I'll have a look into that then.
I have a newer Denon AVR-X4300H model. Apparently the new models no longer support the web interface supported by older models (uggggg--- why remove the web or RESTFul interface). But the mobile app for the reciever works fantastically so there is definitely a stable mechanism to connect to these.
The original "denon" component does kinda sorta work -- via telnet access. But it's very unreliable. For example the volume change will work about 1 out of 5 times. The pattern I've seen is that once you set it via HomeAssistant it won't respond again for some timeout period . . . which is minutes. This miraculously it might respond and work at some later time.
So, I would MUCH rather get the denonavr component working well, so that it could be as stable as the mobile app is when changing volume, inputs, etc.! This is really a bummer because the Onkyo reciever this one replaced was very very stable and worked very well with HomeAssistant.
At this time I've fallen back to basic on/off automation using my Harmony remote integration with HomeAssistant and it's working well. But, is very very limited. Being able to set the volume and sources with HomeAssistant is a fantastic automation that I'm very much missing.
We were previously corresponding on this thread: https://github.com/home-assistant/home-assistant/issues/7645
But, per the recommendation over there I wanted ot open a ticket here and offer my help in testing /debugging however I can to get the latest series of AVR's working!
I've attached the results of the python test script you posed on the other thread here as well to provide the Xml files that it saved out: Denon Python Requests - AVR-X4300H.zip
Unfortunately I don't think the web interface that is used by the denonavr platform is available on the higher end newer (2016+) models anymore.
On my AVR-X4300H, the urls you posted all return:
This is also documented on AVS Forums: http://www.avsforum.com/forum/90-receivers-amps-processors/2444306-official-2016-denon-s-series-x-series-avr-owner-s-thread-faq.html
Please let me know what else I can do to help. I'll try to pay more attention and be more prompt than I was before on that last thread!