NAD 7050
Moderator: leecollings
-
- Posts: 29
- Joined: Monday 23 March 2015 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Zwolle
- Contact:
NAD 7050
I have created rudimentary support for the NAD 7050 Amplifier:
https://www.domoticz.com/wiki/NAD7050
If you happen to have one, give it a try. The main reason for me was that the Android App stopped working with the release of Android Nougat, so I had to get off the couch to set the volume
https://www.domoticz.com/wiki/NAD7050
If you happen to have one, give it a try. The main reason for me was that the Android App stopped working with the release of Android Nougat, so I had to get off the couch to set the volume
Re: NAD 7050
Thanks a lot for sharing the NAD7050 code!
I had to make some minor changes to get the scripts to work with python 3.5.2. Among others the hex decode method has changed between version 2 and 3, the print syntax is changed and the ord() call is not needed anymore. I have included the modified scripts below.
Thanks,
Regards, Anne
--
NADOnOff.py becomes:
and NADVolume.py:
I had to make some minor changes to get the scripts to work with python 3.5.2. Among others the hex decode method has changed between version 2 and 3, the print syntax is changed and the ord() call is not needed anymore. I have included the modified scripts below.
Thanks,
Regards, Anne
--
NADOnOff.py becomes:
Code: Select all
#!/usr/bin/python
TCP_IP = '<IP of your NAD7050>'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
def send(MESSAGE):
MESSAGE = codecs.decode(MESSAGE, "hex_codec")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
def turnOff():
send("0001020900")
def turnOn():
send("0001020901")
def setVol(n):
send("00010204"+(hex(int(n))[2:]).zfill(2))
if sys.argv[1]=="on":
print ('Turning on')
turnOn()
else:
print ('Turning off')
turnOff()
Code: Select all
#!/usr/bin/python
TCP_IP = '<IP of your NAD7050>'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
def send(MESSAGE):
MESSAGE = codecs.decode(MESSAGE, "hex_codec")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
def getSetVol(delta): #Fuck yeah magic numbers
MESSAGE = "000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(codecs.decode(MESSAGE, "hex_codec"))
counter = 0
while True:
x = s.recv(1024)
for a in x:
if counter==11:
z = a
s.send(codecs.decode("00010204"+(hex(int(z+delta))[2:]).zfill(2), "hex_codec"))
s.close()
return z
counter += 1
if sys.argv[1]=="up":
getSetVol(6)
elif sys.argv[1]=="down":
getSetVol(-6)
Re: NAD 7050
Hi,
I have captured the command strings for the input selection on the amplifier. I have modified the NADVolume script so it first collects the current input and you can use the 'push button on' to cycle through the inputs.
Next I'll look at a better option to control the amplifier, the 'Selector' option with a button set or menu would be a start I guess. Next step would be a more media-player like control with the on/off and volume added
Regards, Anne
I have captured the command strings for the input selection on the amplifier. I have modified the NADVolume script so it first collects the current input and you can use the 'push button on' to cycle through the inputs.
Next I'll look at a better option to control the amplifier, the 'Selector' option with a button set or menu would be a start I guess. Next step would be a more media-player like control with the on/off and volume added
Regards, Anne
Code: Select all
#!/usr/bin/python
TCP_IP = '<insert your NAD7050 IP>'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
def send(MESSAGE):
MESSAGE = codecs.decode(MESSAGE, "hex_codec")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
# CMD strings for each input
#0001020300 - Coax 1
#0001020301 - Coax 2
#0001020302 - Opt 1
#0001020303 - Opt 2
#0001020304 - Computer
#0001020305 - Stream
#0001020306 - Dock
#0001020307 - BT
def SelectInput(delta): # magic numbers -> initial string captured in Wireshark
MESSAGE = "000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(codecs.decode(MESSAGE, "hex_codec"))
counter = 0
while True:
x = s.recv(1024)
for a in x:
if counter==46:
z = InputMinMax(a,delta)
s.send(codecs.decode("00010203"+(hex(int(z+delta))[2:]).zfill(2), "hex_codec"))
s.close()
return z
counter += 1
def InputMinMax(a,delta):
# if last input is reached (BT), go back to first (Coax 1) on the next 'up' command. This way you can cycle through the inputs in Domoticz
if (a+delta) == 8:
z = -1
return z
elif (a+delta) == -1:
z = 8
return z
else:
z = a
return z
if sys.argv[1]=="up":
SelectInput(1)
elif sys.argv[1]=="down":
SelectInput(-1)
-
- Posts: 29
- Joined: Monday 23 March 2015 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Zwolle
- Contact:
Re: NAD 7050
Thanks for the updates, I forgot to subscribe to the topic so I did not notice your response until now. Supporting source switching was high on my wishlist!
I moved the lua scripts into domoticz itself (setup -> more options -> events and then select lua instead of blockly) and merged them, so I updated the wiki to reflect this. I remember that it is also possible to directly use python scripts when you build domoticz from source, but I just use the standard beta releases.
I used python2 because it still seems to be the default on domoticz, but I have been using python3 for my paid job for years, so we might as well finally go for it here too, after all these years . I switched my own installation and also adapted the wiki. You are not running the standard raspbian (which is still in 3.4 and not 3.5)?
I moved the lua scripts into domoticz itself (setup -> more options -> events and then select lua instead of blockly) and merged them, so I updated the wiki to reflect this. I remember that it is also possible to directly use python scripts when you build domoticz from source, but I just use the standard beta releases.
I used python2 because it still seems to be the default on domoticz, but I have been using python3 for my paid job for years, so we might as well finally go for it here too, after all these years . I switched my own installation and also adapted the wiki. You are not running the standard raspbian (which is still in 3.4 and not 3.5)?
Re: NAD 7050
Hi Rob,
Nice! I wasn't aware of the python 2/3 change, I cloned the git repository when I started with domoticz and I guess it came with Python 3
In the meantime I made a Selector switch for the NAD in which you can turn it on/off and directly select the input, with a separate dimmer switch to control the volume (I then picked up a Homey, spent a couple of frustrating nights wondering whether I should return it until I figured it's actually pretty cool but completely different from domoticz, with a different learning curve... I have not yet gotten around to connecting homey with domoticz to control the NAD amplifier...).
Anyway, the Selector switch is pretty useful.
As to the volume dimmer switch I made a script that takes a direct value for the volume, but I still need to tweak the volume mapping (0 - 100 to the NAD logarithmic -90 + 10 or something like that) to cover the entire range. A function is needed, I haven't gotten around to that. I'll sort it out and post it.
The following screenshot shows how I setup the Selector switch: Here's the input selector script (I called it 'NADSelectDirect.py'). Any of the 8 inputs can be selected/added, I only use four:
The script is called from a bash wrapper script called NADSelector.sh:
I have done the same thing for the on/off python script. There may be a nicer way of calling the scripts I am not aware of, but it works
Regards, Anne
Nice! I wasn't aware of the python 2/3 change, I cloned the git repository when I started with domoticz and I guess it came with Python 3
In the meantime I made a Selector switch for the NAD in which you can turn it on/off and directly select the input, with a separate dimmer switch to control the volume (I then picked up a Homey, spent a couple of frustrating nights wondering whether I should return it until I figured it's actually pretty cool but completely different from domoticz, with a different learning curve... I have not yet gotten around to connecting homey with domoticz to control the NAD amplifier...).
Anyway, the Selector switch is pretty useful.
As to the volume dimmer switch I made a script that takes a direct value for the volume, but I still need to tweak the volume mapping (0 - 100 to the NAD logarithmic -90 + 10 or something like that) to cover the entire range. A function is needed, I haven't gotten around to that. I'll sort it out and post it.
The following screenshot shows how I setup the Selector switch: Here's the input selector script (I called it 'NADSelectDirect.py'). Any of the 8 inputs can be selected/added, I only use four:
Code: Select all
#!/usr/bin/python
TCP_IP = '<insert IP NAD D7050>'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
def send(MESSAGE):
MESSAGE = codecs.decode(MESSAGE, "hex_codec")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
#0001020300 - Coax 1
#0001020301 - Coax 2
#0001020302 - Opt 1
#0001020303 - Opt 2
#0001020304 - Computer
#0001020305 - Stream
#0001020306 - Dock
#0001020307 - BT
def select(n):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
z=0
n=z+1
s.send(codecs.decode("00010203"+(hex(int(n))[2:]).zfill(2), "hex_codec"))
s.close()
def turnOn():
send("0001020901")
if sys.argv[1]=="0":
print ('Selecting Coax 1 input')
# turnOn()
send("0001020300")
# select(0)
elif sys.argv[1]=="1":
print ('Selecting Coax 2 input')
# turnOn()
send("0001020301")
elif sys.argv[1]=="2":
print ('Selecting Optical 1 input')
# turnOn()
send("0001020302")
elif sys.argv[1]=="3":
print ('Selecting Optical 2 input')
# turnOn()
send("0001020303")
elif sys.argv[1]=="4":
print ('Selecting Computer input')
# turnOn()
send("0001020304")
elif sys.argv[1]=="5":
print ('Selecting Stream input')
# turnOn()
send("0001020305")
elif sys.argv[1]=="6":
print ('Selecting Dock input')
# turnOn()
send("0001020306")
elif sys.argv[1]=="7":
print ('Selecting BT input')
# turnOn()
send("0001020307")
Code: Select all
#!/bin/bash
python /opt/domoticz/scripts/python/NADSelectDirect.py "$@"
Regards, Anne
-
- Posts: 29
- Joined: Monday 23 March 2015 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Zwolle
- Contact:
Re: NAD 7050
I just started making that, great work! I will copy your approach and then update the wiki.
Re: NAD 7050
Hi Rob,
I just had a look at the Volume. I am not entirely happy with it, although the dimmer swich now does control the entire range (0 - 192 in the volume script), the steps are small on the low end of the dimmer scale, and relatively big on the high end of the scale, but I guess it's good enough. More often than not I use the volume control in the Spotify or iPeng app.
Here's the volume dimmer switch: The lua script script_device_NADVolume.lua:
And the volume script NADVolumeDimmer.py:
As a sidenote, last week suddenly Spotify connect stopped working... Airplay was fine, but Spofity connect only worked intermittently. I thought I had broken the amplifier, I did a reset, downgrade, upgrade, no difference. In the end it turned out Spotify had an issue on their end, many people had the same problem with all kinds of Spotify devices! Fortunately Spofity addressed the issue and everything has been fine since
Anyway, I guess it can't hurt to insert the usual disclaimer, use at your own risk, etc
I just had a look at the Volume. I am not entirely happy with it, although the dimmer swich now does control the entire range (0 - 192 in the volume script), the steps are small on the low end of the dimmer scale, and relatively big on the high end of the scale, but I guess it's good enough. More often than not I use the volume control in the Spotify or iPeng app.
Here's the volume dimmer switch: The lua script script_device_NADVolume.lua:
Code: Select all
commandArray = {}
if (devicechanged['NADVolume']) then
if (devicechanged['NADVolume']=='Off') then
DomValue = 0;
else
DomValue = otherdevices_svalues['NADVolume'];
end
-- print ("Dimmer value= "..DomValue);
CalcValue = (2*DomValue);
os.execute('python /opt/domoticz/scripts/python/NADVolumeDimmer.py '..CalcValue..'&')
-- print("Volume value= "..CalcValue);
end
return commandArray
~
Code: Select all
#!/usr/bin/python
TCP_IP = '<insert IP NAD D7050>'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
def send(MESSAGE):
MESSAGE = codecs.decode(MESSAGE, "hex_codec")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
s.close()
def getSetVol(delta): # Wireshark capture initial strings
MESSAGE = "000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800000102020b000102020400010202060001020207000102020800010202050001020209000102020a000102020c0001020203000102020d00010207000001020800"
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(codecs.decode(MESSAGE, "hex_codec"))
counter = 0
while True:
x = s.recv(1024)
for a in x:
if counter==11:
z = a
s.send(codecs.decode("00010204"+(hex(int(delta))[2:]).zfill(2), "hex_codec"))
s.close()
return z
counter += 1
v = sys.argv[1]
getSetVol(v)
Anyway, I guess it can't hurt to insert the usual disclaimer, use at your own risk, etc
Re: NAD 7050
Controlling the NAD through the rest API turns out to be trivial
If you look up the IDX of the NAD7050Control device you can use it in the following URL's to control the NAD amplifier through the rest API:
As to the volume, setting a value directly can be done like this:
Or using the NADSofter / NADLouder devices:
If you look up the IDX of the NAD7050Control device you can use it in the following URL's to control the NAD amplifier through the rest API:
Code: Select all
NAD off
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NAD7050Control device>&switchcmd=Set%20Level&level=0
NAD on
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NAD7050Control device>&switchcmd=Set%20Level&level=10
Input Squeezebox
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NAD7050Control device>&switchcmd=Set%20Level&level=20
Input DVD
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NAD7050Control device>&switchcmd=Set%20Level&level=30
etc.
Code: Select all
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NADVolumeControl device>&switchcmd=Set%20Level&level=66
Code: Select all
http://<domoticz-ip>:8080/json.htm?type=command¶m=switchlight&idx=<ID of NADLouder device>&switchcmd=On
-
- Posts: 29
- Joined: Monday 23 March 2015 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Zwolle
- Contact:
Re: NAD 7050
I did a total rewrite of the code making it much simpler, you can find the new one on the wiki page. I cannot upload the two pictures, I think the boss himself is updating the back-end (I saw some things change during the day). It seems to me that the magic number is not required.
Re: NAD 7050
Hi Rob,
Nice!
I have changed my setup to use your script, it is indeed much cleaner.
As a sidenote, the 'standby function' of the NAD D7050 does nothing but change the LED to amber... Power consumption remains at 15W
It does have an 'auto shutoff' feature, but for some reason the setting is automatically turned off at some point... And once the 'auto shutoff' does kick in, the device is unreachable, so the mode is quite useless. I have connected it to a power plug with a standby-killer flow to shut it down when in standby mode for a while.
Thanks,
Regards, Anne
Nice!
I have changed my setup to use your script, it is indeed much cleaner.
As a sidenote, the 'standby function' of the NAD D7050 does nothing but change the LED to amber... Power consumption remains at 15W
It does have an 'auto shutoff' feature, but for some reason the setting is automatically turned off at some point... And once the 'auto shutoff' does kick in, the device is unreachable, so the mode is quite useless. I have connected it to a power plug with a standby-killer flow to shut it down when in standby mode for a while.
Thanks,
Regards, Anne
Re: NAD 7050
Hi Rob,
I have made a Homey app for the D7050, and in the process I figured out (most of) the remaining switches, see below. Mute is obviously a useful addition, but being able to control the power saving options can be useful as well. It's strange that the power saving settings are not preserved after a restart, however you can easily configure the power saving options whenever you start the device. The only snag is that the proper power saving option, 'Eco standby' means the amplifier can only be switched on by a button press or via IR.
I have also found the switches to poll the various states (on/standby, source, volume, mute, power saving options), see below.
Regards, Anne
I have made a Homey app for the D7050, and in the process I figured out (most of) the remaining switches, see below. Mute is obviously a useful addition, but being able to control the power saving options can be useful as well. It's strange that the power saving settings are not preserved after a restart, however you can easily configure the power saving options whenever you start the device. The only snag is that the proper power saving option, 'Eco standby' means the amplifier can only be switched on by a button press or via IR.
I have also found the switches to poll the various states (on/standby, source, volume, mute, power saving options), see below.
Regards, Anne
Code: Select all
# standby / on
0001020900 - standby
0001020901 - on
# Standby - 'Network standby' (No powersaving at all) and 'Eco mode' (uses 1W, but can only wake up by button press or IR). NB: it seems these settings are not preserved after poweroff
00010208000001020208 - auto shutoff disabled
00010208010001020208 - auto shutoff enabled
00010207000001020207 - power save disabled
00010207010001020207 - power save enabled
# Network standby
00010208010001020208 - auto shutoff enabled
00010207000001020207 - power save disabled
# Eco standby
00010208010001020208 - auto shutoff enabled
00010207010001020207 - power save enabled
# inputs/sources
0001020300 - Coax 1
0001020301 - Coax 2
0001020302 - Opt 1
0001020303 - Opt 2
0001020304 - Computer
0001020305 - Stream
0001020306 - Dock
0001020307 - BT
0001020203 - poll inputs
0001020209 - poll standby/on state (response: 0001020900 (standby) / 0001020901 (on)
0001020400 - 00010204c8 Volume
0001020400 - volume (min, -90dB)
00010204c8 - volume (max, 10dB)
0001020204 - poll volume
0001020a01 - mute
0001020a00 - unmute
000102020a - poll mute/unmute. Response not muted 0001020a00, muted 0001020a01
Discovery: 224.0.0.251 bonjour/mDNS, UDP port 5353.
-
- Posts: 29
- Joined: Monday 23 March 2015 19:20
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Zwolle
- Contact:
Re: NAD 7050
Nice, the real off mode works well, a bit of a shame that it does not have wake-up on wlan. Thanks for the information.
Re: NAD 7050
Indeed, and that the 'none-power save' standby uses a full 15W :-/
I have long been confused about the auto shutoff / power save options. I have now figured out that the confusion is caused by the iPhone app disabling both options whenever you use it
I guess you can use the 12V trigger input to wake up the amp...
I have long been confused about the auto shutoff / power save options. I have now figured out that the confusion is caused by the iPhone app disabling both options whenever you use it
I guess you can use the 12V trigger input to wake up the amp...
Who is online
Users browsing this forum: No registered users and 0 guests