File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change
1
+ import logging
1
2
from enum import Enum , unique
2
3
4
+ _LOGGER = logging .getLogger (__name__ )
5
+
3
6
4
7
@unique
5
8
class UIClass (str , Enum ):
@@ -70,6 +73,13 @@ class UIClass(str, Enum):
70
73
WINDOW = "Window"
71
74
WINDOW_HANDLE = "WindowHandle"
72
75
76
+ UNKNOWN = "unknown"
77
+
78
+ @classmethod
79
+ def _missing_ (cls , value ): # type: ignore
80
+ _LOGGER .warning (f"Unsupported value { value } has been returned for { cls } " )
81
+ return cls .UNKNOWN
82
+
73
83
74
84
@unique
75
85
class UIWidget (str , Enum ):
@@ -394,3 +404,10 @@ class UIWidget(str, Enum):
394
404
ZWAVE_TRANSCEIVER = "ZWaveTransceiver"
395
405
ZIGBEE_NETWORK = "ZigbeeNetwork"
396
406
ZIGBEE_STACK = "ZigbeeStack"
407
+
408
+ UNKNOWN = "unknown"
409
+
410
+ @classmethod
411
+ def _missing_ (cls , value ): # type: ignore
412
+ _LOGGER .warning (f"Unsupported value { value } has been returned for { cls } " )
413
+ return cls .UNKNOWN
Original file line number Diff line number Diff line change 15
15
GatewaySubType ,
16
16
GatewayType ,
17
17
ProductType ,
18
+ UIClass ,
19
+ UIWidget ,
18
20
UpdateBoxStatus ,
19
21
)
20
22
@@ -151,8 +153,8 @@ class Device:
151
153
controllable_name : str
152
154
definition : Definition
153
155
data_properties : list [dict [str , Any ]] | None = None
154
- widget : str | None = None
155
- ui_class : str | None = None
156
+ widget : UIWidget
157
+ ui_class : UIClass
156
158
states : States
157
159
type : ProductType
158
160
place_oid : str
@@ -168,8 +170,8 @@ def __init__(
168
170
controllable_name : str ,
169
171
definition : dict [str , Any ],
170
172
data_properties : list [dict [str , Any ]] | None = None ,
171
- widget : str | None = None ,
172
- ui_class : str | None = None ,
173
+ widget : str ,
174
+ ui_class : str ,
173
175
states : list [dict [str , Any ]] | None = None ,
174
176
type : int ,
175
177
place_oid : str ,
@@ -185,8 +187,8 @@ def __init__(
185
187
self .controllable_name = controllable_name
186
188
self .states = States (states )
187
189
self .data_properties = data_properties
188
- self .widget = widget
189
- self .ui_class = ui_class
190
+ self .widget = UIWidget ( widget )
191
+ self .ui_class = UIClass ( ui_class )
190
192
self .type = ProductType (type )
191
193
self .place_oid = place_oid
192
194
You can’t perform that action at this time.
0 commit comments