11# Need to figure out how to resolve the 'Untyped decorator makes function "..." untyped' errors in mypy when using click decorators
22# mypy: disable-error-code="misc"
33
4- from typing import Any
5-
64import click
75
86from pyomnilogic_local .cli import ensure_connection
9- from pyomnilogic_local .models .mspconfig import (
10- MSPColorLogicLight ,
11- MSPConfig ,
12- )
13- from pyomnilogic_local .models .telemetry import (
14- Telemetry ,
15- TelemetryType ,
16- )
17- from pyomnilogic_local .omnitypes import (
18- ColorLogicBrightness ,
19- ColorLogicPowerState ,
20- ColorLogicShow ,
21- ColorLogicSpeed ,
22- )
7+ from pyomnilogic_local .cli .get .backyard import backyard
8+ from pyomnilogic_local .cli .get .bows import bows
9+ from pyomnilogic_local .cli .get .filters import filters
10+ from pyomnilogic_local .cli .get .heaters import heaters
11+ from pyomnilogic_local .cli .get .lights import lights
12+ from pyomnilogic_local .cli .get .valves import valves
2313
2414
2515@click .group ()
@@ -35,67 +25,10 @@ def get(ctx: click.Context) -> None:
3525 ensure_connection (ctx )
3626
3727
38- @get .command ()
39- @click .pass_context
40- def lights (ctx : click .Context ) -> None :
41- """List all ColorLogic lights and their current settings.
42-
43- Displays information about all lights including their system IDs, names,
44- current state, and available light shows.
45-
46- Example:
47- omnilogic get lights
48- """
49- mspconfig : MSPConfig = ctx .obj ["MSPCONFIG" ]
50- telemetry : Telemetry = ctx .obj ["TELEMETRY" ]
51-
52- lights_found = False
53-
54- # Check for lights in the backyard
55- if mspconfig .backyard .colorlogic_light :
56- for light in mspconfig .backyard .colorlogic_light :
57- lights_found = True
58- _print_light_info (light , telemetry .get_telem_by_systemid (light .system_id ))
59-
60- # Check for lights in Bodies of Water
61- if mspconfig .backyard .bow :
62- for bow in mspconfig .backyard .bow :
63- if bow .colorlogic_light :
64- for cl_light in bow .colorlogic_light :
65- lights_found = True
66- _print_light_info (cl_light , telemetry .get_telem_by_systemid (cl_light .system_id ))
67-
68- if not lights_found :
69- click .echo ("No ColorLogic lights found in the system configuration." )
70-
71-
72- def _print_light_info (light : MSPColorLogicLight , telemetry : TelemetryType | None ) -> None :
73- """Format and print light information in a nice table format.
74-
75- Args:
76- light: Light object from MSPConfig with attributes to display
77- telemetry: Telemetry object containing current state information
78- """
79- click .echo ("\n " + "=" * 60 )
80-
81- light_data : dict [Any , Any ] = {** dict (light ), ** dict (telemetry )} if telemetry else dict (light )
82- for attr_name , value in light_data .items ():
83- if attr_name == "brightness" :
84- value = ColorLogicBrightness (value ).pretty ()
85- elif attr_name == "effects" and isinstance (value , list ):
86- show_names = [show .pretty () if hasattr (show , "pretty" ) else str (show ) for show in value ]
87- value = ", " .join (show_names ) if show_names else "None"
88- elif attr_name == "show" and value is not None :
89- value = ColorLogicShow (value ).pretty ()
90- elif attr_name == "speed" :
91- value = ColorLogicSpeed (value ).pretty ()
92- elif attr_name == "state" :
93- value = ColorLogicPowerState (value ).pretty ()
94- elif isinstance (value , list ):
95- # Format other lists nicely
96- value = ", " .join (str (v ) for v in value ) if value else "None"
97-
98- # # Format the attribute name to be more readable
99- display_name = attr_name .replace ("_" , " " ).title ()
100- click .echo (f"{ display_name :20} : { value } " )
101- click .echo ("=" * 60 )
28+ # Register subcommands
29+ get .add_command (backyard )
30+ get .add_command (bows )
31+ get .add_command (filters )
32+ get .add_command (heaters )
33+ get .add_command (lights )
34+ get .add_command (valves )
0 commit comments