File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -693,7 +693,7 @@ async def get_reference_ui_classes(self) -> list[str]:
693693 return await self .__get ("reference/ui/classes" )
694694
695695 @retry_on_auth_error
696- async def get_reference_ui_classifiers (self ) -> JSON :
696+ async def get_reference_ui_classifiers (self ) -> list [ str ] :
697697 """Get a list of all defined UI classifiers."""
698698 return await self .__get ("reference/ui/classifiers" )
699699
Original file line number Diff line number Diff line change @@ -462,3 +462,16 @@ class UIWidget(UnknownEnumMixin, StrEnum):
462462 ZWAVE_TRANSCEIVER = "ZWaveTransceiver"
463463 ZIGBEE_NETWORK = "ZigbeeNetwork"
464464 ZIGBEE_STACK = "ZigbeeStack"
465+
466+
467+ @unique
468+ class UIClassifier (UnknownEnumMixin , StrEnum ):
469+ """Enumeration of UI classifiers used to categorize device types."""
470+
471+ UNKNOWN = "unknown"
472+
473+ COOLING_SYSTEM = "coolingSystem"
474+ EMITTER = "emitter"
475+ GENERATOR = "generator"
476+ HEATING_SYSTEM = "heatingSystem"
477+ SENSOR = "sensor"
Original file line number Diff line number Diff line change @@ -202,6 +202,27 @@ def to_enum_name(value: str) -> str:
202202
203203 lines .append ("" ) # End with newline
204204
205+ # Fetch and add UI classifiers
206+ ui_classifiers = cast (list [str ], await client .get_reference_ui_classifiers ())
207+
208+ lines .append ("" )
209+ lines .append ("@unique" )
210+ lines .append ("class UIClassifier(UnknownEnumMixin, StrEnum):" )
211+ lines .append (
212+ ' """Enumeration of UI classifiers used to categorize device types."""'
213+ )
214+ lines .append ("" )
215+ lines .append (' UNKNOWN = "unknown"' )
216+ lines .append ("" )
217+
218+ # Add UI classifiers
219+ sorted_classifiers = sorted (ui_classifiers )
220+ for ui_classifier in sorted_classifiers :
221+ enum_name = to_enum_name (ui_classifier )
222+ lines .append (f' { enum_name } = "{ ui_classifier } "' )
223+
224+ lines .append ("" ) # End with newline
225+
205226 # Write to the ui.py file
206227 output_path = Path (__file__ ).parent .parent / "pyoverkiz" / "enums" / "ui.py"
207228 output_path .write_text ("\n " .join (lines ))
@@ -215,6 +236,7 @@ def to_enum_name(value: str) -> str:
215236 print (f"✓ Added { len (ui_widgets )} UI widgets from API" )
216237 print (f"✓ Added { additional_widget_count } additional hardcoded UI widgets" )
217238 print (f"✓ Total: { len (sorted_widgets )} UI widgets" )
239+ print (f"✓ Added { len (sorted_classifiers )} UI classifiers" )
218240
219241
220242async def generate_all () -> None :
You can’t perform that action at this time.
0 commit comments