Denon AV Reciver - plugin

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Denon AV Reciver - plugin

Post by trixwood » Saturday 12 November 2016 4:08

Well I did not test that :-) I was hacked my way in... never wrote a bash script before :-)
Glad it works :-)

As a side note:

denon.telnet.sh gives a lot more action options then the nomal http ones. Like bass control or individual speaker volume see reference (or google for your model):

http://openrb.com/wp-content/uploads/20 ... V7.6.0.pdf

Like (see begin page 15 bass up)

Code: Select all

denon.telnet.sh PSBAS UP
i use it also in denon.sh to get the bass value...

Code: Select all

# Bass
 #   AVbass=$(./denon.telnet.sh PSBAS ? | sed 's/PSBAS //' | grep -Eo '[0-9]{1,4}')
 #   AVbass=$(((AVbass-43)*10)) 
There is one limitation... denon device accepts limited telnet connection... so if you do not change it alot it works...:-)

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 4:12

Its not working when I have my amp as absolute.. I need my amp on absolute lol.. I have just ran the first command and got this..

Denon AVR-X2000 ON ON MAIN ZONE ON ON MPLAY ON 4 DENON_MODEL 1 NETWORK NET MULTI CH STEREO Absolute -29.0 off OFF FALSE TRUE

if I change it to relative its this

Denon AVR-X2000 ON ON MAIN ZONE ON ON MPLAY ON 4 DENON_MODEL 1 NETWORK NET MULTI CH STEREO Relative -29.0 off OFF FALSE TRUE

The volume numbers are the same! both -29.0.. Any ideas why when I'm in absolute mode it sets my domoticz slider to over 200% and while in Relative mode it works..

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 12:45

So using your latest script works fine if my Amp is in Relative mode and I enable the Absolute part of the script. However if I change amp to Absolute the script comes up with a load of errors. If I have amp in Relative mode and the script with Relative mode it throws up errors. Only way it works is with Amp in Relative and Script in Absolute then it works. If I put Amp into Absolute with Absolute the script actually runs but sets the slider in domoticz to well over 200%. There is a calculation error somewhere but I can't see from where? Any ideas mate?

I'll recap

