NAD7050
Jump to navigation
Jump to search
Purpose
Operate the NAD D 7050 Direct Digital Network Amplifier from Domoticz.
Dependencies - hardware / software / operating system
- NAD D 7050 Direct Digital Network Amplifier
- python3 (sudo apt-get install python3)
Domoticz Setup - switches, variables, version
- Setup -> Hardware
- For type select Dummy
- Press Add
- Press the create virtual sensors blue bubble on the new device that appeared on the top
- Type NADControl for the name and select Selector for the type
- Press the create virtual sensors blue bubble again
- Type NADVolume for the name and select Dimmer for the type
- Go to the switches tab
- Edit the NADVolume slider and give them an amplifier icon
- Edit the NADControl button and give it an amplifier icon. Furthermore, link the switches to the commands for the python script as:
Installation instructions
The NAD 7050 should be connected to the network and have a static IP.
Scripts with comments
A python script sents the commands to the NAD7050. The script must be called with the new volume setting when changing the volume and we use a LUA script for that. This can be done under setup -> more options -> events. Under event name type NAD7050 and select lua instead of blockly. Then paste the following script in the text box:
commandArray = {}
if (devicechanged['NADVolume']) then
volume = devicechanged['NADVolume']
os.execute('/home/pi/domoticz/scripts/python/nad_selector.py volume "'..volume..'"')
end
return commandArray
and press save. Now we still need the python script that actually operates the NAD7050, inspired by the work of Tom Hartley (https://gist.github.com/anonymous/07cd28fe578ec49839db). *Create the following script named nad_selector.py in /home/pi/domoticz/scripts/python
- Do not forget to change the ip address to match the static IP of your NAD 7050
- And make the file executable using chmod u+x nad_selector.py
#!/usr/bin/python3
TCP_IP = '192.168.10.23'
TCP_PORT = 50001
BUFFER_SIZE = 1024
import socket
import sys, time
import codecs
# Function to send codes to the NAD7050
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()
command = sys.argv[1]
if command == 'source':
channel = int(sys.argv[2]) # Input number from command line
send('0001020901') # Switch NAD on
time.sleep(0.5) # Otherwise the second connection is refused
send('000102030' + str(channel)) # Select input
elif command == 'volume': # Set the volume
volume_number = sys.argv[2].split(':')[1].split('%')[0]
volume = 2*int(volume_number) # NAD volume runs from 0 to 200
volume_hex = str(hex(volume)[2:]).zfill(2) # And is entered as hex
send('00010204'+volume_hex)
elif command == 'off':
send('00010207010001020207') # Enable Eco mode
time.sleep(0.5)
send('0001020900') # Off command (no longer reachable by network)
else:
print('command not recognized')