easink / heos

4 stars 0 forks source link

How does this handle multiple players on the network? #2

Open blysik opened 7 years ago

blysik commented 7 years ago

I have a Heos Drive, and two Heos Links on my network. They have difference IPs and pids. How would I use this to specify which device I'm trying to control?

Thanks!

blysik commented 7 years ago

When I try to select a host manually, it doesn't seem to work. Is this correct syntax?

heos = Heos('192.168.55.176', verbose=True)

Even specifying an IP, it always seems to do the get_players call.

blysik commented 7 years ago

Let me give you both my sample program, and the output:

$ cat test.py

from heos.heos import *
host = '192.168.55.176'
heos = Heos(host,True)
info = heos.get_player_info()
heos.close()
print(info)
$ python3 ./test.py
'heos://player/get_players\r\n'
(b'{"heos": {"command": "player/get_players", "result": "success", "message": "'
 b'"}, "payload": [{"name": "Living Room", "pid": 174479135, "model": "HEOS Dri'
 b've", "version": "1.382.80", "ip": "192.168.55.229", "network": "wired", "lin'
 b'eout": 1}, {"name": "Master Bathroom", "pid": -608667775, "model": "HEOS Dri'
 b've", "version": "1.382.80", "ip": "192.168.55.176", "network": "wired", "lin'
 b'eout": 1}, {"name": "Pool", "pid": -366844967, "model": "HEOS Amp", "version'
 b'": "1.382.80", "ip": "192.168.55.175", "network": "wired", "lineout": 0}, {"'
 b'name": "Playroom", "pid": -608128766, "model": "HEOS Drive", "version": "1.3'
 b'82.80", "ip": "192.168.55.201", "network": "wired", "lineout": 1}, {"name": '
 b'"Master Bedroom", "pid": -3336210, "model": "HEOS Drive", "version": "1.382.'
 b'80", "ip": "192.168.55.228", "network": "wired", "lineout": 1}, {"name": "Fa'
 b'mily Room", "pid": -411275013, "model": "HEOS Link", "version": "1.382.80", '
 b'"ip": "192.168.55.113", "network": "wired", "lineout": 1}]}\r\n')
('{"heos": {"command": "player/get_players", "result": "success", "message": '
 '""}, "payload": [{"name": "Living Room", "pid": 174479135, "model": "HEOS '
 'Drive", "version": "1.382.80", "ip": "192.168.55.229", "network": "wired", '
 '"lineout": 1}, {"name": "Master Bathroom", "pid": -608667775, "model": "HEOS '
 'Drive", "version": "1.382.80", "ip": "192.168.55.176", "network": "wired", '
 '"lineout": 1}, {"name": "Pool", "pid": -366844967, "model": "HEOS Amp", '
 '"version": "1.382.80", "ip": "192.168.55.175", "network": "wired", '
 '"lineout": 0}, {"name": "Playroom", "pid": -608128766, "model": "HEOS '
 'Drive", "version": "1.382.80", "ip": "192.168.55.201", "network": "wired", '
 '"lineout": 1}, {"name": "Master Bedroom", "pid": -3336210, "model": "HEOS '
 'Drive", "version": "1.382.80", "ip": "192.168.55.228", "network": "wired", '
 '"lineout": 1}, {"name": "Family Room", "pid": -411275013, "model": "HEOS '
 'Link", "version": "1.382.80", "ip": "192.168.55.113", "network": "wired", '
 '"lineout": 1}]}\r\n')
[{'ip': '192.168.55.229',
  'lineout': 1,
  'model': 'HEOS Drive',
  'name': 'Living Room',
  'network': 'wired',
  'pid': 174479135,
  'version': '1.382.80'},
 {'ip': '192.168.55.176',
  'lineout': 1,
  'model': 'HEOS Drive',
  'name': 'Master Bathroom',
  'network': 'wired',
  'pid': -608667775,
  'version': '1.382.80'},
 {'ip': '192.168.55.175',
  'lineout': 0,
  'model': 'HEOS Amp',
  'name': 'Pool',
  'network': 'wired',
  'pid': -366844967,
  'version': '1.382.80'},
 {'ip': '192.168.55.201',
  'lineout': 1,
  'model': 'HEOS Drive',
  'name': 'Playroom',
  'network': 'wired',
  'pid': -608128766,
  'version': '1.382.80'},
 {'ip': '192.168.55.228',
  'lineout': 1,
  'model': 'HEOS Drive',
  'name': 'Master Bedroom',
  'network': 'wired',
  'pid': -3336210,
  'version': '1.382.80'},
 {'ip': '192.168.55.113',
  'lineout': 1,
  'model': 'HEOS Link',
  'name': 'Family Room',
  'network': 'wired',
  'pid': -411275013,
  'version': '1.382.80'}]
'heos://player/get_player_info?pid=174479135\r\n'
(b'{"heos": {"command": "player/get_player_info", "result": "success", "message'
 b'": "pid=174479135"}, "payload": {"name": "Living Room", "pid": 174479135, "m'
 b'odel": "HEOS Drive", "version": "1.382.80", "ip": "192.168.55.229", "network'
 b'": "wired", "lineout": 1}}\r\n')
('{"heos": {"command": "player/get_player_info", "result": "success", '
 '"message": "pid=174479135"}, "payload": {"name": "Living Room", "pid": '
 '174479135, "model": "HEOS Drive", "version": "1.382.80", "ip": '
 '"192.168.55.229", "network": "wired", "lineout": 1}}\r\n')
{'ip': '192.168.55.229',
 'lineout': 1,
 'model': 'HEOS Drive',
 'name': 'Living Room',
 'network': 'wired',
 'pid': 174479135,
 'version': '1.382.80'}
{'network': 'wired', 'model': 'HEOS Drive', 'ip': '192.168.55.229', 'name': 'Living Room', 'lineout': 1, 'version': '1.382.80', 'pid': 174479135}
$
easink commented 7 years ago

Sorry, but this isnt implemented, I only have one speaker. If you can stand one ugly solution you should be able to set heos._player_id to a pid of choice. Please patch, or I will probably update in the future.

blysik commented 7 years ago

That ugly workaround works! Thanks.