Re: Denon AV Reciver - plugin
Posted: Sunday 20 November 2016 0:16
Great work mate!
Sent from my iPhone using Tapatalk
Sent from my iPhone using Tapatalk

OK so this is brilliant, and I've been at this for a long time not wanting to go into .sh but remain pure Lua.simon_rb wrote:Don't know how pretty this is but it works
This updates the sliders and only updates the switch if its different...
Code: Select all
commandArray = {} function execute(command) -- returns success, error code, output. local f = io.popen(command..' 2>&1 && echo " $?"') local output = f:read"*a" return output end --read xml and remove value strings --<MasterVolume><value>-60.0</value></MasterVolume> becomes -60.0 function get(data,name) data = data:match("<"..name..">(.-)</"..name..">") data = data:gsub("<value>", "") data = data:gsub("</value>", "") return data end vol_tv = execute('curl --url "http://192.168.1.12/goform/formMainZone_MainZoneXml.xml" &') --get volume of TV and update volume switch in Domoticz if it differs local vol_tv = get(vol_tv,"MasterVolume") local vol_domo = otherdevices_svalues['Denon Volume'] print(vol_tv) vol_tv = tonumber(vol_tv) + 80 print(vol_tv) if otherdevices['Denon Volume'] ~= 'Off' then --if (vol_domo ~= vol_tv) then difference = math.abs(vol_domo - vol_tv) if difference > 1 then --commandArray['UpdateDevice'] = otherdevices_idx['Denon Volume'] ..' |2|' .. vol_tv os.execute('curl -s "http://192.168.1.26:8080/json.htm?type=command¶m=switchlight&idx=284&switchcmd=Set%20Level&level='..vol_tv..'" &') end end return commandArray
I use absolute for my amp and use the 100 (0-99) slider within Domoticz. I don't believe you can change it within Domoticz as such. It depends on the dummy switch you create. For me the 100 dummy is enough as I didn't like .5 volumes anyways - would bug me if it was at 65.5 for example lol.Bart77 wrote:Hi All,
Just wondering if it is possible to modify the range of the dummy switch - slider object.
If so I can match the range displayed on the AV receiver perfectly with the Domoticz object, in addition autoswitch to absolute <> relative which I can read from the actual configuration.
Next will be to implement the Source Select and synchronization to the scripts I posted
Thanks
I've written the script which I will share soon after cleaning it up a bit.Bart77 wrote:Hi All,
Just wondering if it is possible to modify the range of the dummy switch - slider object.
If so I can match the range displayed on the AV receiver perfectly with the Domoticz object, in addition autoswitch to absolute <> relative which I can read from the actual configuration.
Next will be to implement the Source Select and synchronization to the scripts I posted
Thanks
OK, that was easier than I thought cleaning it up. Here's my script for getting the Selector Switch for Marantz SOURCE in sync.raymond wrote:I've written the script which I will share soon after cleaning it up a bit.Bart77 wrote:Hi All,
Just wondering if it is possible to modify the range of the dummy switch - slider object.
If so I can match the range displayed on the AV receiver perfectly with the Domoticz object, in addition autoswitch to absolute <> relative which I can read from the actual configuration.
Next will be to implement the Source Select and synchronization to the scripts I posted
Thanks
I'm working on the Surround Setting Selector Switch too, but ran into a problem I posted just above.
Cheers,
Ray
Code: Select all
-- Reading Denon/Marantz xml file to update a Selector Switch to reflect current state of the receiver
-- July 2016 v0.1 first try testing
-- November 2016 v1.0 with help of G3rard and simon_rb for extracting the xml values
MarantzInput = 'Marantz Input Select'
InputValue = otherdevices['Marantz Input Select']
MarantzIP = '192.168.200.160'
Port = '80'
debug = true
logging = false
-- Name of the levels in the selector
ONLevel = 'On'
BDLevel = 'BD'
SATLevel = 'SAT'
TUNERLevel = 'TUNER'
GAMELevel = 'GAME'
OFFLevel = 'Off' --optional
-- Values from each level name
ONLevelValue = '10'
BDLevelValue = '20'
SATLevelValue = '30'
TUNERLevelValue = '40'
GAMELevelValue = '50'
OFFLevelValue = '0' --optional
commandArray = {}
function execute(command)
-- returns success, error code, output.
local f = io.popen(command..' 2>&1 && echo " $?"')
local output = f:read"*a"
return output
end
--read xml and remove value strings
--<InputFuncSelect><value>SOURCE</value></MasterVolume>
function get(data,name)
data = data:match("<"..name..">(.-)</"..name..">")
data = data:gsub("<value>", "")
data = data:gsub("</value>", "")
return data
end
av_status = execute('curl --url "http://192.168.200.160/goform/formMainZone_MainZoneXml.xml" &')
pw_status = execute('curl --url "http://192.168.200.160/goform/formMainZone_MainZoneXml.xml" &')
--get volume of TV and update volume switch in Domoticz if it differs
local av_status = get(av_status,"InputFuncSelect")
local pw_status = get(pw_status,"Power")
if debug then
print("av_status: '" .. av_status .."'")
print("pw_status: '" .. pw_status .. "'")
print("InputValue: '" .. InputValue .. "'")
end
if (pw_status == 'STANDBY') then
if debug then
print("Marantz is set to Off");
end
if (otherdevices[MarantzInput] ~= OFFLevel) then
print("Updating '" .. MarantzInput .. "' selector to '" .. OFFLevel .. "'")
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..OFFLevelValue
end
goto done
end
if (av_status == InputValue) then
if debug then
print("Marantz gelijk aan Marantz Input Domoticz");
end
elseif (av_status == ONLevel) then
print('<font color="blue">Marantz Input equals to ON </font>');
if InputValue ~= ONLevel then
print('<font color="blue">Updating ' .. MarantzInput .. ' selector to ' .. ONLevel .. '</font>')
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..ONLevelValue
end
elseif (av_status == GAMELevel) then
print('<font color="blue">Marantz Input equals to GAME </font>');
if (otherdevices[MarantzInput] ~= GAMELevel) then
print('<font color="blue">Updating ' .. MarantzInput .. ' selector to ' .. GAMELevel .. '</font>')
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..GAMELevelValue
end
elseif (av_status == BDLevel) then
print('<font color="blue">Marantz Input equals to BD </font>');
if (otherdevices[MarantzInput] ~= BDLevel) then
print('<font color="blue">Updating ' .. MarantzInput .. ' selector to ' .. BDLevel .. '</font>')
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..BDLevelValue
end
elseif (av_status == SATLevel) then
print('<font color="blue">Marantz Input equals to SAT </font>');
if (otherdevices[MarantzInput] ~= SATLevel) then
print('<font color="blue">Updating ' .. MarantzInput .. ' selector to ' .. SATLevel .. '</font>')
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..SATLevelValue
end
elseif (av_status == TUNERLevel) then
print('<font color="blue">Marantz Input equals to TUNER </font>');
if (otherdevices[MarantzInput] ~= TUNERLevel) then
print('<font color="blue">Updating ' .. MarantzInput .. ' selector to ' .. TUNERLevel .. '</font>')
commandArray['UpdateDevice'] = otherdevices_idx[MarantzInput]..'|1|'..TUNERLevelValue
end
end
::done::
return commandArray
Code: Select all
pi@raspberrypi:~/domoticz/scripts $ ls -l denon.sh
-rwxr-xr-x 1 pi pi 14119 dec 1 00:21 denon.sh
pi@raspberrypi:~/domoticz/scripts $ sudo sh -x denon.sh
+
: not found6: denon.sh:
+ DOMO_IP=192.168.0.100
+ DOMO_PORT=8080
+ DENONIP=192.168.0.32
+ DENON_IDX=69
+ DENON_STATUS_IDX=64
+ DENON_MUTE_IDX=71
+ DENON_VOL_REL_IDX=72
+ DENON_VOL_ABS_IDX=71
+ DENON_SURROUND_IDX=73
+ DENON_INPUT_IDX=74
+ DENON_NET_INPUT_IDX=62
+ DENON_AIRPLAY_IDX=75
+
: not found0: denon.sh:
+
: not found3: denon.sh:
+
: not found7: denon.sh:
+ ping -c 1 -q 192.168.0.32
+ awk -F/ {print $5}
+ xargs
+ PINGTIME=0.512
+
: not found0: denon.sh:
+ function defaulting {
denon.sh: 45: denon.sh: function: not found
+
: not found6: denon.sh:
+
+ +
curl -s -i -H Accept: application/json http://192.168.0.100:8080/json.htm?type=command¶m=udevice&idx=64&nvalue=0&svalue=No%20Denon%20Detected
+ +
curl -s -i -H Accept: application/json http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=75&switchcmd=Off
+
+ +
curl -s -i -H+ Accept: application/json http://192.168.0.100:8080/json.htm?type=command¶m=udevice&idx=72&nvalue=0&svalue=-80.5
: not found4: denon.sh: +
+ }
: not found5: denon.sh: }
+
: not found6: denon.sh:
+
: not found7: denon.sh:
curl -sdenon.sh: 90: denon.sh: Syntax error: "fi" unexpected (expecting "then")
-i -H Accept: application/json http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=69&switchcmd=Off
pi@raspberrypi:~/domoticz/scripts $ HTTP/1.1 200 OK
Content-Length: 53
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
+ curl -s -i -H Accept: application/json http://192.168.0.100:8080/json.htm?type=command¶m=switchlight&idx=71&switchcmd=Set%20Level&level=0
HTTP/1.1 200 OK
HTTP/1.1 200 OK
HTTP/1.1 200 OK
Content-Length: 53
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "Update Device"
}
{
"status" : "OK",
"title" : "SwitchLight"
}
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "SwitchLight"
}
HTTP/1.1 200 OK
Content-Length: 51
Content-Type: application/json;charset=UTF-8
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Allow-Origin: *
{
"status" : "OK",
"title" : "SwitchLight"
}
Code: Select all
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<item>
<FriendlyName>
<value>Denon AVR-X4200W</value>
</FriendlyName>
<Power>
<value>STANDBY</value>
</Power>
<ZonePower>
<value>OFF</value>
</ZonePower>
<RenameZone>
<value>MAIN ZONE</value>
</RenameZone>
<TopMenuLink>
<value>ON</value>
</TopMenuLink>
<VideoSelectDisp>
<value>OFF</value>
</VideoSelectDisp>
<VideoSelect>
<value/>
</VideoSelect>
<VideoSelectOnOff>
<value>OFF</value>
</VideoSelectOnOff>
<VideoSelectLists>
<value index="ON">På</value>
<value index="OFF">Av</value>
<value index="SAT/CBL">Dator</value>
<value index="DVD">DVD</value>
<value index="GAME">Wii U</value>
<value index="MPLAY">Shield TV</value>
</VideoSelectLists>
<ECOModeDisp>
<value>ON</value>
</ECOModeDisp>
<ECOMode>
<value>OFF</value>
</ECOMode>
<ECOModeLists>
<value index="ON" table="MILJÖ: PÅ" param=""/>
<value index="OFF" table="MILJÖ: AV" param=""/>
<value index="AUTO" table="MILJÖ: AUTO" param=""/>
</ECOModeLists>
<AddSourceDisplay>
<value>FALSE</value>
</AddSourceDisplay>
<ModelId>
<value>4</value>
</ModelId>
<BrandId>
<value>DENON_MODEL</value>
</BrandId>
<SalesArea>
<value>4</value>
</SalesArea>
<InputFuncSelect>
<value>Dator</value>
</InputFuncSelect>
<NetFuncSelect>
<value>NET</value>
</NetFuncSelect>
<selectSurround>
<value>Multi Ch Stereo</value>
</selectSurround>
<VolumeDisplay>
<value>Relative</value>
</VolumeDisplay>
<MasterVolume>
<value>-40.0</value>
</MasterVolume>
<Mute>
<value>off</value>
</Mute>
<RemoteMaintenance>
<value>OFF</value>
</RemoteMaintenance>
<SubwooferDisplay>
<value>FALSE</value>
</SubwooferDisplay>
<Zone2VolDisp>
<value>TRUE</value>
</Zone2VolDisp>
<SleepOff>
<value>Av</value>
</SleepOff>
</item>

