-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_pybeoplay_notifs.py
47 lines (35 loc) · 1.26 KB
/
test_pybeoplay_notifs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pybeoplay import BeoPlay
import logging
import json
import requests
LOG = logging.getLogger(__name__)
if __name__ == '__main__':
import sys
ch = logging.StreamHandler(sys.stdout)
logging.basicConfig(level=logging.DEBUG)
ch.setLevel(logging.DEBUG)
LOG.addHandler(ch)
if len(sys.argv) < 2:
quit()
gateway = BeoPlay(sys.argv[1])
gateway.getDeviceInfo()
print ("Serial Number: " , gateway.serialNumber)
print ("Type Number: ", gateway.typeNumber)
print ("Item Number: ",gateway.itemNumber)
print ("Name: ",gateway.name)
print ("Standby: ", gateway.on)
gateway.getStandby()
print ("Standby: ", gateway.on)
r = requests.get(gateway._host_notifications, stream=True)
if r.encoding is None:
r.encoding = 'utf-8'
for line in r.iter_lines(decode_unicode=True):
if line:
json_line = json.loads(line)
print(json_line)
gateway._processNotification(json_line)
print ("State: ", gateway.state)
print ("Source: ", gateway.source)
print ("Muted: ", gateway.muted)
print ("Volume: ", gateway.volume)
print ("Media Track: ", gateway.media_track)