AMP SCRIPT
Absolute Absolute - Script runs without error but sets slider in Domoticz to over 200%
Relative Absolute - Runs perfectly (However I can't leave my amp in Relative mode for other plugins I need :( )
Absolute Relative - Script fails
Relative Relative - Script fails

Below is what I get when the script fails..

Code: Select all

/home/pi/domoticz/scripts/denon.sh: line 123: 7
0
100
1014
150
00
58
0
7
0
3
5
0
0
0
0
0
0
0
2
8
0
1531
5
969
57
94
33
24
55
53
45
32
1045
8
373
8
0
100
41
99
34
75
18
31
47
2
2
24
0
8
18
44
35
41
88
40
32
0
0
70
21
0
20
0
47
16
0
27
0
48
76
26
63
4
52
92
9
59
1
42
58
5
43
45
6
208
45
6+1: syntax error in expression (error token is "0
100
1014
150
00
58
0
7
0
3
5
0
0
0
0
0
0
0
2
8
0
1531
5
969
57
94
33
24
55
53
45
32
1045
8
373
8
0
100
41
99
34
75
18
31
47
2
2
24
0
8
18
44
35
41
88
40
32
0
0
70
21
0
20
0
47
16
0
27
0
48
76
26
63
4
52
92
9
59
1
42
58
5
43
45
6
208
45
6+1")

User avatar
G3rard
Posts: 827
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Denon AV Reciver - plugin

Post by G3rard » Saturday 12 November 2016 12:48

@trixwood, thanks for your scripts and detailed explanation!

I have used your bash scripts to control the volume of my Marantz NR1604 with Domoticz using two LUA scripts.
tv-volume.jpg
tv-volume.jpg (16.11 KiB) Viewed 2011 times
LUA device script which sends volume via dimmer in Domoticz to Marantz

Code: Select all

commandArray = {}
IP = '192.168.1.138'	--IP of Marantz

if devicechanged['TV volume'] == 'On' then
    local play = 'curl --url "http://192.168.1.138/MainZone/index.put.asp?cmd0=PutVolumeMute%2Foff" &'	--unmute
    os.execute(play)
end

if devicechanged['TV volume'] == 'Off' then
    local play = 'curl --url "http://192.168.1.138/MainZone/index.put.asp?cmd0=PutVolumeMute%2Fon" &'	--mute
    os.execute(play)
end

if devicechanged['TV volume'] then 
  NewLevel = otherdevices_svalues['TV volume'] 
  if NewLevel ~= "Off" and NewLevel ~= "0" then  
    if tonumber(NewLevel) > 60 then   --volume max 60
        NewLevel = 60
    end
    SendLevel = NewLevel - 80 --79.5
    --os.execute ("curl http://" .. (IP) .. "/MainZone/index.put.asp?cmd0=PutSystem_OnStandby%2FON")
    --os.execute ("curl http://" .. (IP) .. "/MainZone/index.put.asp?cmd0=PutVolumeMute%2Foff")    
    os.execute ("curl http://" .. (IP) .. "/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/" .. (SendLevel))
  end
end

return commandArray
LUA time script which updates actual volume from Marantz in Domoticz

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.138/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['TV volume']
--print(vol_tv)
vol_tv = tonumber(vol_tv) + 80
--print(vol_tv)
--if otherdevices['TV'] == 'On' then
    if (vol_domo ~= vol_tv) then
        commandArray['UpdateDevice'] = otherdevices_idx['TV volume'] ..' |2|' .. vol_tv
    end
--end

return commandArray
The volume gets updated every minute, that is fast enough for me.
This way I can also control the volume via Siri using the excellent Homebridge-eDomoticz software .

Edit: changed the script a bit, because it was only updating if you have a device TV which is On.
Last edited by G3rard on Saturday 12 November 2016 14:38, edited 1 time in total.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

User avatar
G3rard
Posts: 827
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Denon AV Reciver - plugin

Post by G3rard » Saturday 12 November 2016 12:51

simon_rb wrote:So using your latest script works fine if my Amp is in Relative mode and I enable the Absolute part of the script. However if I change amp to Absolute the script comes up with a load of errors. If I have amp in Relative mode and the script with Relative mode it throws up errors. Only way it works is with Amp in Relative and Script in Absolute then it works. If I put Amp into Absolute with Absolute the script actually runs but sets the slider in domoticz to well over 200%. There is a calculation error somewhere but I can't see from where? Any ideas mate?
I have my Marantz in Absolute mode and use the LUA scripts I posted above.
I changed the calculation to determine the right volume from the bash script a bit (and am using 80 to get the right volume).
Can you try if that is working for you?
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 12:56

Above is what I'm trying to do. I currently use homebridge-marantz-volume but it has an issue where it crashes when the Amp isn't reachable so was looking to do what you have done above.

Does this work with yours in Absolute mode? The only difference in both the commands sent for status is the name..

sent:- http://192.168.1.12/goform/formNetAudio_StatusXml.xml
receive:- 0 8 0 0 0 0 0 0 0 0 Network Favorites Internet Radio Last.Fm Spotify Media Server Flickr [ 0/6 ] 1 6 ../img/favorite_off.png ../img/favorite_on.png FAVORITES ../img/Internetradio_off.png ../img/Internetradio_on.png IRADIO ../img/Spotify_off.png ../img/Spotify_on.png SPOTIFY ../img/lastfm_off.png ../img/lastfm_on.png LASTFM ../img/Mediaserver_off.png ../img/Mediaserver_on.png SERVER ../img/flickr_off.png ../img/flickr_on.png FLICKR 0 0 0 0 0 0 0 0 0 0 4 DENON_MODEL 1 MEDIA PLAYER NET DTS NEO:6 cinema Relative -1.0 off OFF FALSE TRUE

Only difference is it will say Absolute instead of Relative, the number stays the same so I think its the way its working it out is wrong... when in absolute mode when it doesn't have to work anything out difference to absolute mode..

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 12:58

Cheers mate however I just got it working.. I changed the references within the bash script from Relative to Absolute in the calculations and its worked!
Dunno how but its working! :D

I might try your approach as every minute the bash runs it changes the volume slightly as calculations are wrong by 1%

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:12

I get a Nil value from your script, can't see what I've missed. Do I have to have the denon.sh running too?

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'] == 'On' then
    if (vol_domo ~= vol_tv) then
        commandArray['UpdateDevice'] = otherdevices_idx['Denon Volume'] ..' |2|' .. vol_tv
    end
end

return commandArray

User avatar
G3rard
Posts: 827
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Denon AV Reciver - plugin

Post by G3rard » Saturday 12 November 2016 13:17

What is the output of http://192.168.1.12/goform/formMainZone_MainZoneXml.xml?

For me it's showing the following XML for the volume:

Code: Select all

<MasterVolume>
<value>-30.0</value>
</MasterVolume>
If your output is different then the code needs to be changed, because it's looking for MasterVolume and then removes the value tags.

And you don't need denon.sh to be running.
Last edited by G3rard on Saturday 12 November 2016 13:19, edited 1 time in total.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:18

Mines 32 also..


Sent from my iPhone using Tapatalk

trixwood
Posts: 510
Joined: Friday 18 March 2016 8:20
Target OS: -
Domoticz version: Offline
Contact:

Re: Denon AV Reciver - plugin

Post by trixwood » Saturday 12 November 2016 13:21

mine is

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<item>
<Power><value>ON</value></Power>
<ZonePower><value>ON</value></ZonePower>
<InputFuncList>
<value>SOURCE</value>
<value>TUNER</value>
<value>CD</value>
<value>NET/USB</value>
<value>DVD</value>
<value>BD</value>
<value>TV</value>
<value>SAT/CBL</value>
<value>DOCK</value>
<value>GAME2</value>
<value>GAME</value>
<value>V.AUX</value>
</InputFuncList>
<RenameSource>
<value></value>
<value>TUNER   </value>
<value>CD      </value>
<value>NET/USB </value>
<value>DVD     </value>
<value>BD      </value>
<value>TV      </value>
<value>SAT/CBL </value>
<value>DOCK    </value>
<value>GAME2   </value>
<value>GAME1   </value>
<value>V.AUX   </value>
</RenameSource>
<RenameZone><value>MAIN ZONE 
</value></RenameZone>
<SourceDelete>
<value>DEL</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
<value>USE</value>
</SourceDelete>
<TopMenuLink><value>OFF</value></TopMenuLink>
<ModelId><value>1</value></ModelId>
<SalesArea><value>1</value></SalesArea>
<InputFuncSelect><value>NET/USB</value></InputFuncSelect>
<NetFuncSelect><value>NET/USB</value></NetFuncSelect>
<InputFuncSelectMain><value>NET/USB</value></InputFuncSelectMain>
<selectSurround><value>STEREO                         </value></selectSurround>
<SurroundLists>
<value index=''  table='' param=''/>
<value index='DOLBY DIGITAL'  table='Standard(Dolby)' param=''/>
<value index='DTS SURROUND'  table='Standard(DTS)' param=''/>
<value index='DIRECT'  table='Direct' param=''/>
<value index='PURE DIRECT'  table='Pure Direct' param=''/>
<value index='STEREO'  table='Stereo' param=''/>
<value index='MCH STEREO'  table='Multi CH Stereo' param=''/>
<value index='VIRTUAL'  table='Virtual' param=''/>
<value index='ROCK ARENA'  table='Rock Arena' param=''/>
<value index='JAZZ CLUB'  table='Jazz Club' param=''/>
<value index='MONO MOVIE'  table='Mono Movie' param=''/>
<value index='VIDEO GAME'  table='Video Game' param=''/>
<value index='MATRIX'  table='Matrix' param=''/>
</SurroundLists>
<VolumeDisplay><value>Relative</value></VolumeDisplay>
<MasterVolume><value>-27.0</value></MasterVolume>
<Mute><value>off</value></Mute>
<RemoteMaintenance><value>OFF</value></RemoteMaintenance>
<GameSourceDisplay><value>TRUE</value></GameSourceDisplay>
<LastfmDisplay><value>FALSE</value></LastfmDisplay>
<SubwooferDisplay><value>FALSE</value></SubwooferDisplay>
<Zone2VolDisp><value>TRUE</value></Zone2VolDisp>
</item>

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:22

I have got it working now using the denon.sh and not updating every minute (don't know how just been playing about). Below is the script thats working for my Denon amp in Absolute mode if anyone wants it :D

Thank you so much trixwood and G3rard for your help

Code: Select all

#!/bin/bash
#
# Domoticz Denon Script
# ---------------------
#
# Created 2016 Trixwood
#
# 0.1 first try
# 0.2 TC only update when needed
# 0.3 Mute & Volume feature
#
#
# to do: check if domoticz online else do not send anything
#
# Enable debug remove the # from the echo's (only volume uses echo... will change that todo ;-)

# Settings
DOMO_IP="192.168.1.26"            # Domoticz IP Address
DOMO_PORT="8080"              # Domoticz Port
DENONIP="192.168.1.12"           # Denon IP Address
#DENON_IDX="155"               # On/Off    (Switch) IDX *1
#DENON_MUTE_IDX="284"         # Absolute Volume (Slider) IDX (same as Absolute Volume)
#DENON_VOL_REL_IDX="284"        # Relative Volume (Sound Volume) IDX
DENON_VOL_ABS_IDX="284"       # Absolute Volume (Slider) IDX


# *1 You need additional virtual device which this one is a slave
# use ip for domoticz not the hostname, else password protection will fail…

# check if receiver in online
PINGTIME=`ping -c 1 -q $DENONIP | awk -F"/" '{print $5}' | xargs`

#
# Default Values
# todo only update when value changed... sleepy time now ;-)
#
function defaulting {

  #echo Defaulting...  

 # curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_MUTE_IDX&switchcmd=On" &> /dev/null
  curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_IDX&switchcmd=Off" &> /dev/null
  curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$DENON_VOL_REL_IDX&nvalue=0&svalue=-80.5" &> /dev/null
  curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_VOL_ABS_IDX&switchcmd=Set%20Level&level=0" &> /dev/null

}


# we can ping the machine
if expr "$PINGTIME" '>' 0
then

  # is there a denon?
  AVexists=$(curl -s http://$DENONIP/goform/formMainZone_MainZoneXml.xml | tee denon.mainzone.settings | grep "<Power><value>" &> /dev/null)
  
  # yes!
  if [ $? -eq 0 ] ; then
    
    #
    # Mute
    # ----
    #
   
    # decode new value
    AVmute=$(sed -n -e 's/.*\<Mute><value>\(.*\)<\/value>.*/\1/p' denon.mainzone.settings)

    # decode old value
    AVmuteold=$(curl -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=devices&rid=$DENON_MUTE_IDX" | grep "Status")
    AVmuteold="${AVmuteold##*Status\" : \"}"
    AVmuteold=${AVmuteold//\",/}

    #echo "Mute: $AVmute ($AVmuteold)"
    
    # only switch when value is changed
    if [ "$AVmute" == "on" ] && [ "$AVmuteold" != "Off" ] ; then
      curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_MUTE_IDX&switchcmd=Off" &> /dev/null
      #echo "Mute: Switching On"
    fi
    if [ "$AVmute" == "off" ] && [ "$AVmuteold" == "Off" ] ; then
      curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_MUTE_IDX&switchcmd=On" &> /dev/null
      #echo "Mute: Switching Off"
    fi

    #
    # Volume
    # ----------
    #
    # Note that Denon Can So 0.5 steps of Decibel is set to Relative that means with relative you have twice the amount of resolution
    # So resolution will be lost if your denon is set to relative volume since the slider only half the resolution and sound volume 
    # does not have half steps
    # 
    # Range Relative -80.5 dB to +18
    #       Absolute 0..99
    #
    # that will not convert well :-/

    # decode new value

  
    AVisvolumeabsolute=$(sed -n -e 's/.*\<VolumeDisplay><value>\(.*\)<\/value>.*/\1/p' denon.mainzone.settings)
    AVvolume=$(sed -n -e 's/.*\<MasterVolume><value>\(.*\)<\/value>.*/\1/p' denon.mainzone.settings)
  
     if [ "$AVvolume" == "--" ] ; then
          AVvolume="0"
          AVisvolumerelative="Infinity"
     fi

    # compensate for Denon Volume setting    
    if [ "$AVisvolumeabsolute" == "Absolute" ] ; then
      #echo "Volume: Relative"
      AVvolumeAbs=$(echo "81 + $AVvolume" | bc) 
      AVvolumeRel=$AVvolume
    else
      #echo "Volume: Absolute"
      AVvolumeRel=$(echo "$AVvolume - 81" | 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)" 

    # only switch when value is changed
    if [ "$AVmute" == "off" ] && [ "$AVvolumeAbs" != "$AVvolumeoldAbs" ]; then
      #echo "Volume: Switching $AVvolumeRel db $AVvolumeAbs"

      curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$DENON_VOL_REL_IDX&nvalue=0&svalue=$AVvolumeRel" &> /dev/null
      curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=switchlight&idx=$DENON_VOL_ABS_IDX&switchcmd=Set%20Level&level=$AVvolumeAbs" &> /dev/null
    fi  

    # if mute then show sound -81db
    if [ "$AVmute" == "off" ]  && [ "$AVmuteold" == "On" ]; then
      curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$DENON_VOL_REL_IDX&nvalue=0&svalue=$AVvolumeRel" &> /dev/null
    fi

  
     if [ "$AVmute" == "on" ] && [ "$AVmuteold" == "Off" ]; then
       curl -s -i -H "Accept: application/json" "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command&param=udevice&idx=$DENON_VOL_REL_IDX&nvalue=0&svalue=-81" &> /dev/null


    fi  

  else
    # no denon xml from http server do something!
    defaulting 
  fi
else
  # we could not even ping it defaulting
  defaulting  
fi




pollefinario
Posts: 20
Joined: Wednesday 10 February 2016 13:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Denon AV Reciver - plugin

Post by pollefinario » Saturday 12 November 2016 13:27

G3rard wrote:LUA time script which updates actual volume from Marantz in Domoticz

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.138/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['TV volume']
--print(vol_tv)
vol_tv = tonumber(vol_tv) + 80
--print(vol_tv)
if otherdevices['TV'] == 'On' then
    if (vol_domo ~= vol_tv) then
        commandArray['UpdateDevice'] = otherdevices_idx['TV volume'] ..' |2|' .. vol_tv
    end
end

return commandArray
How did you set the event name and "all/device/time selector" for this script? Thanks!

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:35

Problem I have now is I'm trying to use the Denon Volume to turn on and off my amp within Domoticz which works fine. Problem is that if the amp is off when the script sends the commands every minute and the amp is in an off state it sets the Denon Volume dimmer back to on and turns amp on. LOL What can I put in the script to not update the Denon Volume if Amp is in standby?

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:36

pollefinario wrote:
G3rard wrote:LUA time script which updates actual volume from Marantz in Domoticz

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.138/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['TV volume']
--print(vol_tv)
vol_tv = tonumber(vol_tv) + 80
--print(vol_tv)
if otherdevices['TV'] == 'On' then
    if (vol_domo ~= vol_tv) then
        commandArray['UpdateDevice'] = otherdevices_idx['TV volume'] ..' |2|' .. vol_tv
    end
end

return commandArray
How did you set the event name and "all/device/time selector" for this script? Thanks!
I'd say script_time_scriptname.lua in Lua folder :)

pollefinario
Posts: 20
Joined: Wednesday 10 February 2016 13:40
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Denon AV Reciver - plugin

Post by pollefinario » Saturday 12 November 2016 13:39

Thanks thats what I've used indeed.

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 13:50

I see in the bash script it checks to see if the amp is actually there.. Is there a way to see if its on or standby so if its standby, don't run the rest of the script however if its on then run the script? I only need the denon.sh to check volume when the amp is on. I don't need it to turn the amp on or anything like that. Cheers Peps..

I know the xml says if its in STANDBY & ON, just need to figure out how to add that to begging of the script..

http://192.168.1.12/goform/formMainZone_MainZoneXml.xml
Denon AVR-X2000 STANDBY OFF MAIN ZONE ON OFF MPLAY OFF 4 DENON_MODEL 1 MEDIA PLAYER NET DTS NEO:6 cinema Absolute -32.0 off OFF FALSE TRUE

http://192.168.1.12/goform/formMainZone_MainZoneXml.xml
Denon AVR-X2000 ON ON MAIN ZONE ON OFF MPLAY OFF 4 DENON_MODEL 1 MEDIA PLAYER NET DTS NEO:6 cinema Absolute -32.0 off OFF FALSE TRUE

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 14:36

I'm trying to get either way working now, I think the Lua one should work well as it checks if Denon Volume is on.. I'm still not getting info from the amp.. Is there anything else I need to do?

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'] == 'On' then
    if (vol_domo ~= vol_tv) then
        commandArray['UpdateDevice'] = otherdevices_idx['Denon Volume'] ..' |2|' .. vol_tv
    end
end

return commandArray

My XML returned from http://192.168.1.12/goform/formMainZone_MainZoneXml.xml

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<item>
    <FriendlyName>
        <value>Denon AVR-X2000</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>MPLAY</value>
    </VideoSelect>
    <VideoSelectOnOff>
        <value>OFF</value>
    </VideoSelectOnOff>
    <VideoSelectLists>
        <value index='ON'  table='On' param=''/>
        <value index='OFF'  table='Off' param=''/>
        <value index='SAT/CBL'  table='CBL/SAT' param=''/>
        <value index='DVD'  table='DVD' param=''/>
        <value index='BD'  table='Blu-ray' param=''/>
        <value index='GAME'  table='GAME' param=''/>
        <value index='AUX1'  table='AUX' param=''/>
        <value index='MPLAY'  table='MEDIA PLAYER' param=''/>
        <value index='TV'  table='TV AUDIO ' param=''/>
        <value index='CD'  table='CD' param=''/>
    </VideoSelectLists>
    <ModelId>
        <value>4</value>
    </ModelId>
    <BrandId>
        <value>DENON_MODEL</value>
    </BrandId>
    <SalesArea>
        <value>1</value>
    </SalesArea>
    <InputFuncSelect>
        <value>MEDIA PLAYER</value>
    </InputFuncSelect>
    <NetFuncSelect>
        <value>NET</value>
    </NetFuncSelect>
    <selectSurround>
        <value>DTS NEO:6 cinema               </value>
    </selectSurround>
    <VolumeDisplay>
        <value>Absolute</value>
    </VolumeDisplay>
    <MasterVolume>
        <value>-20.0</value>
    </MasterVolume>
    <Mute>
        <value>off</value>
    </Mute>
    <RemoteMaintenance>
        <value>OFF</value>
    </RemoteMaintenance>
    <SubwooferDisplay>
        <value>FALSE</value>
    </SubwooferDisplay>
    <Zone2VolDisp>
        <value>TRUE</value>
    </Zone2VolDisp>
</item>

User avatar
G3rard
Posts: 827
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Denon AV Reciver - plugin

Post by G3rard » Saturday 12 November 2016 14:42

Please change

Code: Select all

if otherdevices['Denon Volume'] == 'On' then
to

Code: Select all

if otherdevices['Denon Volume'] ~= 'Off' then
The dimmer has not status On when it's on, but the %.
And uncomment the 2 print(vol_tv) lines to be sure you get the right values.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

simon_rb
Posts: 700
Joined: Wednesday 07 August 2013 19:09
Target OS: -
Domoticz version:
Location: UK
Contact:

Re: Denon AV Reciver - plugin

Post by simon_rb » Saturday 12 November 2016 14:45

G3rard wrote:Please change

Code: Select all

if otherdevices['Denon Volume'] == 'On' then
to

Code: Select all

if otherdevices['Denon Volume'] ~= 'Off' then
The dimmer has not status On when it's on, but the %.
And uncomment the 2 print(vol_tv) lines to be sure you get the right values.
I'm not getting any values. The above script gives be a Nil value.. Yet my XML looks the same as yours. It is defo the correct IP address

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests