yeemidi test project
src/wizard_lightcheck.py
Source file coverage
Path:
src/wizard_lightcheck.py
Lines:
42
Non-empty lines:
37
Non-empty lines covered with requirements:
37 / 37 (100.0%)
Functions:
1
Functions covered by requirements:
1 / 1 (100.0%)
1
"""
2
@relation(YMD-SYS-5, scope=file)
3
"""
4
import logging
5
import os
6
import argparse
7
import console as CON
8
import consts as C
9
import midi_bulb as MB
10
 
11
logger = logging.getLogger(__name__)
12
 
13
 
14
def main() -> None:
15
    #
16
    # Arguments parsing
17
    parser = argparse.ArgumentParser(description="Yeelight lightcheck")
18
    parser.add_argument("-f", "--file", type=str,
19
                        help="File to load configuration from.", default="config.yml")
20
    args = parser.parse_args()
21
    #
22
    # Logging initiation
23
    logging.basicConfig(
24
        level=logging.DEBUG, format="%(name)s - %(levelname)s - %(message)s", filename="lightcheck.log")
25
    logger.info("Yeelight lightcheck started.")
26
    #
27
    # Console initiation
28
    os.system("clear" if os.name == "posix" else "cls")
29
    print(C.GREEN(C.YEEMIDI_LIGHTCHECK_TEXT))
30
    con = CON.Console()
31
    greouped_bulbs = MB.from_yaml(args.file)
32
    for channel, bulbs_in_channel in greouped_bulbs.items():
33
        con.print(f"Checking channel {C.BLUE(channel)}:")
34
        con.print(
35
            f"Found {C.BLUE(len(bulbs_in_channel))} bulb(s) in this channel.")
36
        with MB.distinguish_channel(bulbs_in_channel):
37
            con.input_str("Press Enter to continue...")
38
        con.refresh()
39
 
40
 
41
if __name__ == "__main__":
42
    main()