LogicMachine Forum
Denon AVR X2300W control via API - Printable Version

+- LogicMachine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Denon AVR X2300W control via API (/showthread.php?tid=2694)



Denon AVR X2300W control via API - MantasJ - 22.06.2020

Hello everyone,

Maybe someone here have succesfully integrated Denon AVR X2300W with logicmachine? I mean, there are couple of scripts out here in forum and one in the openrb website, but those scripts differ and there is no clear indication whether they work or not. I will have to integrate such functionality:

  • ON
  • OFF
  • VOLUME ON
  • VOLUME OFF
  • VOLUME SET
  • MUTE ON
  • MUTE OFF
  • SOURCE INPUT SELECTION
As I do not have the AVR at the moment I just can prepare the script for it and only then test it, but I will have not a lot of time. So, maybe someone who has succesfully integrated such AVR could share some code examples?

Thanks in advance!


RE: Denon AVR X2300W control via API - admin - 22.06.2020

Looks like newer models can be controlled via HTTP like this:
http://DENON_IP:8080/goform/formiPhoneAppDirect.xml?PWON
I'm not sure if status response can be received this way, you might need to use Telnet instead of HTTP.


RE: Denon AVR X2300W control via API - benanderson_475 - 22.06.2020

(22.06.2020, 10:57)admin Wrote: Looks like newer models can be controlled via HTTP like this:
http://DENON_IP:8080/goform/formiPhoneAppDirect.xml?PWON
I'm not sure if status response can be received this way, you might need to use Telnet instead of HTTP.
I got the post commands working as admin said above,
This also might help I did get feedback with this script, using xpat to parse XML I got it working but never completed it properly,
Even with it running in an resident script with 1 sec delay the feedback was to slow for me, the impatient so I ended up using telnet 
Code:
local http = require("socket.http") local ltn12 = require("ltn12")   local path = "http://192.168.1.13/goform/AppCommand.xml"     local payload = [[ <?xml version="1.0" encoding="utf-8"?> <tx>   <cmd id="1">GetAllZonePowerStatus</cmd>   <cmd id="1">GetAllZoneVolume</cmd>   <cmd id="1">GetAllZoneSource</cmd>   <cmd id="1">GetAllZoneMuteStatus</cmd> </tx> ]]          --"cmd0=PutMasterVolumeBtn%2F%3E&cmd1=aspMainZone_WebUpdateStatus%2F"          --"cmd0=PutZone_InputFunction%2FTV&cmd1=aspMainZone_WebUpdateStatus%2F"   local response_body = { }   local res, code, response_headers, status = http.request   {     url = path,     method = "POST",     headers =     {       ["Accept"] = "*/*",       ["Content-Type"] = "application/x-www-form-urlencoded",       ["Content-Length"] = payload:len()     },     source = ltn12.source.string(payload),     sink = ltn12.sink.table(response_body)   } itemtag = false result = {} -- callback for tag start function starttag(parser, tag)   -- create new storage in result table for each <item> tag   if tag == 'zone1' then     itemtag = true     table.insert(result, {})   end   currtag = tag end -- callback for tag end function endtag(p, tag)   if tag == 'zone1' then     itemtag = false   end   currtag = nil end -- callback for character data function cdata(parser, text)   -- check if parser is inside of <item> and either in <title> or <description>   if itemtag and currtag then     if currtag == 'zone1' then       result[ #result ].Z1= text           elseif currtag == 'dispvalue' then       result[ #result ].Z1_Volume = text           elseif currtag == 'source' then       result[ #result ].Z1_source = text     end       end end -- create parser lxp = require('lxp') parser = lxp.new({   StartElement = starttag,   EndElement = endtag,   CharacterData = cdata, }) if parser:parse(data) then   -- Zone 1 State   if (result [1].Z1) == 'ON'then   —-update group   end     if (result [1].Z1) == 'OFF'then     —update group   end   -- Zone 1 Volume   if(result [2].Z1_Volume) ~= last then     —set new volume to group      last = result [2].Z1_Volume   end   else   log('parse failed') end



RE: Denon AVR X2300W control via API - MantasJ - 25.06.2020

Thank You guys!

I've managed to make control script with method admin posted and I've managed to make a status script from this example: https://openrb.com/example-use-lm2-as-tcp-client-for-reading-data-from-home-theater/ it is a bit slow, but it is more than fine for the client.