Debian Codegraph @

examples/simple.py

raw
1 import asyncio
2 import logging
3 import sys
4
5 from jvcprojector import JvcProjector, command
6
7 logging.basicConfig(level=logging.WARNING)
8
9
10 async def main():
11 jp = JvcProjector(sys.argv[1])
12 await jp.connect()
13
14 print("Projector model info:")
15 print({
16 "model": jp.model,
17 "spec": jp.spec,
18 })
19
20 if await jp.get(command.Power) == command.Power.STANDBY:
21 print("Turning projector on...")
22 await jp.set(command.Power, command.Power.ON)
23 await asyncio.sleep(1)
24
25 if await jp.get(command.Power) == command.Power.WARMING:
26 print("Waiting for projector to warmup...")
27 while await jp.get(command.Power) != command.Power.ON:
28 await asyncio.sleep(3)
29 elif await jp.get(command.Power) == command.Power.COOLING:
30 print("Run command after projector has cooled down")
31 sys.exit(0)
32
33 # Example of sending remote codes
34 print("Showing info on screen")
35 await jp.remote(command.Remote.INFO)
36 await asyncio.sleep(5)
37 print("Hiding info on screen")
38 await jp.remote(command.Remote.BACK)
39
40 # Example of reference command
41 print("Current projector input:")
42 print(await jp.get(command.Input))
43
44 await jp.disconnect()
45
46
47 if __name__ == "__main__":
48 asyncio.run(main())