Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Quick and dirty XMC-1 remote control. Hard coded port and IP for now.
- # Beerware / ian Butler / dualityk (emotiva lounge) / 9/2017
- # Old XMC-1 firmware will wake up if the screen is off, but not do anything;
- # you have to send a second command before it listens. FW 4.1 is fixed.
- # Set your preamp's IP here. This is all you have to change.
- EMOPORT = ("192.168.0.111", 7002)
- import argparse, socket
- # Heavy lifting done by argument parser
- args = argparse.ArgumentParser()
- args.add_argument('--input-1', dest='togs', action='append_const', const='<source_1 value="0" />', help='set source to input 1')
- args.add_argument('--input-2', dest='togs', action='append_const', const='<source_2 value="0" />', help='set source to input 2')
- args.add_argument('--input-3', dest='togs', action='append_const', const='<source_3 value="0" />', help='set source to input 3')
- args.add_argument('--input-4', dest='togs', action='append_const', const='<source_4 value="0" />', help='set source to input 4')
- args.add_argument('--input-5', dest='togs', action='append_const', const='<source_5 value="0" />', help='set source to input 5')
- args.add_argument('--input-6', dest='togs', action='append_const', const='<source_6 value="0" />', help='set source to input 6')
- args.add_argument('--input-7', dest='togs', action='append_const', const='<source_7 value="0" />', help='set source to input 7')
- args.add_argument('--input-8', dest='togs', action='append_const', const='<source_8 value="0" />', help='set source to input 8')
- args.add_argument('--input-tuner', dest='togs', action='append_const', const='<source_tuner value="0" />', help='set source to tuner')
- args.add_argument('-M', '--menu', dest='togs', action='append_const', const='<menu value="0" />', help='toggle menu')
- args.add_argument('-u', '--up', dest='togs', action='append_const', const='<up value="0" />', help='menu up')
- args.add_argument('-d', '--down', dest='togs', action='append_const', const='<down value="0" />', help='menu down')
- args.add_argument('-l', '--left', dest='togs', action='append_const', const='<left value="0" />', help='menu left')
- args.add_argument('-r', '--right', dest='togs', action='append_const', const='<right value="0" />', help='menu right')
- args.add_argument('-e', '--enter', dest='togs', action='append_const', const='<enter value="0" />', help='menu enter')
- args.add_argument('-b', '--brightness', dest='togs', action='append_const', const='<dim value="0" />', help='cycle display brightness')
- args.add_argument('-i', '--info', dest='togs', action='append_const', const='<info value="0" />', help='information screen')
- args.add_argument('-m', '--mute', dest='togs', action='append_const', const='<mute value="0" />', help='toggle mute')
- args.add_argument('-R', '--reference', dest='togs', action='append_const', const='<reference_stereo value="0" />', help='toggle reference stereo')
- args.add_argument('--movie', dest='togs', action='append_const', const='<movie value="0" />', help='select movie preset')
- args.add_argument('--music', dest='togs', action='append_const', const='<music value="0" />', help='select music preset')
- args.add_argument('-o', '--poweron', dest='togs', action='append_const', const='<power_on value="0" />', help='zone 1 power on')
- args.add_argument('-O', '--poweroff', dest='togs', action='append_const', const='<power_off value="0" />', help='zone 1 power off')
- args.add_argument('-L', '--loudness', dest='togs', action='append_const', const='<loudness value="0" />', help='zone 1 loudness')
- args.add_argument('-s', '--speaker-preset', dest='togs', action='append_const', const='<speaker_preset value="0" />', help='cycle speaker presets')
- args.add_argument('-z', '--zone2-power', dest='togs', action='append_const', const='<zone2_power value="0" />', help='toggle zone 2 power')
- args.add_argument('--band', dest='togs', action='append_const', const='<zone1_band value="0" />', help='tuner band am/fm')
- args.add_argument('-v', '--volume', type=int, default=0, help='change zone 1 volume by n dB')
- args.add_argument('-D', '--mode', type=int, default=0, help='mode +/-')
- args.add_argument('-C', '--center', type=int, default=0, help='center trim +/-')
- args.add_argument('-W', '--sub', type=int, default=0, help='sub trim +/-')
- args.add_argument('-S', '--surround', type=int, default=0, help='surround trim +/-')
- args.add_argument('-B', '--back', type=int, default=0, help='back trim +/-')
- args.add_argument('-I', '--input', type=int, default=0, help='cycle zone 1 inputs +/-')
- args.add_argument('-Z', '--zone2-input', dest='z2input', type=int, default=0, help='cycle zone 2 inputs +/-')
- args.add_argument('-V', '--zone2-volume', dest='z2vol', type=int, default=0, help='change zone 2 volume by n dB')
- args.add_argument('-f', '--tuner-frequency', dest='freq', type=int, default=0, help='tuner frequency +/-')
- args.add_argument('-F', '--tuner-seek', dest='seek', type=int, default=0, help='tuner seek +/-')
- args.add_argument('-c', '--tuner-channel', dest='channel', type=int, default=0, help='tuner preset +/-')
- x = args.parse_args()
- # Build the XML payload
- blast = '<?xml version="1.0"?><emotivaControl>'
- # Iterate through all the easy pushbutton strings created above
- if x.togs:
- for i in x.togs:
- blast += i
- # Add all the commands that require arguments
- if x.volume: blast += '<volume value="' +str(x.volume)+ '" />'
- if x.mode: blast += '<mode value="' +str(x.mode)+ '" />'
- if x.center: blast += '<center value="' +str(x.center)+ '" />'
- if x.sub: blast += '<subwoofer value="'+str(x.sub)+ '" />'
- if x.surround: blast += '<surround value="' +str(x.surround)+ '" />'
- if x.back: blast += '<back value="' +str(x.back)+ '" />'
- if x.input: blast += '<input value="' +str(x.input)+ '" />'
- if x.z2input: blast += '<zone2_input value="'+str(x.z2input)+'" />'
- if x.z2vol: blast += '<zone2_volume value="'+str(x.z2vol)+ '" />'
- if x.freq: blast += '<frequency value="'+str(x.freq)+ '" />'
- if x.seek: blast += '<seek value="' +str(x.seek)+ '" />'
- if x.channel: blast += '<channel value="' +str(x.channel)+ '" />'
- blast += '</emotivaControl>'
- # Send and done.
- socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(blast, EMOPORT)
- print 'All your problems are over.'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement