forked from nugget/python-anthemav
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·54 lines (39 loc) · 1.73 KB
/
example.py
File metadata and controls
executable file
·54 lines (39 loc) · 1.73 KB
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
48
49
50
51
52
53
54
#!/usr/bin/env python3
import argparse
import asyncio
import anthemav
import logging
log = logging.getLogger(__name__)
@asyncio.coroutine
def test():
parser = argparse.ArgumentParser(description=test.__doc__)
parser.add_argument('--host', default='127.0.0.1', help='IP or FQDN of AVR')
parser.add_argument('--port', default='14999', help='Port of AVR')
parser.add_argument('--verbose', '-v', action='count')
args = parser.parse_args()
if args.verbose:
level = logging.DEBUG
else:
level = logging.ERROR
logging.basicConfig(level=level)
def log_callback(message):
log.info('Callback invoked: %s' % message)
host = args.host
port = int(args.port)
log.info('Connecting to Anthem AVR at %s:%i' % (host, port))
conn = yield from anthemav.Connection.create(host=host,port=port,loop=loop,update_callback=log_callback)
log.info('Power state is '+str(conn.protocol.power))
conn.protocol.power = True
log.info('Power state is '+str(conn.protocol.power))
yield from asyncio.sleep(2, loop=loop)
log.info('Panel brightness (raw) is '+str(conn.protocol.panel_brightness))
log.info('Panel brightness (text) is '+str(conn.protocol.panel_brightness_text))
log.info('Video resolution (text) is '+str(conn.protocol.video_input_resolution_text))
log.info('Audio input channels (text) is '+str(conn.protocol.audio_input_channels_text))
log.info('Audio input format (text) is '+str(conn.protocol.audio_input_format_text))
log.info('Audio listening mode (text) is '+str(conn.protocol.audio_listening_mode_text))
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()
asyncio.async(test())
loop.run_forever()