Code: Select all
if [ "$AVvolume" == "--" ] ; then
AVvolume="0"
AVisvolumerelative="Infinity"
fi
if [ "$AVisvolumerelative" == "Relative" ] ; then
#echo "Volume: Relative"
AVvolumeAbs=$(echo "80.5 + $AVvolume" | bc)
AVvolumeRel=$AVvolume
else
#echo "Volume: Absolute"
AVvolumeRel=$(echo "80.5 - $AVvolume" | bc)
AVvolumeAbs=$AVvolume
fi
# exterminate, exterminate, convert... convert...
AVvolumeAbs=$((${AVvolumeAbs//\./}/10))
# decode old value
AVvolumeoldAbs=$(($(curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$DENON_VOL_ABS_IDX" | grep Data | grep -Eo '[0-9]{1,4}')+1))
#echo "Volume: $AVvolumeRel db $AVvolumeAbs ($AVvolumeoldAbs)"
Code: Select all
echo "Volume: $AVvolumeRel db $AVvolumeAbs"Code: Select all
SendLevel = NewLevel - 79.5Yes with http you can, simply add in the URL (or in the message body if you're using POST) &ZoneName=ZONE2piokuc wrote:Hi
Did you know how create virtual device in Domoticz to set for Zone 1 and other to Zone 2 SLEEP TIME in DENON AVR-X2100W ?
Code: Select all
http://DENONIP/MainZone/index.put.asp?cmd0=PutZone_InputFunction/MPLAY&ZoneName=ZONE2This wont work with the 2016 onwards AVR's as Denon have stopped access to the Web Control API. I have just updated to a X3400 from an X2000 so its broken for me also. No sure how to fix it.gj23 wrote: Monday 19 February 2018 16:06 hi,
great stuff.
i have an denon avr x2400h and it won't work.
can somebody tell me what commands i have to use?
when i try to check some codes with firefox i only get Error 403: Forbidden Access Forbidden.
and where i have to put the xml file exactly?
The web control API is still there, but has been moved to port 8080. See https://github.com/scarface-4711/denona ... -354880648simon_rb wrote: Tuesday 20 March 2018 18:28 This wont work with the 2016 onwards AVR's as Denon have stopped access to the Web Control API. I have just updated to a X3400 from an X2000 so its broken for me also. No sure how to fix it.