forked from dgomes/pyhifiberry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_local.py
44 lines (33 loc) · 1.3 KB
/
test_local.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
import aiohttp
import asyncio
from pyhifiberry import audiocontrol2
async def main():
try:
async with aiohttp.ClientSession() as session:
api = audiocontrol2.Audiocontrol2(session, host="192.168.1.150")
status = await api.status()
print(status)
print(await api.info())
return
print(await api.metadata())
print(await api.volume())
print("Start playing")
await api.player("play")
status = await api.player("status")
assert any([player['state'] == 'playing' for player in status['players']])
await api.player("pause")
await asyncio.sleep(2)
await api.player("play")
current_volume = await api.volume()
print(await api.volume("-5"))
assert current_volume-5 == await api.volume()
await asyncio.sleep(2)
print(await api.volume("+5"))
assert current_volume == await api.volume()
print(await api.metadata())
except audiocontrol2.Audiocontrol2Exception as err:
print(err)
if err.original:
print("Original Exception: ", err.original)
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())