File: simple.py

package info (click to toggle)
pyjvcprojector 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 280 kB
  • sloc: python: 4,075; makefile: 21; sh: 5
file content (48 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download
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
import asyncio
import logging
import sys

from jvcprojector import JvcProjector, command

logging.basicConfig(level=logging.WARNING)


async def main():
    jp = JvcProjector(sys.argv[1])
    await jp.connect()

    print("Projector model info:")
    print({
        "model": jp.model,
        "spec": jp.spec,
    })

    if await jp.get(command.Power) == command.Power.STANDBY:
        print("Turning projector on...")
        await jp.set(command.Power, command.Power.ON)
        await asyncio.sleep(1)

    if await jp.get(command.Power) == command.Power.WARMING:
        print("Waiting for projector to warmup...")
        while await jp.get(command.Power) != command.Power.ON:
            await asyncio.sleep(3)
    elif await jp.get(command.Power) == command.Power.COOLING:
        print("Run command after projector has cooled down")
        sys.exit(0)

    # Example of sending remote codes
    print("Showing info on screen")
    await jp.remote(command.Remote.INFO)
    await asyncio.sleep(5)
    print("Hiding info on screen")
    await jp.remote(command.Remote.BACK)

    # Example of reference command
    print("Current projector input:")
    print(await jp.get(command.Input))

    await jp.disconnect()


if __name__ == "__main__":
    asyncio.run(main())