Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions eiscp/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ def filter_for_message(getter_func, msg):
# It seems ISCP commands are always three characters.
if candidate and candidate[:3] == msg[:3]:
return candidate
elif candidate and candidate[:3] == 'MDI' and msg[:3] == 'MGS':
# the MGS command for grouping multiroom audio, returns an MDI message, not MGS
return candidate

# exception for HDMI-CEC commands (CTV) since they don't provide any response/confirmation
if "CTV" in msg[:3]:
Expand Down Expand Up @@ -564,6 +567,25 @@ def power_off(self):
"""Turn the receiver power off."""
return self.command('power', 'off')

def group_with(self, otherIDs=[]):
"""Create a multiroom audio / flareconnect group with the supplied device IDs.
Calling this without arguments or an empty list stops the multiroom audio / flareconnect group.
Calling this method twice with the same arguments does not generate a response from the receiver, thus causing a timeout on the message."""
if otherIDs:
# check if the supplied deviceIDs are all strings
for ID in otherIDs:
if type(ID) != str:
raise ValueError('group_with needs a list object, with each device identifier as a string')
# construct a MGS message with a list of the device IDs
message='MGS<mgs zone="1"><groupid>1</groupid><maxdelay>500</maxdelay><devices>' + \
'<device id="%s" zoneid="1"/>'%(self.identifier) + \
''.join(['<device id="%s" zoneid="1"/>'%(ID) for ID in otherIDs]) + \
'</devices></mgs>'
else:
# No other devices specified. Create an empty group, which stops the multiroom audio / flareconnect
message='MGS<mgs zone="1"><groupid>0</groupid></mgs>'
return self.raw(message)

def get_nri(self):
"""Return NRI info as dict."""
data = self.command("dock.receiver-information=query")[1]
Expand Down
9 changes: 9 additions & 0 deletions eiscp/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
%(prog_n_space)s [--all] [--name <name>] [--id <identifier>]
%(prog_n_space)s [--verbose | -v]... [--quiet | -q]... <command>...
%(program_name)s --discover
%(program_name)s [--host <host>] [--group_with <otherhost> ...]
%(program_name)s --help-commands [<zone> <command>]
%(program_name)s -h | --help

Expand All @@ -31,6 +32,11 @@
Turn receiver on, select "PC" source, set volume to 75.
%(program_name)s zone2.power=standby
To execute a command for zone that isn't the main one.
%(program_name)s --host 192.168.1.15 --group_with "0009B0E4B723" "0009B0E4B724"
Setup multiroom audio using Flareconnect. The <host> receiver is source, all receiver IDs supplied for <otherhost> join the <host> in a Flareconnect group.
Use the --discover option to get the receiver IDs.
%(program_name)s --host 192.168.1.15 --group_with
Stop the multiroom audio group / flareconnect.
'''

import sys
Expand Down Expand Up @@ -112,6 +118,9 @@ def main(argv=sys.argv):
print('No receivers found.')
return 1

if options['--group_with']:
receivers[0].group_with(options['<otherhost>'])

# List of commands to execute - deal with special shortcut case
to_execute = options['<command>']

Expand Down