77class Device :
88 __slots__ = (
99 "id" ,
10+ "attributes" ,
1011 "controllable_name" ,
1112 "creation_time" ,
1213 "last_update_time" ,
@@ -28,7 +29,9 @@ class Device:
2829 def __init__ (
2930 self ,
3031 * ,
32+ attributes : Optional [List [Dict [str , Any ]]] = None ,
3133 available : bool ,
34+ enabled : bool ,
3235 label : str ,
3336 deviceurl : str ,
3437 controllable_name : str ,
@@ -42,32 +45,39 @@ def __init__(
4245 ** _ : Any
4346 ) -> None :
4447 self .id = deviceurl
48+ self .attributes = [State (** a ) for a in attributes ] if attributes else None
4549 self .available = available
46- self .definition = definition
50+ self .definition = Definition ( ** definition )
4751 self .deviceurl = deviceurl
52+ self .enabled = enabled
4853 self .label = label
4954 self .controllable_name = controllable_name
50- self .states = states
51- # self.states = [State(**s) for s in states]
55+ self .states = [State (** s ) for s in states ] if states else None
5256 self .data_properties = data_properties
5357 self .widget = widget
5458 self .ui_class = ui_class
5559 self .qualified_name = qualified_name
5660 self .type = type
5761
5862
59- # class Definition:
60- # __slots__ = (
61- # "commands",
62- # "states",
63- # "widget_name",
64- # "ui_class",
65- # "ui_classifiers" "type",
66- # )
63+ class Definition :
64+ __slots__ = ("commands" , "states" , "widget_name" , "ui_class" , "qualified_name" )
6765
68- # def __init__(self, command_name: str, nparams: int, **_: Any) -> None:
69- # self.command_name = command_name
70- # self.nparams = nparams
66+ def __init__ (
67+ self ,
68+ * ,
69+ commands : List [Dict [str , Any ]],
70+ states : Optional [List [Dict [str , Any ]]] = None ,
71+ widget_name : str ,
72+ ui_class : str ,
73+ qualified_name : str ,
74+ ** _ : Any
75+ ) -> None :
76+ self .commands = [CommandDefinition (** cd ) for cd in commands ]
77+ self .states = [StateDefinition (** sd ) for sd in states ] if states else None
78+ self .widget_name = widget_name
79+ self .ui_class = ui_class
80+ self .qualified_name = qualified_name
7181
7282
7383class StateDefinition :
@@ -78,7 +88,11 @@ class StateDefinition:
7888 )
7989
8090 def __init__ (
81- self , qualified_name : str , type : str , values : Optional [str ], ** _ : Any
91+ self ,
92+ qualified_name : str ,
93+ type : str ,
94+ values : Optional [List [str ]] = None ,
95+ ** _ : Any
8296 ) -> None :
8397 self .qualified_name = qualified_name
8498 self .type = type
@@ -125,6 +139,69 @@ class CommandMode(Enum):
125139 internal = "internal"
126140
127141
142+ class Event :
143+ __slots__ = (
144+ "timestamp" ,
145+ "name" ,
146+ "gateway_id" ,
147+ "exec_id" ,
148+ "deviceurl" ,
149+ "device_states" ,
150+ "old_state" ,
151+ "new_state" ,
152+ "owner_key" ,
153+ )
154+
155+ def __init__ (
156+ self ,
157+ timestamp : int ,
158+ name : str ,
159+ gateway_id : Optional [str ] = None ,
160+ exec_id : Optional [str ] = None ,
161+ deviceurl : Optional [str ] = None ,
162+ device_states : Optional [List [Dict [str , Any ]]] = None ,
163+ old_state : Optional [str ] = None ,
164+ new_state : Optional [str ] = None ,
165+ ** _ : Any
166+ ):
167+ self .timestamp = timestamp
168+ self .name = name
169+ self .gateway_id = gateway_id
170+ self .exec_id = exec_id
171+ self .deviceurl = deviceurl
172+ self .device_states = (
173+ [State (** s ) for s in device_states ] if device_states else None
174+ )
175+ self .old_state = old_state
176+ self .new_state = new_state
177+
178+
179+ class Execution :
180+
181+ __slots__ = (
182+ "id" ,
183+ "description" ,
184+ "owner" ,
185+ "state" ,
186+ "action_group" ,
187+ )
188+
189+ def __init__ (
190+ self ,
191+ id : str ,
192+ description : str ,
193+ owner : str ,
194+ state : str ,
195+ action_group : List [Dict [str , Any ]],
196+ ** _ : Any
197+ ):
198+ self .id = id
199+ self .description = description
200+ self .owner = owner
201+ self .state = state
202+ self .action_group = action_group
203+
204+
128205class Scenario :
129206 __slots__ = ("label" , "oid" )
130207
0 commit comments