22.06.2020, 11:24
(This post was last modified: 22.06.2020, 11:32 by benanderson_475.)
(22.06.2020, 10:57)admin Wrote: Looks like newer models can be controlled via HTTP like this:I got the post commands working as admin said above,
http://DENON_IP:8080/goform/formiPhoneAp...t.xml?PWON
I'm not sure if status response can be received this way, you might need to use Telnet instead of HTTP.
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